Search code examples
ampl

ampl display variable depending on a condition


suppose we have the following ampl model:

set objects;
set sacks;
...
var Take{objects, sacks} binary;
...
display Take;

after solving the optimization problem I want to display only the lines of Take that equal 1


Solution

  • You can do something like this:

    for{o in objects, s in sacks: Take[o,s] = 1} {
        printf "\n %s %s", o,s; 
    }