Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer 1

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|improve this answer
    
thanks, I am just precomputing things now –  gnychis Mar 30 '12 at 1:05
add comment

Your Answer

 
discard

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.