platypus.extensions module
- class AdaptiveTimeContinuationExtension(window_size=100, max_window_size=1000, population_ratio=4.0, min_population_size=10, max_population_size=10000, mutator=<platypus.operators.UM object>)
Bases:
FixedFrequencyExtensionExtends an algorithm to enable adaptive time continuation.
Adaptive time continuation performs two key functions:
First, it scales the population based on the size of the archive. The idea being a larger archive, with more non-dominated solutions, requires a larger population to cover the search space.
Second, it periodically introduces extra randomness or diversity into the population. This helps avoid or escape local optima.
Parameters
- window_sizeint
The number of iterations between calls to
check().- max_window_sizeint
The maximum number of iterations before a restart is required.
- population_ratofloat
The ratio between the desired population size and archive size, used to scale the population size after each restart.
- min_population_sizeint
The minimum allowed population size.
- max_population_sizeint
The maximum allowed population size.
- mutatorVariator
The mutation operator applied during restarts to introduce additional randomness or diversity into the population. Must have an arity of
1.
- check(algorithm)
Checks if a restart is required.
- do_action(algorithm)
Performs the action defined by this extension.
- restart(algorithm)
Performs the restart procedure.
- class EpsilonProgressContinuationExtension(window_size=100, max_window_size=1000, population_ratio=4.0, min_population_size=10, max_population_size=10000, mutator=<platypus.operators.UM object>)
Bases:
AdaptiveTimeContinuationExtensionExtends an algorithm to enable epsilon-progress continuation.
Epsilon-progress continuation extends adaptive time continuation to also track the number of improvements made in the
EpsilonBoxArchive. A restart is triggered if no improvements were recorded, as that often occurs when the algorithm as converged to a local optima.Parameters
- window_sizeint
The number of iterations between calls to
check().- max_window_sizeint
The maximum number of iterations before a restart is required.
- population_ratofloat
The ratio between the desired population size and archive size, used to scale the population size after each restart.
- min_population_sizeint
The minimum allowed population size.
- max_population_sizeint
The maximum allowed population size.
- mutatorVariator
The mutation operator applied during restarts to introduce additional randomness or diversity into the population. Must have an arity of
1.
- check(algorithm)
Checks if a restart is required.
- restart(algorithm)
Performs the restart procedure.
- class Extension
Bases:
objectExtends the functionality of an algorithm.
- end_run(algorithm)
Executes at the end of a run.
This can be used to perform any finalization or post-processing. However, note that the
runmethod can be called multiple times.Parameters
- algorithmAlgorithm
The algorithm being run.
- post_step(algorithm)
Executes after the
stepmethod.Parameters
- algorithmAlgorithm
The algorithm being run.
- class FixedFrequencyExtension(frequency=10000, by_nfe=True)
Bases:
ExtensionExtension that performs an action at a fixed frequency.
Parameters
- frequencyint
The frequency the action occurs.
- by_nfebool
If
True, the frequency is given in number of function evaluations. IfFalse, the frequency is given in the number of iterations.
- abstract do_action(algorithm)
Performs the action defined by this extension.
- class LoggingExtension(frequency=10000, by_nfe=True)
Bases:
FixedFrequencyExtensionLogs a run’s progress.
- do_action(algorithm)
Performs the action defined by this extension.
- class SaveResultsExtension(filename_pattern, frequency=10000, by_nfe=True)
Bases:
FixedFrequencyExtensionSaves intermediate results to a JSON file.
The filename pattern can reference the following variables: *
{algorithm}- The algorithm name *{problem}- The problem name *{nfe}- The number of function evaluations *{nvars}- The number of variables in the problem *{nobjs}- The number of objectives in the problem *{nconstrs}- The number of constraints in the problemParameters
- filename_pattern: str
The filename pattern.
- frequencyint
The frequency the action occurs.
- by_nfebool
If
True, the frequency is given in number of function evaluations. IfFalse, the frequency is given in the number of iterations.
- do_action(algorithm)
Performs the action defined by this extension.