Beispiel #1
0
class Individual(gp.AExpressionTree):
    """The gp representation (genotype) of the actuator for the control problem."""

    pset = gp.sympy_primitive_set(categories=['algebraic', 'trigonometric', 'exponential'],
                                  arguments=['y_0', 'y_1'])

    def __str__(self):
        """Human readable representation of the individual."""
        return str(sympy.sympify(deap.gp.compile(repr(self), self.pset)))
Beispiel #2
0
class Individual(gp.individual.AExpressionTree):
    """The gp representation (genotype) of the actuator for the control problem."""

    pset = gp.sympy_primitive_set(
        categories=["algebraic", "trigonometric", "exponential", "neg"],
        arguments=["y_0", "y_1", "y_2"],
        constants=["c"],
    )

    def __str__(self):
        """Human readable representation of the individual."""
        return str(sympy.sympify(deap.gp.compile(repr(self), self.pset)))
Beispiel #3
0
from glyph import application
from glyph import assessment
from glyph import gp
from glyph import utils
from toolz import cons

import sys
import os

sys.path.append(os.path.dirname(__file__))
import control_problem

pset = gp.sympy_primitive_set(
    categories=["algebraic", "trigonometric", "exponential"],
    arguments=["y0", "y1"],
    constants=["c"],
)
Individual = gp.Individual(pset=pset, name="Individual")


class AssessmentRunner(assessment.AAssessmentRunner):
    """Define a measure for the fitness assessment.

    Uses constant optimization. Optimal values for the constants are stored to
    an individual's popt attribute.
    """
    def setup(self):
        # Setup dynamic system.
        self.nperiods = 50.0
        self.x = np.linspace(0.0,
Beispiel #4
0
import operator
import re
import sys

import dill
import numpy as np
import pytest
import scipy.integrate

from glyph import assessment
from glyph import gp
from glyph.utils.numeric import hill_climb, rms

SingleConstIndividual = gp.Individual(pset=gp.sympy_primitive_set(
    categories=['algebraic', 'exponential', 'neg', 'sqrt'],
    arguments=['x_0'],
    constants=['c']),
                                      name="SingleConstIndividual",
                                      marker="sympy")

TwoConstIndividual = gp.Individual(pset=gp.sympy_primitive_set(
    categories=['algebraic', 'exponential', 'neg'],
    arguments=['x_0'],
    constants=['c_0', 'c_1']),
                                   name="TwoConstIndividual",
                                   marker="sympy")

UnlimitedConstants = gp.Individual(pset=gp.numpy_primitive_set(
    1, categories=('algebraic', 'trigonometric', 'exponential', 'symc')),
                                   name="UnlimitedConstants",
                                   marker="symc")
Beispiel #5
0
import scipy

from glyph import application
from glyph import assessment
from glyph import gp
from glyph import utils
from toolz import cons

import sys
import os
sys.path.append(os.path.dirname(__file__))
import control_problem

pset = gp.sympy_primitive_set(
    categories=['algebraic', 'trigonometric', 'exponential'],
    arguments=['y0', 'y1'],
    constants=['c'],
)
Individual = gp.Individual(pset=pset, name="Individual")


class AssessmentRunner(assessment.AAssessmentRunner):
    """Define a measure for the fitness assessment.

    Uses constant optimization. Optimal values for the constants are stored to
    an individual's popt attribute.
    """
    def setup(self):
        # Setup dynamic system.
        self.nperiods = 50.0
        self.x = np.linspace(0.0,
Beispiel #6
0
import operator
import re
import sys

import dill
import numpy as np
import pytest
import scipy.integrate

from glyph import assessment
from glyph import gp
from glyph.utils.numeric import hill_climb, rms

SingleConstIndividual = gp.Individual(
    pset=gp.sympy_primitive_set(
        categories=["algebraic", "exponential", "neg", "sqrt"],
        arguments=["x_0"],
        constants=["c"]),
    name="SingleConstIndividual",
    marker="sympy",
)

TwoConstIndividual = gp.Individual(
    pset=gp.sympy_primitive_set(categories=["algebraic", "exponential", "neg"],
                                arguments=["x_0"],
                                constants=["c_0", "c_1"]),
    name="TwoConstIndividual",
    marker="sympy",
)

UnlimitedConstants = gp.Individual(
    pset=gp.numpy_primitive_set(1,
Beispiel #7
0
def SympyIndividual():
    return gp.Individual(pset=gp.sympy_primitive_set(constants=["c"]),
                         name="SympyIndividual")