Simulation control

Trajectory

class l2l.utils.trajectory.Trajectory(**keyword_args)[source]

Bases: object

The trajectory is a class which holds the history of the parameter space exploration, defines the current parameters to be explored and holds the results from each execution. Based on the pypet trajectory concept: https://github.com/SmokinCaterpillar/pypet

f_add_parameter_group(name, comment='')[source]

Adds a new parameter group :param name: name of the new parameter group :param comment: ignored for the moment. Kept to match pypet interface.

f_add_parameter_to_group(group_name, key, val)[source]

Adds a parameter to an already existing group.

Parameters
  • group_name – Name of the group where the parameter should be added

  • key – Name of the parameter to be added

  • val – Value of the parameter

Throws an exception if the group does not exist

f_add_result(key, val, comment='')[source]

Adds a result to the trajectory :param key: it identifies either a generation params result group or another result :param val: The value to be added to the results TODO: verify where is the generation_params call performed

f_add_parameter(key, val, comment='')[source]

Adds a parameter to the trajectory :param key: Name of the parameter :param val: Value of the parameter :param comment

f_add_derived_parameter(key, val, comment='')[source]

Adds a derived parameter to the trajectory. Match the previous pypet interface. :param key: Name of the parameter :param val: Value of the parameter :param comment:

f_expand(build_dict, fail_safe=True)[source]

The expand function takes care of adding a new generation and individuals to the trajectory This is a critical function to allow the addition of a new generation, called by the optimizer from the postprocessing function :param build_dict: The dictionary containing the new generation id and its individuals :param fail_safe: Currently ignored

Individual

class l2l.utils.individual.Individual(generation=0, ind_idx=0, params=[])[source]

Bases: l2l.utils.groups.ParameterGroup

This class represents individuals in the parameter search. It derives from a Parameter group. The main elements which make an individual are the ID of its generation, its individual ID and the params specific for its run.

ParamterGroup

class l2l.utils.groups.ParameterGroup[source]

Bases: object

This class is a Dictionary which can be used to store parameters. It is used to fit the pypet already existing interface with the trajectory

f_add_parameter(key, val, comment='')[source]

Adds parameter with name key and value val. The comment is ignored for the moment but kept for compatibility with the pypet groups :param key: Name of the parameter :param val: Value of the parameter :param comment: Ignores for the moment

Experiment

class l2l.utils.experiment.Experiment(root_dir_path)[source]

Bases: object

prepare_experiment(**kwargs)[source]

Prepare the experiment by creating the environment

Parameters

kwargs

optional dictionary, contains

  • name: str, name of the run, Default: L2L-run

  • trajectory_name: str, name of the trajectory, Default: trajectory

  • log_stdout: bool, if stdout should be sent to logs, Default:False

  • jube_parameter: dict, User specified parameter for jube. See notes section for default jube parameter

  • multiprocessing, bool, enable multiprocessing, Default: False

Returns

traj, trajectory object

Returns

all_jube_params, dict, a dictionary with all parameters for jube given by the user and default ones

Notes
Default JUBE parameters are:
  • scheduler: None,

  • submit_cmd: sbatch,

  • job_file: job.run,

  • nodes: 1,

  • walltime: 01:00:00,

  • ppn: 1,

  • cpu_pp: 1,

  • threads_pp: 4,

  • mail_mode: ALL,

  • err_file: stderr,

  • out_file: stdout,

  • tasks_per_job: 1,

  • exec: python3 + self.paths.simulation_path + “run_files/run_optimizee.py”

  • ready_file: self.paths.root_dir_path + “ready_files/ready_w_”

  • work_path: self.paths.root_dir_path,

  • paths_obj: self.paths

run_experiment(optimizer, optimizee, optimizer_parameters=None, optimizee_parameters=None)[source]

Runs the simulation with all parameter combinations

Optimizee and optimizer object are required as well as their parameters as namedtuples.

Parameters
  • optimizee – optimizee object

  • optimizee_parameters – Namedtuple, optional, parameters of the optimizee

  • optimizer – optimizer object

  • optimizer_parameters – Namedtuple, optional, parameters of the optimizer

end_experiment(optimizer)[source]

Ends the experiment and disables the logging

Parameters

optimizer – optimizer object

Returns

traj, trajectory object

Returns

path, Path object