--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to am...@googlegroups.com.
To unsubscribe from this group, send email to ampl+uns...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ampl?hl=en.
You can use "i" in both statements:
param x{i in 1..5, 1..q[i]};
...
subject to constr1{i in 1..5}: alpha[i]>=(1/d[i])*(sum{k in 1..q[i]}(x[i,k]));
It is just a dummy index whose definition is active only in the statement that uses it.
Bob Fourer
From: am...@googlegroups.com [mailto:am...@googlegroups.com]
On Behalf Of Sachin Argade
Sent: Monday, May 14, 2012 8:35 PM
To: am...@googlegroups.com
Cc: 4...@ampl.com
Subject: Re: [AMPL 5800] writing Parameters
Bob,
as you mentioned I tried putting [i] in front of q...then it looks like this
param q{1..5}; # this is the parameter I want to use in the parameter x which is defined below
param d{1..5};
param x{1..5,1..q[i]}; # here I used parameter q which is defined earlier
param alpha{1..5};
.
.
.
subject to constr1{i in 1..5}:alpha[i]>=(1/d[i])*(sum{k in 1..q[i]}(x[i,k])); # here I am using both x and q
then it gives me error that i is not defined.......and I do not want define i before, because as you can see it is defined in the constraint below
please let me know how to avoid this.
Thank you,
Sachin.
.
--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to am...@googlegroups.com.
To unsubscribe from this group, send email to ampl+uns...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ampl?hl=en.
Perhaps the error is now coming from some other statement. Or maybe the indexing of x was accidentally written "I in 1..5", which would result in that error. Can you post the entire error message, so that the context is clear? Also it might help to attach the model file.
On Behalf Of Sachin Argade
Sent: Tuesday, May 15, 2012 9:14 AM
To: am...@googlegroups.com
Cc: 4...@ampl.com
Subject: Re: [AMPL 5805] writing Parameters
Still it gives error as ' i ' is not defined.......
On Tue, May 15, 2012 at 8:56 AM, Robert Fourer <4...@ampl.com> wrote:
You can use "i" in both statements:
param x{i in 1..5, 1..q[i]};
...
subject to constr1{i in 1..5}: alpha[i]>=(1/d[i])*(sum{k in 1..q[i]}(x[i,k]));
It is just a dummy index whose definition is active only in the statement that uses it.
Bob Fourer
.
To unsubscribe from this group, send email to ampl+unsubscribe@googlegroups.com.
--
Sachin Argade