``multiObjective_GA`` ============================================================ .. py:module:: optimeed.optimize.optiAlgorithms.multiObjective_GA Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: optimeed.optimize.optiAlgorithms.multiObjective_GA.MyProblem optimeed.optimize.optiAlgorithms.multiObjective_GA.MyGenerator optimeed.optimize.optiAlgorithms.multiObjective_GA.MaxTimeTerminationCondition optimeed.optimize.optiAlgorithms.multiObjective_GA.ManualStopFromFileTermination optimeed.optimize.optiAlgorithms.multiObjective_GA.ConvergenceTerminationCondition optimeed.optimize.optiAlgorithms.multiObjective_GA.SeveralTerminationCondition optimeed.optimize.optiAlgorithms.multiObjective_GA.MyMapEvaluator optimeed.optimize.optiAlgorithms.multiObjective_GA.MyMultiprocessEvaluator optimeed.optimize.optiAlgorithms.multiObjective_GA.MultiObjective_GA .. py:class:: MyProblem(theOptimizationVariables, nbr_objectives, nbr_constraints, evaluationFunction) Bases: :py:obj:`optimeed.optimize.optiAlgorithms.platypus.core.Problem` Automatically sets the optimization problem .. py:method:: evaluate(solution) Evaluates the problem. By default, this method calls the function passed to the constructor. Alternatively, a problem can subclass and override this method. When overriding, this method is responsible for updating the objectives and constraints stored in the solution. Parameters ---------- solution: Solution The solution to evaluate. .. py:class:: MyGenerator(initialVectorGuess) Bases: :py:obj:`optimeed.optimize.optiAlgorithms.platypus.Generator` Population generator to insert initial individual .. py:method:: generate(problem) .. py:class:: MaxTimeTerminationCondition(maxTime) Bases: :py:obj:`optimeed.optimize.optiAlgorithms.platypus.core.TerminationCondition` Abstract class for defining termination conditions. .. py:method:: initialize(algorithm) Initializes this termination condition. This method is used to collect any initial state, such as the current NFE or current time, needed for calculating the termination criteria. Parameters ---------- algorithm : Algorithm The algorithm being run. .. py:method:: shouldTerminate(algorithm) Checks if the algorithm should terminate. Check the termination condition, returning True if the termination condition is satisfied; False otherwise. This method is called after each iteration of the algorithm. Parameters ---------- algorithm : Algorithm The algorithm being run. .. py:class:: ManualStopFromFileTermination(filename) Bases: :py:obj:`optimeed.optimize.optiAlgorithms.platypus.core.TerminationCondition` Abstract class for defining termination conditions. .. py:method:: shouldTerminate(algorithm) Checks if the algorithm should terminate. Check the termination condition, returning True if the termination condition is satisfied; False otherwise. This method is called after each iteration of the algorithm. Parameters ---------- algorithm : Algorithm The algorithm being run. .. py:class:: ConvergenceTerminationCondition(minrelchange_percent=0.1, nb_generation=15) Bases: :py:obj:`optimeed.optimize.optiAlgorithms.platypus.core.TerminationCondition` Abstract class for defining termination conditions. .. py:method:: initialize(algorithm) Initializes this termination condition. This method is used to collect any initial state, such as the current NFE or current time, needed for calculating the termination criteria. Parameters ---------- algorithm : Algorithm The algorithm being run. .. py:method:: shouldTerminate(algorithm) Checks if the algorithm should terminate. Check the termination condition, returning True if the termination condition is satisfied; False otherwise. This method is called after each iteration of the algorithm. Parameters ---------- algorithm : Algorithm The algorithm being run. .. py:class:: SeveralTerminationCondition Bases: :py:obj:`optimeed.optimize.optiAlgorithms.platypus.core.TerminationCondition` Abstract class for defining termination conditions. .. py:method:: initialize(algorithm) Initializes this termination condition. This method is used to collect any initial state, such as the current NFE or current time, needed for calculating the termination criteria. Parameters ---------- algorithm : Algorithm The algorithm being run. .. py:method:: add(theTerminationCondition) .. py:method:: shouldTerminate(algorithm) Checks if the algorithm should terminate. Check the termination condition, returning True if the termination condition is satisfied; False otherwise. This method is called after each iteration of the algorithm. Parameters ---------- algorithm : Algorithm The algorithm being run. .. py:class:: MyMapEvaluator(callback_on_evaluation) Bases: :py:obj:`optimeed.optimize.optiAlgorithms.platypus.evaluator.Evaluator` .. py:method:: evaluate_all(jobs, **kwargs) .. py:class:: MyMultiprocessEvaluator(callback_on_evaluation, numberOfCores) Bases: :py:obj:`optimeed.optimize.optiAlgorithms.platypus.evaluator.Evaluator` .. py:method:: my_callback(output) .. py:method:: evaluate_all(jobs, **kwargs) .. py:method:: close() .. py:class:: MultiObjective_GA(theGenerator=MyGenerator) Bases: :py:obj:`optimeed.optimize.optiAlgorithms.algorithmInterface.AlgorithmInterface`, :py:obj:`optimeed.core.Option_class` Based on `Platypus Library `_. Workflow: Define what to optimize and which function to call with a :class:`Problem` Define the initial population with a :class:`Generator` Define the algorithm. As options, define how to evaluate the elements with a :class:`Evaluator`, i.e., for multiprocessing. Define what is the termination condition of the algorithm with :class:`TerminationCondition`. Here, termination condition is a maximum time. .. py:attribute:: DIVISION_OUTER :value: 0 .. py:attribute:: OPTI_ALGORITHM :value: 1 .. py:attribute:: NUMBER_OF_CORES :value: 2 .. py:attribute:: KWARGS_ALGO :value: 3 .. py:method:: initialize(initialVectorGuess, listOfOptimizationVariables) This function is called just before running optimization algorithm. .. py:method:: compute() Launch the optimization :return: vector of optimal variables .. py:method:: set_evaluationFunction(evaluationFunction, callback_on_evaluation, numberOfObjectives, numberOfConstraints, array_evaluator) Set the evaluation function and all the necessary callbacks :param evaluationFunction: check :meth:`~optimeed.optimize.optimizer.evaluateObjectiveAndConstraints` :param callback_on_evaluation: check :meth:`~optimeed.optimize.optimizer.callback_on_evaluation`. Call this function after performing the evaluation of the individuals :param numberOfObjectives: int, number of objectives :param numberOfConstraints: int, number of constraints :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) .. py:method:: set_maxtime(maxTime) Set maximum optimization time (in seconds) .. py:method:: __str__() Return str(self). .. py:method:: get_convergence() This function is called just before compute. Because the convergence is contained in opti algorithm, it must be created now. .. py:method:: add_terminationCondition(theTerminationCondition) .. py:method:: reset()