from pybrain.structure.modules.module import Module


# Tasks to be optimized:
# ----------------------

# simple function
sf = lambda x:-sum((x + 1) ** 2)
# FunctionEnvironment class
fe = SphereFunction
# initialized FE
ife1 = fe(1)
ife2 = fe(2)
ife100 = fe(100)
# a Task object
task = BalanceTask()
task.N = 10
# for the simple evolvable class defined below
evoEval = lambda e: e.x


# starting points
# ----------------------
xlist1 = [2.]
xlist2 = [0.2, 10]
xlist100 = list(range(12, 112))

xa1 = array(xlist1)
xa2 = array(xlist2)
xa100 = array(xlist100)
Пример #2
0
# -*- coding: utf-8 -*-
"""
Created on Thu Mar  7 20:41:24 2013

Just to try and get things working with a GA


@author: david
"""

from pybrain.tools.shortcuts import buildNetwork
from pybrain.structure.parametercontainer import ParameterContainer
from pybrain.rl.environments.functions.unimodal import TabletFunction
from pybrain.rl.environments.cartpole.balancetask import BalanceTask, CartPoleEnvironment
from pybrain.optimization import GA
from pybrain.rl.agents import LearningAgent, OptimizationAgent

environment = CartPoleEnvironment()
task = BalanceTask()

nn = buildNetwork(task.outdim, 6, task.indim)

learning_agent = OptimizationAgent(nn, GA())