# creating a set in ZIMPL (which creates .LP for SoPlex & CPLEX)

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.

-

You can't do this directly. But if your $Q$ is known, you can pre-compute all the output, and store them in a set, with row number as index.