Navigation Menu

Skip to content

v0.4.0

Compare
Choose a tag to compare
@mikeheddes mikeheddes released this 14 Mar 21:43
· 37 commits to master since this release

Evolution algorithm

The first evolutionary algorithm is added called "one plus lambda" (ES-(1+λ)). This algorithm is implemented in C++ for blazing 🔥 speed.

New Expression methodes

The Expression class now has two new methodes getResult and getEquation. getResult calculates the result of a single input point. getEquation returns the encoded equation of the expression as a string.

Example

import { createInstance } from 'dcgp'

const dcgp = await createInstance(fetch('/dcgp.wasm'));
const myKernelSet = new dcgp.KernelSet(['sum', 'diff', 'mul', 'pdiv']);
const myExpression = new dcgp.Expression(2, 1, 2, 6, 5, 2, myKernelSet, 5);

// some simple dataset: y = 2x + 2
const inputs = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1]];
const outputs = [[2], [4], [6], [8], [10]];

// the resultObj currently contains the best loss and the best chromosome but this may change
const resultObj = dcgp.algorithms.onePlusLambda(myExpression, 5, 50, inputs, outputs);