You can modify your code as follows (add singleton set, modify equations, and add a loop to solve).
Code: Select all
singleton set ii(i);
objective.. z =e= sum(ii, sum(j, w(ii, j)) );
constraint1(ii, k)..sum(j,w(ii,j)*a(k,j))=l=1;
loop(i,
ii(i) = yes;
solve ...
);
The above code defines objective function as a sum over a singleton set ii. and constraint1 defined over ii, k.
ii can only have one element.
You then loop over rows (set i). In each iteration, you set one ii to yes the rest becomes by default no.
Now if you look at your model for first row, it is exactly what you have shown in your code block.
Hope this helps.
( I have not checked the syntax of the above code block so please understand the idea before implementing)
- Atharv