I want to iteratively run a set of scenarios. There are two notebooks NB1
and NB2
. The former includes the following system of 2 equations, and the latter includes data and parameter specifications for scenarios. NB1
is:
a X1 + b Y1 == A1;
c X1 + d Y1 == B1;
where {A1, B1}
is the set of constants, and {a, b, c, d}
is the set of parameters calculated in NB2
.
In the notebook NB2
, I keep the data and parameters (scenarios):
benchmarkData = {A1=3, B1=7, a=2, b=9, c=5, d=4};
scenario[i] = {A1=1, B1=0, a=1, b=8, c=5, d=4};
In NB1
, I also created a matrix of 8 by 6 in order to store the solutions from i=6 scenarios. The first column is reserved for storing the solution from i=1 in the order of sol[1] = {X1, Y1, A1, B1, a, b, c, d}
. I first run NB2
to define benchmarkData
and scenario[i]
, and then go to NB1
to Get["file director of NB2"]
the defined benchmark and scenario variables into NB1
and run the model. When the solution is obtained, store it to the first column of the scenario matrix created in NB1
. I repeat the same procedure for each new scenario: design a new scenario in NB2
, go to NB1
to run the model and store the solution in the 2nd column of the matrix, etc.
I know how to do this operation in a single notebook by using:
While[z<7, {the model and the matrix}; z++]
but I could not do the same iteration using two separate notebooks. This is a simple version of a very big model with a large dataset. That is why I had to divide the code
into two notebooks to iteratively run the scenarios and get a matrix of solutions.
I tried several ways to achieve the task such as creating an index z
in NB2
and store the solution in NB1
with an indexed variable but it did not work because the code always kept the very last scenario run not the earlier ones.
I would appreciate your suggestions.