Open nk027 opened 4 years ago
Here a small silly demo of the problem - the outcome heavily depends on the order of processes.
y
contains the production from processes, z the available processing and C the TCFs.
(C <- matrix(c(0.1, 0, 0, 0.1, 0.1, 0, 0, 0.1, 0.1), nrow = 3))
y <- c(1000, 500, 100)
z <- z_adj <- c(5000, 4000, 500)
out <- matrix(0, nrow = nrow(C), ncol = ncol(C))
for(i in seq(nrow(C))) {
tmp <- y[i] / C[i, ]
tmp[!is.finite(tmp)] <- 0
tmp[tmp > z_adj] <- z_adj[tmp > z_adj]
z_adj <- z_adj - tmp
out[i, ] <- tmp
}
print(out)
> [,1] [,2] [,3]
>[1,] 5000 4000 0
>[2,] 0 0 500
>[3,] 0 0 0
C <- C[3:1, 3:1]
y <- y[3:1]
z <- z_adj <- z[3:1]
[...]
print(out[3:1, 3:1])
>[,1] [,2] [,3]
>[1,] 5000 0 0
>[2,] 0 4000 0
>[3,] 0 0 500
So in the use TCF we split processing values up and allocate them to use by some process. This is done by applying TCF to the output of the process and potentially capping with the available processing input (from the CBS), which is then reduced by the amount of use.
Since some processes share items the later processes in the loop are capped at lower values, since processing has already been reduced!