In the model, do:
set indexes;
param values{indexes} ;
param index := min{k in indexes: values[k] != 0} k;
display index; # displays: index = 5
and in the data section, do:
param : indexes : values :=
1 0
2 0
3 0
4 0
5 8
6 9
7 0
8 0
;
From: [email protected]
[mailto:[email protected]] On Behalf Of
Victor Gutierrez
Sent: Sunday, June 24, 2012 1:56 PM
To: [email protected]
Subject: [Help-glpk] Help needed
Hi
I need to pre-process some data before an optimization problem begins.
I'm doing the following:
If I have the following array of parameters:
param values = [0 0 0 0 8 9 0 0]
I would like to have in one parameter the index k where the first element of
the array "values" is different of zero, i.e.
param index := 5 due to values[5] != 0
could you help me with this.
Thank you in advance
Victor
________________________________
This e-mail and any attachments may be confidential or legally privileged. If
you received this message in error or are not the intended recipient, you
should destroy the e-mail message and any attachments or copies, and you are
prohibited from retaining, distributing, disclosing or using any information
contained herein. Please inform us of the erroneous delivery by return e-mail.
Thank you for your cooperation.
_______________________________________________
Help-glpk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-glpk