Symbolic manipulation, function reduction, machine learning, code evolution, and stochastic functions. More...
#include <MAgent.h>
Symbolic manipulation, function reduction, machine learning, code evolution, and stochastic functions.
MAgent is the preferred class to use for M interpretation. It provides symbolic manipulation, mathematical function reduction, and code evolution using genetic programming, neural networks, and other machine learning techniques. MAgent provides a limited knowledge base that may be utilized via Tell() and Ask().
In addition, the agent includes functions for interfacing with Mathematica if it is available on your machine: just set the "mMMPath" config to the path of your "math" command. Although the agent may be used to interface with Mathematica, no part of the MAgent implemenation makes use of or requires Mathematica -- except for those functions named MMxxx.
Functional versions of the stochastic methods in MRandom are made available here. MAgent is fully storeable and restoreable. In most cases, agent should be run in non-strict mode, see MObject::setStrict(). Exact mode may also be desired, see MObject::setExact().
| Meta::MAgent::MAgent | ( | ) |
Constructor.
| Meta::MAgent::MAgent | ( | const MAgent & | agent | ) |
Copy constructor.
| Meta::MAgent::MAgent | ( | const mvar & | v, | |
| RestoreOpt | opt | |||
| ) |
Restore constructor.
| Meta::MAgent::MAgent | ( | MBrokerBase * | broker | ) |
Remote object constructor - do not call directly.
| virtual Meta::MAgent::~MAgent | ( | ) | [virtual] |
Destructor.
Query the agent.
| query | e.g: LT(x,10) |
See MRandom::bernoulli().
See MRandom::binomial().
See MRandom::chisquare().
| virtual MObject* Meta::MAgent::clone | ( | ) | const [virtual] |
Return a copy of this agent.
Reimplemented from Meta::MObject.
| bool Meta::MAgent::configure | ( | const mvar & | args | ) |
Configure the agent based on args.
Delete the specified objective function.
| f | objective function, e.g: f(x,y) |
See MRandom::erlang().
Explicitly evaluate an objective function. Usually this function does not need to be called directly.
Evolve an objective function. Upon completion the best solution is set to the objective function in the agent's scope.
| f | The objective function, e.g: f(x,y) | |
| maxTime | Maximum number of seconds to evolve for. | |
| targetError | Stop upon reaching this error. |
See MRandom::geometric().
See MRandom::lognormal().
Convert f to Mathematica function syntax without translating functions.
See MRandom::normal().
Neural-network based evolver using supervised learning.
| f | The objective function to be evolved, e.g: f(x,y) | |
| train | the training set, e.g: [[f:4.23954, x:0.97627, y:1.85689],[f:14.3957, x:4.30379, y:6.88531]] | |
| layers | The number of hidden layers in the network. | |
| height | The height of each hidden layer. |
| mnode Meta::MAgent::Objective_ | ( | mnode | f, | |
| mnode | train, | |||
| mnode | prods, | |||
| mnode | population, | |||
| mnode | maxDepth, | |||
| mnode | evalTimeout = 5.0, |
|||
| mnode | mutationRate = 0.05, |
|||
| mnode | constMutationRate = 0.0, |
|||
| mnode | selectionPressure = 0.5 | |||
| ) |
Specify an objective to be evolved using genetic programming techniques. Supervised or unsupervised learning may be used.
| f | The output function name to be evolved, e.g: f(x,y) | |
| train | The training set of inputs and outputs, e.g: for supervised learning: [[f:4.23954, x:0.97627, y:1.85689],[f:14.3957, x:4.30379, y:6.88531]], for unsupervised learning: [[f:evalFunc(), x:0.97627, y:1.85689],[f:evalFunc(), x:4.30379, y:6.88531]]. | |
| prods | The production rules / grammar, e.g: [[A,[A+A, A-A, A*A, A/A, B]],[B,[1,2,x,y]]], where production symbols are in all-caps and the first rule gives the start production. | |
| population | The population size -- larger populations run slower and require more memory but provide greater diversity and potentially better solutions. If an objective fails to find an adequate solution, increasing population should be one of the first things to try. | |
| maxDepth | Limits the complexity of the output solution. It determines the number of productions that can be selected before a terminal is chosen. | |
| evalTimeout | The maximum number of seconds to evaluate each solution over all of its inputs for. If the evaluation times out, its error is set to infinity. | |
| mutationRate | The mutation rate per population. 0..1.0 | |
| constMutationRate | Constant mutation rate per population. Mutates floating point constants. 0..1.0 | |
| selectionPressure | Higher values favor more strongly the selection of solutions with less error. 0..1.0 |
| f | Objective function, e.g: f(x,y) |
| mnode Meta::MAgent::Objectives_ | ( | ) |
See MRandom::pareto().
See MRandom::pascal().
Enumerate permutations, choosing k.
| f | e.g: [1,2,3] | |
| k | e.g: 2 |
Enumerate permutations.
| f | e.g: [1,2,3] |
See MRandom::poisson().
Process method.
Reimplemented from Meta::MObject.
Reduce a mathematical function.
| f | e.g: 1 + y + 2*y + 3*z / 22*z + 99 |
Identical to Sample(3) but make the output function g.
| g | e.g: g(x,y) |
Sample a function over the specified inputs ranges, for count times. Useful for generating an objective test training set.
| f | e.g: f(x,y) | |
| ranges | e.g: [[-10,10], [5,10]] | |
| count | Number of samples to return. |
Seed the agent's random number generator.
| seed | is 0..18446744073709551615 |
| virtual void Meta::MAgent::store | ( | mvar & | v | ) | const [virtual] |
Store this agent to v.
Reimplemented from Meta::MObject.
Tell the agent a relation has the specified value whenever condition is true thereby executing the post function.
| condition | Eq(x,2) | |
| relation | e.g: Mul(x,y) | |
| value | e.g: 8 | |
| post | e.g: Inc(x) |
Tell the agent a relation has the specified value whenever condition is true.
| condition | e.g: Eq(x,2) | |
| relation | e.g: Mul(x,y) | |
| value | e.g: 8 |
Tell the agent that a relation has the specified value.
| relation | e.g: Add(x,y) | |
| value | e.g: 8 |
Tell the agent a fact.
| fact | e.g: IsCommutative(Add) |
| mnode Meta::MAgent::Time_ | ( | ) |
Return time since the UNIX epoch in seconds + microseconds.
| mnode Meta::MAgent::TimeSeed_ | ( | ) |
Seed the agent's random number generator with the current time.
See MRandom::uniform().
| mnode Meta::MAgent::Uniform_ | ( | ) |
See MRandom::uniform().
1.6.1