optimizer

Module Contents

Classes

Functions

Attributes

default
class OptimizerSettings(theDevice, theObjectives, theConstraints, theOptimizationVariables, theOptimizationAlgorithm=None, theMathsToPhysics=None, theCharacterization=None)[source]

Bases: optimeed.core.SaveableObject

Abstract class for dynamically type-hinted objects. This class is to solve the special case where the exact type of an attribute is not known before runtime, yet has to be saved.

get_additional_attributes_to_save()[source]

Return list of attributes corresponding to object, whose type cannot be determined statically (e.g. topology change)

get_additional_attributes_to_save_list()[source]

Same behavior as get_additional_attributes_to_save, but where the attributes contains list of unknown items

get_device()[source]
get_M2P()[source]
get_charac()[source]
get_optivariables()[source]
get_objectives()[source]
get_constraints()[source]
get_optialgorithm()[source]
class _Evaluator(optimization_parameters: OptimizerSettings)[source]

This is the main class that serves as evaluator. This class is NOT process safe (i.e., copy of it might be generated upon process call)

start()[source]
evaluate(x)[source]

Evaluates the performances of device associated to entrance vector x. Outputs the objective function and the constraints, and other data used in optiHistoric.

This function is NOT process safe: “self.” is a FORK in multiprocessing algorithms. It means that the motor originally contained in self. is modified only in the fork, and only gathered by reaching the end of the fork.

Parameters:x – Input mathematical vector from optimization algorithm
Returns:dictionary, containing objective values (list of scalar), constraint values (list of scalar), and other info (motor, time)
reevaluate_solutions(x_solutions)[source]
class _ArrayEvaluator(optimization_parameters: OptimizerSettings)[source]

Bases: _Evaluator

Same as _evaluator, using array as inputs. Allows to evaluate all generation at once, in case of numpy array computations. Drawbacks: devices can not be visualized and saved. Use this with care.

evaluate(list_of_x)[source]

Evaluates the performances of device associated to entrance vector x. Outputs the objective function and the constraints, and other data used in optiHistoric.

This function is NOT process safe: “self.” is a FORK in multiprocessing algorithms. It means that the motor originally contained in self. is modified only in the fork, and only gathered by reaching the end of the fork.

Parameters:x – Input mathematical vector from optimization algorithm
Returns:dictionary, containing objective values (list of scalar), constraint values (list of scalar), and other info (motor, time)
reevaluate_solutions(x_solutions)[source]
run_optimization(optimizer_settings: OptimizerSettings, opti_historic, max_opti_time_sec=10, return_x_solutions=False, array_evaluator=False, initialVectorGuess=None)[source]

Perform the optimization.

Parameters:
  • optimizer_settingsOptimizerSettings containing all information in models, objectives and optimization variable
  • opti_historic – OptiHistoric to log evaluations and results
  • max_opti_time_sec – Maximum optimization time (default stopping criterion, unless modified in algorithm)
  • return_x_solutions – If True, returns raw parameters in reults
  • array_evaluator – If True, evaluate each generation at once using numpy array. Use it only with care, as it dismisses some features (expert mode)
Returns:

list of the best optimized devices, convergence information and [if return_x_solutions=True] best solutions