// Here, we consider modeling queues: https://en.wikipedia.org/wiki/M/M/c_queue import*asDGLfrom'diff-grok';
// 1. Model specification: the M|M|2|2 model constmodel = `#name: M|M|2|2 #description: Modelling the system with two servers & two waiting places (EXPLAINED)
#equations: dp0/dt = -la * p0 + mu * p1 dp1/dt = la * p0 - (la + mu) * p1 + 2 * mu * p2 dp2/dt = la * p1 - (la + 2 * mu) * p2 + 2 * mu * p3 dp3/dt = la * p2 - (la + 2 * mu) * p3 + 2 * mu * p4
#argument: t _t0 = 0 {min: 0; max: 10; caption: start; category: Time; units: min} [Initial time of simulation] _t1 = 60 {min: 20; max: 100; caption: finish; category: Time; units: min} [Final time of simulation] _h = 1 {min: 0.01; max: 0.1; caption: step; category: Time; units: min} [Time step of simulation]
#inits: p0 = 1 {min: 0; max: 1; category: Initial state; caption: empty} [Probability that initially there are NO customers] p1 = 0 {min: 0; max: 1; category: Initial state; caption: single} [Probability that initially there is ONE customer] p2 = 0 {min: 0; max: 1; category: Initial state; caption: two} [Probability that initially there are TWO customers] p3 = 0 {min: 0; max: 1; category: Initial state; caption: three} [Probability that initially there are THREE customers]
#output: t {caption: Time, min} p0 {caption: P(Empty)} busy {caption: P(Full load)} queue {caption: E(Queue)}
// 3.2) Set model inputs constinputs = { _t0:0, // Initial time of simulation _t1:60, // Final time of simulation _h:1, // Time step of simulation p0:1, // Probability that initially there are NO customers p1:0, // Probability that initially there is ONE customer p2:0, // Probability that initially there are TWO customers p3:0, // Probability that initially there are THREE customers arrival:10, // Mean arrival time service:100, // Mean service time }; constinputVector = DGL.getInputVector(inputs, ivp);
Pipeline creator for a model
Example