# macop.solutions.base — macop v1.0.5 documentation

# macop.solutions.base

Abstract solution class

Classes

`Solution`(data, size) | Base abstract solution class structure

class `macop.solutions.base.``Solution`(data, size)

  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`()

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

    Returns

      {Solution} – clone of current solution

  `evaluate`(evaluator)

    Evaluate solution using specific evaluator

    Parameters

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

    Returns

      {float} – fitness score value

  `fitness`()

    Returns fitness score

    Returns

      {float} – fitness score value

  `isValid`(validator)

    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)

    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