macop.solutions.base

Abstract solution class

Classes

Solution(data, size)

Base abstract solution class structure

class macop.solutions.base.Solution(data, size)[source]

Base abstract solution class structure

  • stores solution data representation into data attribute

  • get size (shape) of specific data representation

  • stores the score of the solution

clone()[source]

Clone the current solution and its data, but without keeping evaluated _score

Returns

{Solution} – clone of current solution

evaluate(evaluator)[source]

Evaluate solution using specific evaluator

Parameters

_evaluator – {function} – specific function which computes fitness of solution

Returns

{float} – fitness score value

fitness()[source]

Returns fitness score

Returns

{float} – fitness score value

isValid(validator)[source]

Use of custom method which validates if solution is valid or not

Parameters

validator – {function} – specific function which validates or not a solution

Returns

{bool} – True is solution is valid

static random(size, validator=None)[source]

Initialize solution using random data with validator

Parameters
  • size – {int} – expected solution size to generate

  • validator – {function} – specific function which validates or not a solution (if None, not validation is applied)

Returns

{Solution} – generated solution