Optimizers

Optimizer Base Module

class l2l.optimizers.optimizer.Optimizer(traj, optimizee_create_individual, optimizee_fitness_weights, optimizee_bounding_func, parameters)[source]

This is the base class for the Optimizers i.e. the outer loop algorithms. These algorithms generate parameters, give them to the inner loop to be evaluated, and with the resulting fitness modify the parameters in some way.

Parameters:
  • traj (Trajectory) – Use this trajectory to store the parameters of the specific runs. The parameters should be initialized based on the values in :param parameters:
  • optimizee_create_individual – A function which when called returns one instance of parameter (or “individual”)
  • optimizee_fitness_weights – The weights which should be multiplied with the fitness returned from the Optimizee – one for each element of the fitness (fitness can be multi-dimensional). If some element is negative, the Optimizer minimizes that element of fitness instead of maximizing. By default, the Optimizer maximizes all fitness dimensions.
  • parameters – A named tuple containing the parameters for the Optimizer class
g = None

The current generation number

eval_pop = None

The population (i.e. list of individuals) to be evaluated at the next iteration

post_process(traj, fitnesses_results)[source]

This is the key function of this class. Given a set of fitnesses_results, and the traj, it uses the fitness to decide on the next set of parameters to be evaluated. Then it fills the Optimizer.eval_pop with the list of parameters it wants evaluated at the next simulation cycle, increments Optimizer.g and calls _expand_trajectory()

Parameters:
  • traj (Trajectory) – The trajectory that contains the parameters and the individual that we want to simulate. The individual is accessible using traj.individual and parameter e.g. param1 is accessible using traj.param1
  • fitnesses_results (list) – This is a list of fitness results that contain tuples run index and the fitness. It is of the form [(run_idx, run), …]
end(traj)[source]

Run any code required to clean-up, print final individuals etc.

Parameters:traj (Trajectory) – The trajectory that contains the parameters and the individual that we want to simulate. The individual is accessible using traj.individual and parameter e.g. param1 is accessible using traj.param1
_expand_trajectory(traj)[source]

Add as many explored runs as individuals that need to be evaluated. Furthermore, add the individuals as explored parameters.

Parameters:traj (Trajectory) – The trajectory that contains the parameters and the individual that we want to simulate. The individual is accessible using traj.individual and parameter e.g. param1 is accessible using traj.param1
Returns: