``optimizer`` ===================================== .. py:module:: optimeed.optimize.optimizer Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: optimeed.optimize.optimizer.OptimizerSettings optimeed.optimize.optimizer._Evaluator optimeed.optimize.optimizer._ArrayEvaluator Functions ~~~~~~~~~ .. autoapisummary:: optimeed.optimize.optimizer.run_optimization Attributes ~~~~~~~~~~ .. autoapisummary:: optimeed.optimize.optimizer.default .. py:data:: default .. py:class:: OptimizerSettings(theDevice, theObjectives, theConstraints, theOptimizationVariables, theOptimizationAlgorithm=None, theMathsToPhysics=None, theCharacterization=None) Bases: :py:obj:`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. .. py:method:: get_additional_attributes_to_save() Return list of attributes corresponding to object, whose type cannot be determined statically (e.g. topology change) .. py:method:: get_additional_attributes_to_save_list() Same behavior as get_additional_attributes_to_save, but where the attributes contains list of unknown items .. py:method:: get_device() .. py:method:: get_M2P() .. py:method:: get_charac() .. py:method:: get_optivariables() .. py:method:: get_objectives() .. py:method:: get_constraints() .. py:method:: get_optialgorithm() .. py:class:: _Evaluator(optimization_parameters: OptimizerSettings) 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) .. py:method:: start() .. py:method:: evaluate(x) 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. :param x: Input mathematical vector from optimization algorithm :return: dictionary, containing objective values (list of scalar), constraint values (list of scalar), and other info (motor, time) .. py:method:: reevaluate_solutions(x_solutions) .. py:class:: _ArrayEvaluator(optimization_parameters: OptimizerSettings) Bases: :py:obj:`_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. .. py:method:: evaluate(list_of_x) 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. :param x: Input mathematical vector from optimization algorithm :return: dictionary, containing objective values (list of scalar), constraint values (list of scalar), and other info (motor, time) .. py:method:: reevaluate_solutions(x_solutions) .. py:function:: run_optimization(optimizer_settings: OptimizerSettings, opti_historic, max_opti_time_sec=10, return_x_solutions=False, array_evaluator=False, initialVectorGuess=None) Perform the optimization. :param optimizer_settings: :class:`OptimizerSettings` containing all information in models, objectives and optimization variable :param opti_historic: OptiHistoric to log evaluations and results :param max_opti_time_sec: Maximum optimization time (default stopping criterion, unless modified in algorithm) :param return_x_solutions: If True, returns raw parameters in reults :param array_evaluator: If True, evaluate each generation at once using numpy array. Use it only with care, as it dismisses some features (expert mode) :return: list of the best optimized devices, convergence information and [if return_x_solutions=True] best solutions