@colibri-engine/core

The engine is based on incremental computation algorithms. When a calculation is submitted to the engine, all the computed values are memorized. So, if you change some variable and query an evaluation, the engine is able to compute the result very fast be

Usage no npm install needed!

<script type="module">
  import colibriEngineCore from 'https://cdn.skypack.dev/@colibri-engine/core';
</script>

README

Colibri-Engine

Presentation

The engine is based on incremental computation algorithms. When a calculation is submitted to the engine, all the computed values are memorized. So, if you change some variable and query an evaluation, the engine is able to compute the result very fast because it recomputes only what has changed.

Libraries

The API provides several libraries that each comes with dozens of operators.

Usage

Imports

The engine API permits you to import the operators in a very simple way.

import {/* required operators */} from "@colibri-engine/{library}" ;

Variable

The engine API permits you to define some special scalars called variables. There are special because once the model is loaded into the engine, you are able to change its values with the affect operation.

import {number} from "@colibri-engine/number" ;

const x = number();

x.affect(12);

Expression

The API allows you to create expressions such as "and", "sum", "isLessThan". An expression represents a step of the computation of the calculation. There, take a set of nodes (variables or expressions) and return a single value—the expressions value.

import {sum, number} from "@colibri-engine/number";

const x = number();
const y = number();
const fx = sum(x, y);

fx.eval()

Example

Polynom computation

import {number, zero} from "@colibri-engine/number";
import {x2} from "@colibri-engine/math";

const x = number();
const a = number(3);
const b = number(5);
const c = number(7);
const fx = a.times(x2(x)).plus(b.times(x)).plus(c);

x.affect(1)
fx.eval(); // = 15

Polynom resolution

import {number, zero} from "@colibri-engine/number";
import {x2, sqrt} from "@colibri-engine/math";

const a = number();
const b = number();
const c = number();
const delta = x2(b).minus(times(4, a, c));
const hasSolution = delta.greaterOrEqualThan(zero);
const x = opposite(b).divide(times(2, a));
const x1 = opposite(b).minus(sqrt(delta)).divide(times(2, a));
const x2 = opposite(b).sum(sqrt(delta)).divide(times(2, a));

a.affect(1);
b.affect(2);
c.affect(3);

hasSolution.eval() // = true
x1.eval(); // = 2/3
x2.eval(); // = 1