TemplateEvaluator#

class optimas.evaluators.TemplateEvaluator(sim_template, analysis_func=None, executable=None, sim_files=None, n_procs=None, n_gpus=None, precedent=None, extra_args=None, env_script=None, env_mpi=None, timeout=None, stdout=None, stderr=None)#

Evaluator class for executing a template script.

Parameters:
sim_templatestr

Path to the simulation template file.

analysis_funcCallable, optional

Function that will analyze the simulation output to obtain the value of the objective(s) and other analyzed parameters. This parameter is only optional if the TemplateEvaluator is included in a ChainEvaluator. In this case, at least one of the chained evaluators should have an analysis function.

executablestr, optional.

Path to the executable that will run the simulation. Only needed if the simulation template is not a Python script.

sim_fileslist of str, optional.

List of files that are needed to carry out the simulation and that will be copied to the simulation directory.

n_procsint, optional

The number of processes that will be used for each evaluation. By default, n_procs=1 if n_gpus is not given. Otherwise, the default behavior is to match the number of processes to the number of GPUs, i.e., n_procs=n_gpus.

n_gpusint, optional

The number of GPUs that will be made available for each evaluation. By default, 0.

precedentstr, optional

Any string that should directly precede the executable. By default, if precedent is not specified and sim_template is a Python file, the precedent will be set to sys.executable, which is the absolute path of the executable binary for the Python interpreter.

extra_argsstr, optional

Additional command line arguments to supply to MPI runner.

env_scriptstr, optional

The full path of a shell script to set up the environment for the launched simulation. This is useful when the simulation needs to run in a different environment than optimas. The script should start with a shebang.

env_mpistr, optional

If the env_script loads an MPI different than the one in the optimas environment, indicate it here. Possible values are “mpich”, “openmpi”, “aprun”, “srun”, “jsrun”, “msmpi”.

timeoutfloat, optional

Time in seconds until the evaluation is forcibly terminated. By default None (i.e., no timeout).

stdoutstr, optional

A standard output filename.

stderrstr, optional

A standard error filename.

Methods

get_libe_specs()

Get the libE_specs for libEnsemble.

get_run_params()

Return run parameters for this evaluator.

get_sim_specs(varying_parameters, ...)

Get the sim_specs for libEnsemble.

initialize()

Initialize the evaluator.

Attributes

app_name

Name of the libEnsemble app that executes the evaluation.