optimize

Package Contents

class InterfaceCharacterization[source]

Interface for the evaluation of a device

abstract compute(self, theDevice)[source]

Action to perform to characterize (= compute the objective function) of the device.

Parameters

theDevice – the device to characterize

__str__(self)[source]
class Characterization[source]

Bases: optimeed.optimize.characterization.interfaceCharacterization.InterfaceCharacterization

compute(self, theDevice)[source]
class MathsToPhysics[source]

Bases: optimeed.optimize.mathsToPhysics.interfaceMathsToPhysics.InterfaceMathsToPhysics

Dummy yet powerful example of maths to physics. The optimization variables are directly injected to the device

fromMathsToPhys(self, xVector, theDevice, theOptimizationVariables)[source]
fromPhysToMaths(self, theDevice, theOptimizationVariables)[source]
__str__(self)[source]
class InterfaceMathsToPhysics[source]

Interface to transform output from the optimizer to meaningful variables of the device

abstract fromMathsToPhys(self, xVector, theDevice, opti_variables)[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

  • theDeviceInterfaceDevice

  • opti_variables – list of OptimizationVariable

abstract fromPhysToMaths(self, theDevice, opti_variables)[source]

Extracts a mathematical vector from meaningful variable of the Device

Parameters
  • theDeviceInterfaceDevice

  • opti_variables – list of OptimizationVariable

Returns

List of optimization variables

class FastObjCons(constraintEquation, name=None)[source]

Bases: optimeed.optimize.objAndCons.interfaceObjCons.InterfaceObjCons

Convenience class to create an objective or a constraint very fast.

compute(self, theDevice)[source]
get_name(self)[source]
class InterfaceObjCons[source]

Interface class for objectives and constraints. The objective is to MINIMIZE and the constraint has to respect VALUE <= 0

abstract compute(self, theDevice)[source]

Get the value of the objective or the constraint. The objective is to MINIMIZE and the constraint has to respect VALUE <= 0

Parameters

theDevice – Input device that has already been evaluated

Returns

float.

get_name(self)[source]
__str__(self)[source]
class MultiObjective_GA[source]

Bases: optimeed.optimize.optiAlgorithms.algorithmInterface.AlgorithmInterface, optimeed.core.Option_class

Based on Platypus Library. Workflow: Define what to optimize and which function to call with a Problem Define the initial population with a Generator Define the algorithm. As options, define how to evaluate the elements with a Evaluator, i.e., for multiprocessing. Define what is the termination condition of the algorithm with TerminationCondition. Here, termination condition is a maximum time.

DIVISION_OUTER = 0
OPTI_ALGORITHM = 1
NUMBER_OF_CORES = 2
compute(self, initialVectorGuess, listOfOptimizationVariables)[source]
set_evaluationFunction(self, evaluationFunction, callback_on_evaluation, numberOfObjectives, numberOfConstraints)[source]
set_maxtime(self, maxTime)[source]
__str__(self)[source]
get_convergence(self)[source]
class Real_OptimizationVariable(attributeName, val_min, val_max)[source]

Bases: optimeed.optimize.optiVariable.OptimizationVariable

Real (continuous) optimization variable. Most used type

get_min_value(self)[source]
get_max_value(self)[source]
get_PhysToMaths(self, deviceIn)[source]
do_MathsToPhys(self, value, deviceIn)[source]
__str__(self)[source]
class Binary_OptimizationVariable[source]

Bases: optimeed.optimize.optiVariable.OptimizationVariable

Boolean (True/False) optimization variable.

get_PhysToMaths(self, deviceIn)[source]
do_MathsToPhys(self, value, deviceIn)[source]
__str__(self)[source]
class Integer_OptimizationVariable(attributeName, val_min, val_max)[source]

Bases: optimeed.optimize.optiVariable.OptimizationVariable

Integer variable, in [min_value, max_value]

get_min_value(self)[source]
get_max_value(self)[source]
get_PhysToMaths(self, deviceIn)[source]
do_MathsToPhys(self, value, deviceIn)[source]
__str__(self)[source]
class Optimizer[source]

Bases: optimeed.core.options.Option_class

Main optimizing class

DISPLAY_INFO = 1
KWARGS_OPTIHISTO = 2
set_optimizer(self, theDevice, theObjectiveList, theConstraintList, theOptimizationVariables, theOptimizationAlgorithm=default['Algo'], theCharacterization=default['Charac'], theMathsToPhysics=default['M2P'])[source]

Prepare the optimizer for the optimization.

Parameters
Returns

PipeOptimization

run_optimization(self)[source]

Perform the optimization.

Returns

Collection of the best optimized devices

set_max_opti_time(self, max_time_sec)[source]
evaluateObjectiveAndConstraints(self, 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 actually 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. It is not (yet?) possible to access this motor on the main process before the end of the fork. This behaviour could be changed by using pipes or Managers.

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)

callback_on_evaluation(self, returnedValues)[source]

Save the output of evaluateObjectiveAndConstraints to optiHistoric. This function should be called by the optimizer IN a process safe context.

formatInfo(self)[source]