Commit 8a00dbb0 authored by Daniel Lehmberg's avatar Daniel Lehmberg
Browse files

Merge commit '94eb3fbd'

parents eb78c5ff 94eb3fbd
Pipeline #87640 passed with stages
in 101 minutes and 10 seconds
# Contributing
It is highly recommended to contribute (report bugs, code, ideas, etc.) in the original repository. If you want to update the suq controller with the current master run the following git command from Vadere's root source code path:
......@@ -34,7 +33,7 @@ set in the environment. A query can simulate VADERE for multiple scenario settin
## Getting started
Either install as a Pyhton package or run the source code directly. Either way it is recommended to use Python>=3.6
Either install as a Python package or run the source code directly. Either way it is recommended to use Python>=3.6
### Using the code
......
......@@ -101,6 +101,8 @@ def njobs_check_and_set(njobs, ntasks):
f"Setting to njobs={njobs}.")
return njobs
return njobs
def str_timestamp():
return datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
......
......@@ -25,23 +25,25 @@ run_local = True
# Example where the values of 'speedDistributionMean' are set between 0.1 and 1.5 in 5 equidistant points
if __name__ == "__main__": # main required by Windows to run in parallel
setup = SingleKeyVaryScenario(scenario_path=path2scenario, # -> path to the Vadere .scenario file to vary
key="speedDistributionMean", # -> parameter key to change
values=np.linspace(0.7, 1.5, 3), # -> values to set for the parameter
qoi="density.txt", # -> output file name to collect
model=path2model) # -> path to Vadere console jar file to use for simulation
setup = SingleKeyVaryScenario(scenario_path=path2scenario, # -> path to the Vadere .scenario file to vary
key="speedDistributionMean", # -> parameter key to change
values=np.linspace(0.7, 1.5, 3), # -> values to set for the parameter
qoi="density.txt", # -> output file name to collect
model=path2model) # -> path to Vadere console jar file to use for simulation
if run_local:
par_var, data = setup.run(njobs=1)
else:
par_var, data = setup.remote(njobs=3)
if run_local:
par_var, data = setup.run(njobs=1)
else:
par_var, data = setup.remote(njobs=3)
print("---------------------------------------\n \n")
print("ALL USED PARAMETER:")
print(par_var)
print("COLLECTED DATA:")
print(data)
\ No newline at end of file
print("---------------------------------------\n \n")
print("ALL USED PARAMETER:")
print(par_var)
print("COLLECTED DATA:")
print(data)
\ No newline at end of file
......@@ -17,20 +17,21 @@ run_local = True
par_var = [{"speedDistributionMean": 1.0, "maximumSpeed": 3.0},
{"speedDistributionMean": 1.3, "maximumSpeed": 4.0, "acceleration": 3.0}]
if __name__ == "__main__": # main required by Windows to run in parallel
setup = QuickVaryScenario(scenario_path=path2scenario,
parameter_var=par_var,
qoi="density.txt",
model=path2model)
setup = QuickVaryScenario(scenario_path=path2scenario,
parameter_var=par_var,
qoi="density.txt",
model=path2model)
if run_local:
par_var, data = setup.run(-1) # -1 indicates to use all cores available to parallelize the scenarios
else:
par_var, data = setup.remote(-1)
if run_local:
par_var, data = setup.run(-1) # -1 indicates to use all cores available to parallelize the scenarios
else:
par_var, data = setup.remote(-1)
print("\n \n ---------------------------------------\n \n")
print("ALL USED PARAMETER:")
print(par_var)
print("\n \n ---------------------------------------\n \n")
print("ALL USED PARAMETER:")
print(par_var)
print("COLLECTED DATA:")
print(data)
print("COLLECTED DATA:")
print(data)
......@@ -10,36 +10,38 @@ from tutorial.imports import *
run_local = True
###############################################################################################################
# Usecase: Provide a single Vadere scenario and location to write out the output to.
if __name__ == "__main__": # main required by Windows to run in parallel
###############################################################################################################
# Usecase: Provide a single Vadere scenario and location to write out the output to.
setup = SingleScenarioOutput(path_scenario=path2scenario,
path_output=os.path.join(path2tutorial, "example_output"),
model=path2model,
qoi=None)
setup = SingleScenarioOutput(path_scenario=path2scenario,
path_output=os.path.join(path2tutorial, "example_output"),
model=path2model,
qoi=None)
if run_local:
setup.run() # provides only njobs=1 for single scenario
else:
setup.remote()
if run_local:
setup.run() # provides only njobs=1 for single scenario
else:
setup.remote()
###############################################################################################################
# Usecase: Provide a folder with more than .scenario file and an output folder. All scenarios are simulated, also
# in parallel). Here it is not possible to hand in a quantity of interest, because there is no guarantee that
# all scenarios have the same processors. Because there is only one example scenario file, only this will be
# executed.
###############################################################################################################
# Usecase: Provide a folder with more than .scenario file and an output folder. All scenarios are simulated, also
# in parallel). Here it is not possible to hand in a quantity of interest, because there is no guarantee that
# all scenarios have the same processors. Because there is only one example scenario file, only this will be
# executed.
setup = MultiScenarioOutput(path_scenarios=path2tutorial,
path_output=os.path.join(path2tutorial, "example_multirun_output"),
model=path2model)
if run_local:
res = setup.run(2)
else:
res = setup.remote(2)
setup = MultiScenarioOutput(path_scenarios=path2tutorial,
path_output=os.path.join(path2tutorial, "example_multirun_output"),
model=path2model)
if run_local:
res = setup.run(2)
else:
res = setup.remote(2)
......
......@@ -9,28 +9,31 @@ from tutorial.imports import *
run_local = True
###############################################################################################################
# Usecase: FullVarySampling provides the most flexibility to provide a grid. All outputs are saved into the
# suqc_envs folder (either in the "[SRC_PATH]/suqc/suqc_envs" code or in "[HOME]/suqc_envs", depending on
# whether installed package or src is used directly.
# EnvironmentManager handles the "environment" (contains all vadere output and basis sceanrio). It is also suited
# to store the results.
env_man = EnvironmentManager.create_environment("test_remote", basis_scenario=path2scenario, replace=True)
if __name__ == "__main__": # main required by Windows to run in parallel
# There are a few different sampling methods implemented. The abstract class ParameterVariation also makes it easy
# to implement new Sampling methods.
par_var = FullGridSampling(grid={"speedDistributionMean": np.array([1., 1.2])})
###############################################################################################################
# Usecase: FullVarySampling provides the most flexibility to provide a grid. All outputs are saved into the
# suqc_envs folder (either in the "[SRC_PATH]/suqc/suqc_envs" code or in "[HOME]/suqc_envs", depending on
# whether installed package or src is used directly.
# Not documented here: postchanges, which allow to alter parameters of the scenario that should not be included in
# sampling. For example, changing the random seed, etc.
# EnvironmentManager handles the "environment" (contains all vadere output and basis sceanrio). It is also suited
# to store the results.
env_man = EnvironmentManager.create_environment("test_remote", basis_scenario=path2scenario, replace=True)
setup = FullVaryScenario(env_man=env_man, par_var=par_var, qoi="density.txt", model="vadere0_7rc.jar", njobs=1)
# There are a few different sampling methods implemented. The abstract class ParameterVariation also makes it easy
# to implement new Sampling methods.
par_var = FullGridSampling(grid={"speedDistributionMean": np.array([1., 1.2])})
if run_local:
par_lookup, data = setup.run(2)
else:
par_lookup, data = setup.remote(2)
# Not documented here: postchanges, which allow to alter parameters of the scenario that should not be included in
# sampling. For example, changing the random seed, etc.
print(par_lookup)
print(data)
setup = FullVaryScenario(env_man=env_man, par_var=par_var, qoi="density.txt", model="vadere0_7rc.jar", njobs=1)
if run_local:
par_lookup, data = setup.run(2)
else:
par_lookup, data = setup.remote(2)
print(par_lookup)
print(data)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment