True algorithm (used in Compute.exe) |
//Stocks and Flows first
initialization
At t = 0 { stocks(t) = stocks initial value mirror stocks(t) = sum (source stocks (t)) flows(t) = 0 } //----------------------------------------------------------------------------- for t = 1
to last t { //last t = (last_cycle)
x (last_time_per_cycle)
//Stocks and Flows initialization for
current time unit
stocks(t) = stocks(t-1) mirror stocks(t) = mirror stocks(t-1) flows(t) = 0 Filtering and grouping actions in
Sets sorted by Chronology()
for first
Set to last Set
{
//Actions dynamic computing
for first
action to
last action {
y[action] = function(action code)* } for first
action to
last action {
if flow[action] links two stocks { //First stocks update if Rate is disable { source stock(t) = source stock(t) - y[action] target stock(t) = target stock(t) + y[action] else { //store the return value RateBuffer[action] = y[action]
}
} //Flows
update
flow[action](t) = flow[action](t) + y[action] } //First mirror stocks
update
for first mirror stock to last mirror stock { mirror stock(t) = sum (source stocks(t)) } }
//Last stocks update
for first RateBuffer[action] to last RateBuffer[action] { source stock[action](t) = source stock[action](t) - (RateBuffer[action] / TimeStepI) target stock[action](t) = target stock[action](t) + (RateBuffer[action] / TimeStepI) } // TimeStepI = 1 / TIME STEP //Last mirror stocks
update
for first mirror stock to last mirror stock { mirror stock(t) = sum (source stocks(t)) } }
//Algorithm end
|
About Action code |
y[action] =
function(action
code)*
Action code example:
//Read a current stock or flow or mirror
stock value y= Svalue("SB") + Fvalue("FE") - Mvalue("FA")
//Read a delayed
value: y+= Svalue("SB",4,10) + Fvalue("FE",2,2) - Mvalue("FA",3,5)
y+= Svalue("SB",False,31) + Fvalue("FE",False,15) - Mvalue("FA",False,40)
//Default syntax to read a current stock or
flow or mirror stock value
Fvalue("FE") : read the current
value of the flow "FE"
Mvalue("FA") : read the current
value of the mirror
stock "FA"
//First syntax for delayed value:
Svalue("SB",c,t) // c= cycle, t=time = current time in the current
cycle
//Example:
Svalue("SB",4,10) : read a
delayed value of the stock
"SB" for
cycle = 4 and time = 10
Fvalue("FE",2,2) : read a
delayed value of the flow "FE" for cycle = 2 and time = 2
Mvalue("FA",3,5) : read a
delayed value of the mirror
stock "FA" for cycle = 3 and time =
5
/Second syntax for delayed
value:
Svalue("SB",False,nbt) // nbt or nbtime =current time number starting
from first cycle
//Example: Svalue("SB",False,31) : read a
delayed value of the stock
"SB" for nbtime = 31
Fvalue("FE",False,15) : read a delayed value of the flow "FE" for nbtime = 15
Mvalue("FA",False,40) : read a delayed value of the mirror stock "FA" for nbtime = 40 // nbtime max =
(last_cycle) x (last_time)
//be careful with action Chronologies ! |