Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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|                                                                                         

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.

share|cite|improve this question
up vote 1 down vote accepted

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.

share|cite|improve this answer
thanks, I am just precomputing things now – gnychis Mar 30 '12 at 1:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.