Group: sci.op-research
From: Min
Date: Tuesday, February 26, 2008 8:19 PM
Subject: Re: define decision variable in OPL-CPLEX

On Feb 26, 2:34 am, Irv Lustig wrote:
> On Feb 25, 10:29 pm, Min wrote:
>
> > Hello -
> > I have a basic question about defining decision variables in OPL-
> > CPLEX. I want to define the variable in a nested format like the
> > following
>
> > for ( var i=0; i<=4; i++) {
> > for ( var j=0; j<=P(i); j++){
> > dvar boolean a[i][j]}}
>
> > But the system thinks it is an error. How can I do this?
>
> > Many thanks.
>
> Use tuples as follows:
> tuple IndexSetTuple {
> int i;
> int j;};
>
> setof(IndexSetTuple) indexset = { | i in 0..4, j in 0..P[i] };
> dvar boolean a[indexset];
>
> When you refer to the variables in the model, use the expression
> a[];
>
> Tuples are a very important feature to make scalable models with OPL.
>
> -Irv Lustig, PhD
> ilus...@ilog.com
> ILOG Direct Channel Director
> http://www.ilog.com/

Thank you, Irv. It is great to have experts from ILOG here;-)

Safety Articles | Usenet Groups | Usenet News | Bluegrass