コード例 #1
0
ファイル: damped_oscillator.py プロジェクト: zeta1999/glyph
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,
                             self.nperiods * 2.0 * np.pi,
                             2000,
                             dtype=np.float64)
コード例 #2
0
ファイル: test_assessment.py プロジェクト: sayin/glyph
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")
コード例 #3
0
ファイル: conftest.py プロジェクト: sayin/glyph
def SympyIndividual():
    return gp.Individual(pset=gp.sympy_primitive_set(constants=["c"]),
                         name="SympyIndividual")
コード例 #4
0
ファイル: test_assessment.py プロジェクト: zeta1999/glyph
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",
コード例 #5
0
ファイル: conftest.py プロジェクト: sayin/glyph
def NumpyIndividual():
    # 13 for the boston data set
    return gp.Individual(gp.numpy_primitive_set(arity=13), "NumpyIndividual")