Package core
Class OTM
- java.lang.Object
-
- core.OTM
-
public class OTM extends Object
Public API. The methods in the API are of three types. Basic scenario loading and running methods belong to the OTM class. Methods for querying and modifying a scenario belong to api.Scenario. Methods for requesting outputs and calculating different metrics are in core.Output.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
advance(float duration)
Advance the simulation in time.float
get_current_time()
Current simulation time in seconds.static String
get_version()
Git hash for the current build.void
initialize(float start_time)
Validate and initialize all components of the scenario.void
initialize(float start_time, String output_requests_file, String prefix, String output_folder, boolean validate_post_init)
Validate and initialize all components of the scenario.static OTM
load_test(String testname)
Load a scenario from the standard tests.Output
output()
Get the output objectvoid
plot_outputs(String out_folder)
Create standard plots for all outputs and write them (as png files) to the output folder.static void
plot_outputs(Set<AbstractOutput> outputs, String out_folder)
Create standard plots for given outputs and write them (as png files) to the output folder.void
run(float start_time, float duration)
Run the simulation.void
run(String prefix, String output_requests_file, String output_folder, float start_time, float duration, boolean validate_post_init)
Run the simulation.void
save(String file)
Save the scenario to a file.Scenario
scenario()
Get the scenario objectstatic void
set_random_seed(long seed)
Set the seed for the simulator's random number generator.void
terminate()
Complete the simulation by closing output files.
-
-
-
Constructor Detail
-
OTM
public OTM(String configfile, boolean validate_pre_init) throws error.OTMException
Constructor.- Parameters:
configfile
- Configuration file.validate_pre_init
- Validate- Throws:
error.OTMException
- Undocumented
-
-
Method Detail
-
load_test
public static OTM load_test(String testname) throws error.OTMException
Load a scenario from the standard tests.- Throws:
error.OTMException
-
output
public Output output()
Get the output object
-
scenario
public Scenario scenario()
Get the scenario object
-
save
public void save(String file)
Save the scenario to a file.
-
run
public void run(String prefix, String output_requests_file, String output_folder, float start_time, float duration, boolean validate_post_init) throws error.OTMException
Run the simulation.- Parameters:
prefix
- Prefix for the output files (used if output_folder is not null).output_requests_file
- XML file with output requests.output_folder
- Folder for the output. If null, then keep output in memory (needed to run plotting functions).start_time
- Initial time in seconds.duration
- Duration of the simulation in seconds.validate_post_init
- If true, runs validations that can only happen once the model is specified.- Throws:
error.OTMException
- Undocumented
-
run
public void run(float start_time, float duration) throws error.OTMException
Run the simulation.- Parameters:
start_time
- Initial time in seconds.duration
- Duration of the simulation in seconds.- Throws:
error.OTMException
- Undocumented
-
initialize
public void initialize(float start_time, String output_requests_file, String prefix, String output_folder, boolean validate_post_init) throws error.OTMException
Validate and initialize all components of the scenario.- Parameters:
start_time
- Initial time in seconds.output_requests_file
- Absolute location and name of file with output requests.prefix
- Prefix for the output.output_folder
- Folder for the output.- Throws:
error.OTMException
- Undocumented
-
initialize
public void initialize(float start_time) throws error.OTMException
Validate and initialize all components of the scenario. This function must be called prior to calling "advance".- Parameters:
start_time
- Initial time in seconds.- Throws:
error.OTMException
- Undocumented
-
advance
public void advance(float duration) throws error.OTMException
Advance the simulation in time.- Parameters:
duration
- Seconds to advance.- Throws:
error.OTMException
- Undocumented
-
terminate
public void terminate()
Complete the simulation by closing output files. This should be called explicitly if the simulation is executed with calls to "advance". The "run" method already calls it internally.
-
plot_outputs
public void plot_outputs(String out_folder) throws error.OTMException
Create standard plots for all outputs and write them (as png files) to the output folder.- Parameters:
out_folder
- Output folder- Throws:
error.OTMException
- Undocumented.
-
plot_outputs
public static void plot_outputs(Set<AbstractOutput> outputs, String out_folder) throws error.OTMException
Create standard plots for given outputs and write them (as png files) to the output folder.- Parameters:
out_folder
- Output folder- Throws:
error.OTMException
- Undocumented.
-
get_current_time
public float get_current_time()
Current simulation time in seconds.- Returns:
- Current simulation time in seconds.
-
get_version
public static String get_version()
Git hash for the current build.- Returns:
- Git hash for the current build.
-
set_random_seed
public static void set_random_seed(long seed)
Set the seed for the simulator's random number generator.- Parameters:
seed
- Any number
-
-