根据条件放大显示变量

ampl display variable depending on a condition

假设我们有以下放大模型:

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

解决优化问题后我只想显示取等于1的行

你可以这样做:

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