Using the optimized values from one Lingo model in another Lingo model

478 views Asked by At

In lingo I have modeled a maximizing function and have found optimal values for say x1,x2,x3.The data required to this model is obtained through an EXCEL sheet by =@OLE('C:\sheet1'). This maximization part works fine. For the second part now I have to use these optimal X1,X2,X3 which were found from this model and use some data in C:\sheet1 and multiply Xi's with sheet1 data and insert the resulting values in a column in sheet1.
How can I do this?
Do I have to do the second part in a separate LINGO file? If so how can I obtain the optimized values in first model ?
Or can I write two Models in one LINGO file? In this way does this help me to have the optimized values from part1 to be used for part2?

1

There are 1 answers

0
Honza Osobne On

I am not a Lingo expert, but here are a few hints. You can use the SUBMODEL directive to define two submodels and then execute them in a CALC section. Between executing them, you can 'sandwich' your data-processing code:

SUBMODEL m1:
... define equations ...
ENDSUBMODEL

SUBMODEL m2:
... define equations ...
ENDSUBMODEL

CALC:
@SOLVE(m1)
... read in the new data from Excel ...
... do the data processing ...
@SOLVE(m2)
... output to Excel ...
ENDCALC

As for the data export to Excel, see manual (Lingo 14) page 451 for an example. SUBMODEL is documented on page 597. These lecture notes also show many helful examples regarding the data processing (accessing variable values, modifying parameters, etc.)