Scenario Runner
A utility to run scenarios, repeat them and output the results to a csv file.
To use define a list of scenarios (objects of class:
Scenario
) and invoke the function run_scenarios()
- class discopygal.experiments.scenarios_runner.Scenario(solver_class, scene_path, parameters, time_limit, repetitions)
A type that defines a scenario - All the info required to run a solver on a scene.
- solver_class
- Solver class to use.Required parameter
- scene_path
- Path to json scene file to use.Required parameter
- parameters
- Parameters to pass to solver as dict: {<parameter_name>: <parameter_value>}.For parameters that won’t be explicitly specified, their default value as defined in the solver will be used.Optional - default is {}, e.g. the default args of the solver
- time_limit
- Max time to allow the solver to run (in seconds).If solver exceeds this time it stops and regarded as it failed.Optional - default is None - e.g. no time limit
- repetitions
- Number of times to repeat this scenario.Results of the scenario are average of all there repetitions.Optional - default is 10.
- parameters
Alias for field number 2
- repetitions
Alias for field number 4
- scene_path
Alias for field number 1
- solver_class
Alias for field number 0
- time_limit
Alias for field number 3
- exception discopygal.experiments.scenarios_runner.TimeoutException
- discopygal.experiments.scenarios_runner.run_scenarios(scenarios, results_file_path)
Run given scenarios and outputs the results to given file as csv
- Parameters:
scenarios ([
Scenario
]) – List of scenarios to runresults_file_path (
str
) – Output csv file path. Will override the file!
Example
from discopygal.experiments.scenarios_runner import run_scenarios, Scenario
from discopygal.solvers.rrt.drrt_star import dRRT_star
SCENE_PATH = "examples/scenes/2_pocket_maze_tight.json"
scenarios = [Scenario(dRRT_star, SCENE_PATH, {"prm_num_landmarks": 200, "num_expands": 40}),
Scenario(dRRT_star, SCENE_PATH, {"prm_num_landmarks": 2000}),
Scenario(dRRT_star, SCENE_PATH, repetitions=5),
Scenario(dRRT_star, SCENE_PATH, {"prm_num_landmarks": 100}, 30, 20)]
run_scenarios(scenarios, "results_drrt_star.csv")