optimize¶
Subpackages¶
Package Contents¶
Classes¶
Functions¶
-
class
Characterization[source]¶ Bases:
optimeed.optimize.characterization.interfaceCharacterization.InterfaceCharacterizationInterface for the evaluation of a device
-
class
InterfaceMathsToPhysics[source]¶ Interface to transform output from the optimizer to meaningful variables of the device
-
class
MathsToPhysics[source]¶ Bases:
optimeed.optimize.mathsToPhysics.interfaceMathsToPhysics.InterfaceMathsToPhysicsDummy yet powerful example of maths to physics. The optimization variables are directly injected to the device
-
fromMathsToPhys(xVector, theDevice, theOptimizationVariables)[source]¶ Transforms an input vector coming from the optimization (e.g. [0.23, 4, False]) to “meaningful” variable (ex: length, number of poles, flag).
Parameters: - xVector – List of optimization variables from the optimizer
- theDevice –
InterfaceDevice - opti_variables – list of
OptimizationVariable
-
-
class
ArrayMathsToPhysics[source]¶ Bases:
optimeed.optimize.mathsToPhysics.interfaceMathsToPhysics.InterfaceMathsToPhysicsEvaluate array M2P. Only use it if specifically needed
-
fromMathsToPhys(list_of_xvector, theDevice, theOptimizationVariables)[source]¶ Transforms an input vector coming from the optimization (e.g. [0.23, 4, False]) to “meaningful” variable (ex: length, number of poles, flag).
Parameters: - xVector – List of optimization variables from the optimizer
- theDevice –
InterfaceDevice - opti_variables – list of
OptimizationVariable
-
-
class
FastObjCons(constraintEquation, name=None)[source]¶ Bases:
optimeed.optimize.objAndCons.interfaceObjCons.InterfaceObjConsConvenience class to create an objective or a constraint very fast.
-
class
InterfaceObjCons[source]¶ Interface class for objectives and constraints. The objective is to MINIMIZE and the constraint has to respect VALUE <= 0
-
class
MultiObjective_GA(theGenerator=MyGenerator)[source]¶ Bases:
optimeed.optimize.optiAlgorithms.algorithmInterface.AlgorithmInterface,optimeed.core.Option_classBased on Platypus Library. Workflow: Define what to optimize and which function to call with a
ProblemDefine the initial population with aGeneratorDefine the algorithm. As options, define how to evaluate the elements with aEvaluator, i.e., for multiprocessing. Define what is the termination condition of the algorithm withTerminationCondition. Here, termination condition is a maximum time.-
initialize(initialVectorGuess, listOfOptimizationVariables)[source]¶ This function is called just before running optimization algorithm.
-
set_evaluationFunction(evaluationFunction, callback_on_evaluation, numberOfObjectives, numberOfConstraints, array_evaluator)[source]¶ Set the evaluation function and all the necessary callbacks
Parameters: - evaluationFunction – check
evaluateObjectiveAndConstraints() - callback_on_evaluation – check
callback_on_evaluation(). Call this function after performing the evaluation of the individuals - numberOfObjectives – int, number of objectives
- numberOfConstraints – int, number of constraints
- array_evaluator – If True, evaluate each generation at once using numpy array. Use it only with care, as it dismisses some features (expert mode)
- evaluationFunction – check
-
-
class
Monobjective_PSO[source]¶ Bases:
optimeed.optimize.optiAlgorithms.algorithmInterface.AlgorithmInterface,optimeed.core.Option_classInterface for the optimization algorithm
-
initialize(initialVectorGuess, listOfOptimizationVariables)[source]¶ This function is called once parameters can’t be changed anymore, before “get_convergence”.
Parameters: - initialVectorGuess – list of variables that describe the initial individual
- listOfOptimizationVariables – list of
optimeed.optimize.optiVariable.OptimizationVariable
Returns:
-
set_evaluationFunction(evaluationFunction, callback_on_evaluate, numberOfObjectives, _numberOfConstraints, array_evaluator)[source]¶ Set the evaluation function and all the necessary callbacks
Parameters: - evaluationFunction – check
evaluateObjectiveAndConstraints() - callback_on_evaluation – check
callback_on_evaluation(). Call this function after performing the evaluation of the individuals - numberOfObjectives – int, number of objectives
- numberOfConstraints – int, number of constraints
- array_evaluator – If True, evaluate each generation at once using numpy array. Use it only with care, as it dismisses some features (expert mode)
- evaluationFunction – check
-
get_convergence()[source]¶ Get the convergence of the optimization
Returns: InterfaceConvergence
-
-
class
Real_OptimizationVariable(attributeName, val_min, val_max)[source]¶ Bases:
OptimizationVariableReal (continuous) optimization variable. Most used type
-
class
Binary_OptimizationVariable(attributeName)[source]¶ Bases:
OptimizationVariableBoolean (True/False) optimization variable.
-
class
Integer_OptimizationVariable(attributeName, val_min, val_max)[source]¶ Bases:
OptimizationVariableInteger variable, in [min_value, max_value]
-
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_settings –
OptimizerSettingscontaining 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
- optimizer_settings –
-
class
OptimizerSettings(theDevice, theObjectives, theConstraints, theOptimizationVariables, theOptimizationAlgorithm=None, theMathsToPhysics=None, theCharacterization=None)[source]¶ Bases:
optimeed.core.SaveableObjectAbstract 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)
-
-
class
OptiHistoric(optiname='opti', autosave_timer=60 * 5, autosave=True, create_new_directory=True, performance_datastruct=True, folder=getPath_workspace())[source]¶ Contains all the points that have been evaluated
-
log_after_evaluation(returned_values: dict)[source]¶ Save the output of evaluate to optiHistoric. This function should be called by the optimizer IN a process safe context.
-
get_convergence()[source]¶ Returns: convergence InterfaceConvergence
-
-
class
OptiHistoric_Fast(optiname='opti')[source]¶ Almost empty struct, just enough to display the graphs. Used to speed up optimization