# Table of Contents

# Model

EpiJS module for creating custom models, which are made of compartments.

Import it with:

       const model = require('@epispot/epijs').model

# Model

Create a model.

# Parameters

  • compartments Array (opens new window) Compartments in the model. Each should be a list, with the first value being the compartment, and the second being it's start value in the key.
  • key Object (opens new window) The key of values for any variable used in the equation. If you use any variable which represents the population of a compartment, add the starting value into the key.

# Examples

let susceptible = new Idiom("S-(B*S*I/p)");
let infected = new Idiom("I+(B*S*I/p)-(u*I)");
let recovered = new Idiom("R+(u*I)");

let key = {
 "S": 10000,
 "B": 0.3,
 "I": 100,
 "R": 0,
 "p": 10100,
 "u": 0.2
};

let sirm = new Model([[susceptible, "S"], [infected, "I"], [recovered, "R"]], key)

# get_data

Get data for the outbreak.

# Parameters

# Examples

let susceptible = new Idiom("S-(B*S*I/p)");
let infected = new Idiom("I+(B*S*I/p)-(u*I)");
let recovered = new Idiom("R+(u*I)");

let key = {
 "S": 10000,
 "B": 0.3,
 "I": 100,
 "R": 0,
 "p": 10100,
 "u": 0.2
};

let sirm = new Model([[susceptible, "S"], [infected, "I"], [recovered, "R"]], key)

model.get_data(100) // Get data for 100 days.

# remove

Remove a compartment from the model.

# Parameters

# Examples

let susceptible = new Idiom("S-(B*S*I/p)");
let infected = new Idiom("I+(B*S*I/p)-(u*I)");
let recovered = new Idiom("R+(u*I)");

let key = {
	"S": 10000,
	"B": 0.3,
	"I": 100,
	"R": 0,
	"p": 10100,
	"u": 0.2
};

let sirm = new Model([[susceptible, "S"], [infected, "I"], [recovered, "R"]], key)

sirm.remove(recovered) // Removes the recovered compartment.

# add

Add a compartment to the model.

# Parameters

# Examples

let susceptible = new Idiom("S-(B*S*I/p)");
let infected = new Idiom("I+(B*S*I/p)-(u*I)");
let recovered = new Idiom("R+(u*I)");
	
let key = {
	"S": 10000,
	"B": 0.3,
	"I": 100,
	"R": 0,
	"p": 10100,
	"u": 0.2
};

let sirm = new Model([[susceptible, "S"], [infected, "I"], [recovered, "R"]], key)

sirm.remove(susceptible) // Removes the susceptible compartment.
sirm.add([susceptible, "S"], 0) // Adds the susceptible compartment back to the beginning

# mexport

NodeJS only! Exports models to a file which can then be imported later on.

# Parameters

# Examples

let susceptible = new Idiom("S-(B*S*I/p)");
let infected = new Idiom("I+(B*S*I/p)-(u*I)");
let recovered = new Idiom("R+(u*I)");

let key = {
 "S": 10000,
 "B": 0.3,
 "I": 100,
 "R": 0,
 "p": 10100,
 "u": 0.2
};

let sirm = new Model([[susceptible, "S"], [infected, "I"], [recovered, "R"]], key)

mexport(sirm, "output.js", file_type=".js")

# mimport

NodeJS only! Imports a model from a file.

# Parameters

# Examples

// Use mexport to export a model into a file
let sirm = mimport("./output.json")