I am looking for some help creating a set dynamically in ZIMPL.
I have a parameter table:
param Q[W*W] := |1,2,3,4,5| |1|1,1,0,0,0| |2|1,1,0,0,0| |3|0,0,1,0,0| |4|0,0,0,1,0| |5|0,0,0,0,1|;
I can access elements like: Q[1,2] --> 1, Q[3,3] --> 1, Q[3,4] --> 0.
What I want to do is create a function that, given a row index, returns me the column indices that have a value of 1. Like, func(Q,2) would return {1,2}. And func(Q,3) would return {3}.
I have been struggling with this, I've read the ZIMPL manual, and I can't find the right methods to do this. I know how to create a function, but I can't seem to figure out how to actually compute the set to return.