Skip to content
This repository has been archived by the owner on Apr 28, 2020. It is now read-only.

trussle/mamo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MaMo

Maintained by @jonnyarnold

The Mathematical Modelling Helper you never knew you didn't need.

Installation

It's an NPM package:

npm install --save mamo

Usage

MaMo can be used to model systems of equations. For example, if you had the system:

  r = s - p
  s = a + b
  p = a * b
  b = a - 1

you can use a MaMo model to represent them and perform some fun experiments.

const mamo = require("mamo")

const contrivedExample = mamo.buildModel({
  result: function() {
    return this.product - this.sum
  },

  sum: function() {
    return (this.a + this.b)
    || (this.product - this.result)
  },

  product: function() {
    return (this.a * this.b)
      || (this.result + this.sum)
  },

  b: function() { return this.a - 1 }
})

// Supports defining dangling variables!
const scenario1 = contrivedExample.where({ a: 4 })
console.log(scenario1.result) // (4 * 3) - (4 + 3) = 5

// Supports overriding relations!
const scenario2 = contrivedExample.where({ product: 4, sum: 2 })
console.log(scenario2.result) // 2

Releases

No releases published

Packages

No packages published