virtualenv venv
. venv/bin/activate
pip install -r requirements.txt
For documentation for the basketball environment, click here
python run_agent.py --envname='scale_draw' --episodes=20000 --agent='sac'
Agents to choose from: SAC (recommended), A2C, PPO (recommended when using raw images as input)
Arguments: --agent='sac'
, agent='a2c'
or agent='ppo'
Add the lines --overwriting
and --location='path'
to save the trained agent in the savedagents/models/ folder.
python run_agent.py --envname='scale_draw' --episodes=50000 --overwriting --location='SAC_new_agent'
Sides:
--sides=1
(default): boxes can be placed anywhere on the scale by agent and from environment side when resetting the places--sides=2
: the environment chooses places for its boxes on the left side, the agent only is allowed to place his boxes on the right side
Densities:
--random_densities
: densities of boxes can have values between 4 and 6- else: all boxes have the same density (5.0)
Sizes of the boxes:
--random_boxsizes
: the size of one box is randomized to a value between 0.8 and 1.2- else: all boxes have size 1.0
Number of boxes:
--actions=2
: number of boxes that have to be placed by the agent (default: 1)--placed=1
: number of the boxes that have been placed randomly beforehand from the environment (default: 1)
- Seed: set the seed of an environment individually by adding
--seeding=1234
(default: 42) - If you somehow cannot install Xvfb (like on Mac), add the
--disable_xvfb
argument - Number of episodes:
--episodes=50000
(default: 10000) - Steps between each print:
--printevery=100
(default: 500) - Use pixels as observations instead of extracted values:
--raw_pixels
- Normalization of observations and actions:
--normalize
- Render the simulation:
--rendering
python run_agent.py --envname='scale_draw' --random_densities --random_boxsizes --episodes=25000 --overwriting --location="SAC_25000" --raw_pixels
- important: use the same box settings (number of boxes, number of actions, ...) and the same location from the training before
- then, run the command by adding the argument
--test
- also state how much episodes you want to test the agent (by default:
--episodes=10000
)
python run_agent.py --envname='scale_draw' --random_densities --random_boxsizes --episodes=1000 --location="SAC_25000" --raw_pixels --test
- first, make sure you have an agent saved, from which we want to extract data including box positions at the end and the sizes and densities of the boxes
- to extract these information, run something like this
python DataExtraction/extract_data.py --envname="scale_draw" --random_densities --random_boxsizes --episodes=1000 --location="SAC_25000" --path="result25000"
- important here is, that we still use the same flags as before when we trained this agent (e.g. use
--random_densities
and--random_boxsizes
)
The files will be saved in the savedagents/results/ folder as a csv file, which we can name with the --path
flag (e.g. --path="result2500"
)
...
Once we ran the extract_data.py file, we have a CSV file in the savedagents/results/ folder with following structure:
Position 1 | Position 2 | Density 1 | Density 2 | Box Size 1 | Box Size 2 | |
---|---|---|---|---|---|---|
0 | 0.30554572 | -0.3609829 | 4.2378 | 4.926749 | 1.135487 | 1.0633456 |
1 | 0.57666147 | -0.26535797 | 4.6346793 | 4.3976474 | 0.8974464 | 1.1024169 |
==NOTE:== for now, it only works with two boxes, which mean that we can only use or default setting with one box placed by the agent and one placed randomly before on the scale.
(todo: explain how to use the symbolic regression files)