[AMPL 24705] Display Variables

Hello everyone, I hope you are well.

I wanted to ask you for help with something. When using display and seeing the values of a variable, is it possible to ask it for each of the indices of a certain set to add the values of the other indices in the other sets? How could I do it


1 2:=
1 1 3
2 2 3
3 4 2

Z[,1]= 7
,2]= 8

Thank you.

I usually do sum{i in SET1, j in SET2}Z[i,j], however, this time, I need partial sums of the variable Z.


You can display the sums with this command:

display {j in SET2} sum {i in SET1} Z[i,j];

The output will look like this:

sum{i in SET1} Z[i,j] [*] :=
1 7
2 8 ;