An example would be 2 models (m1 & m2) that work and can be tested independently. One model have an exogenous variable, let say m2 and varX. For now varX = anyConstant
Then without having to copy paste all the code, I want the output of m1 to be the input for varX (which become endogenous) in m2. I now would have a unique model.
You can create two models and export values from the first model to be used in the second model. Here is an example that creates two models
m1andm2. The first model is solved to determine the value ofx1that is exported by assigningoutput_m1tox1.value[0]. This is an input parameter of the second model withvarX = m2.Param(value=output_m1).The output from this code is:
The value of
varXcan also be updated if there are multiple solutions such as withvarX.value=output_m1.