[SCIP+AMPL] Correspondence between decision variable names and values?

33 views
Skip to first unread message

JC

unread,
Oct 17, 2018, 2:48:16 PM10/17/18
to OPTI Toolbox Forum
After running the example 6 presented here: https://www.inverseproblem.co.nz/OPTI/index.php/File/AMPL,

I obtain a vector with the solution for each decision variable specified in the AMPL model file:

solution =

     3
     2
     0
     4
     3
     0
     1
     1

How can one find the correspondence between the values obtained and the names specified in the model file, i.e, which value corresponds to which variable? 

Jonathan Currie

unread,
Oct 22, 2018, 3:22:59 AM10/22/18
to opti-tool...@googlegroups.com
I'm unfortunately away on holiday at the moment and don't have access to MATLAB, but I believe solving an AMPL problem also generates a .sol (solution) file in the current directory which should contain this information? Otherwise from memory AMPL reorders variables based on integer/continuous/binary I think. This document may help a bit: https://ampl.com/REFS/hooking2.pdf

Apologies this should be a simple answer but I don't have the information in front of me at the moment!

Jonathan

--
You received this message because you are subscribed to the Google Groups "OPTI Toolbox Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opti-toolbox-fo...@googlegroups.com.
To post to this group, send email to opti-tool...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jorge Miguel Cordeiro

unread,
Oct 22, 2018, 10:58:52 AM10/22/18
to jonathan...@gmail.com, opti-tool...@googlegroups.com
The .sol (solution) file generated also does not contain the decision variables names, only their values.

I found a way to work around this issue, which is satisfactory for me, but maybe not the easier way of doing things.

After solving the problem in MATLAB, I go to the command window of AMPL. There I load the model, the data and the solution files. Then, I input this command: printf {i in 1.._nvars} "%s= %.16f\n", _varname[i], _var[i] > ("OUTPUT" & ".out");, which generates me a new .out (output) file with the variables names and values.

Thanks a lot for answering Jonathan.
Reply all
Reply to author
Forward
0 new messages