macop.algorithms.Algorithm¶
Abstract Algorithm class used as basic algorithm implementation with some specific initialization
Classes
|
Algorithm class used as basic algorithm |
-
class
macop.algorithms.Algorithm.
Algorithm
(_initalizer, _evaluator, _operators, _policy, _validator, _maximise=True, _parent=None)[source]¶ Algorithm class used as basic algorithm
-
initalizer
¶ {function} – basic function strategy to initialize solution
-
evaluator
¶ {function} – basic function in order to obtained fitness (mono or multiple objectives)
-
operators
¶ {[Operator]} – list of operator to use when launching algorithm
-
policy
¶ {Policy} – Policy class implementation strategy to select operators
-
validator
¶ {function} – basic function to check if solution is valid or not under some constraints
-
maximise
¶ {bool} – specify kind of optimization problem
-
currentSolution
¶ {Solution} – current solution managed for current evaluation
-
bestSolution
¶ {Solution} – best solution found so far during running algorithm
-
callbacks
¶ {[Callback]} – list of Callback class implementation to do some instructions every number of evaluations and load when initializing algorithm
-
parent
¶ {Algorithm} – parent algorithm reference in case of inner Algorithm instance (optional)
-
addCallback
(_callback)[source]¶ Add new callback to algorithm specifying usefull parameters
- Parameters
_callback – {Callback} – specific Callback instance
-
evaluate
(_solution)[source]¶ Evaluate a solution using evaluator passed when intialize algorithm
- Parameters
solution – {Solution} – solution to evaluate
- Returns
fitness score of solution which is not already evaluated or changed
Note
if multi-objective problem this method can be updated using array of evaluator
-
getGlobalEvaluation
()[source]¶ Get the global number of evaluation (if inner algorithm)
- Returns
{int} – current global number of evaluation
-
getGlobalMaxEvaluation
()[source]¶ Get the global max number of evaluation (if inner algorithm)
- Returns
{int} – current global max number of evaluation
-
isBetter
(_solution)[source]¶ Check if solution is better than best found
- Parameters
solution – {Solution} – solution to compare with best one
- Returns
{bool} – True if better
-
run
(_evaluations)[source]¶ Run the specific algorithm following number of evaluations to find optima
-