Topic
• 5 replies
• Latest Post - ‏2013-03-17T15:55:40Z by SystemAdmin
754 Posts

# Pinned topic Restrict combinations of indices for decision variable to reduce runtime.

‏2013-02-17T18:11:17Z |
Hello,
I started to use cplex opl a few months ago. Now I have a problem which I can´t solve by myself.
It is a scheduling problem with l=1..4 Lines; i,j=1..25 Blocks and s=1..20 Micro-Periods.
Because every block is assigned to a line it should be possible to reduce the amount of possible combinations for the decision-variable z_lijs. z_lijs is 1 if there is a changeover from block i to block j on line l and in micro-period s/ 0 otherwise. The objective function is to minimize: z_lijs * c_lij (c_lij are set-up costs).

range Line =1..4;
range Block=1..25;
range Micro=1..20;

tuple zIndizes{
int Line;
int Block1;
int Block2;
int Micro;
}

{zIndizes} Index = {<l,i,j,s>| l in Line: l==1, i in 20..24, j in 20..24, s in 1..20};
{zIndizes} Index = {<l,i,j,s>| l in Line: l==2, i in 11..19, j in 11..19, s in 1..20};
{zIndizes} Index = {<l,i,j,s>| l in Line: l==3, i in 1..10, j in 1..10, s in 1..20};
{zIndizes} Index = {<l,i,j,s>| l in Line: l==4, i in Block: i==25, j in Block: j==25, s in 1..20};
float cLineBlockBlock=…;
dvar float+ zIndex;

minimize
sum (l in Line, i in Block1, j in Block2, s in Micro)
c[l][i][j]*z[<l,i,j,s>};
I know that it is wrong to define 4 types of “Index” but my intention was to show what the problem is about.
If it is possible I would like the setup-cost-variable to stay like c[l][i][j] and not be changed to c<l,i,j>.
Maybe there is a possibility to use IF-constraints in the definition of the tuple or to use subtuples? I tried different things but it didn’t work out well.
It would be really nice if somebody could help me.
Thanks,
Kind regards,
MP_10
Updated on 2013-03-17T15:55:40Z at 2013-03-17T15:55:40Z by SystemAdmin
754 Posts

#### Re: Restrict combinations of indices for decision variable to reduce runtime.

‏2013-03-01T17:08:42Z
Finally, I solved the problem by creating a new array LILineBlock where LI[l][i]=1 if Block i is produced on line l.
{zIndizes} Index = {<l,i,j,s>| l in Line, i in Block1, j in Block2, s in Micro: LI[l][i]==1 && LI[l][j]==1};

But now there is a little problem with a constraint in the model.
In the constraint, I would like to refer to the i and j from the tuple.
So I tried this but it doesn´t work:

forall(l in Line, d in Macro2)
sum (idx in Index: idx.i==i)sum(idx in Index: idx.j==j) sum(s in S[d])
stb[l][i][j]*z<l,i,j,s>....

Can anybody tell how the sum i and sum j have to be formulated so that the i,j are taken from tuple "Index"?

Thanks,

regards
MP_10
754 Posts

#### Re: Restrict combinations of indices for decision variable to reduce runtime.

‏2013-03-01T19:39:31Z
Finally, I solved the problem by creating a new array LILineBlock where LI[l][i]=1 if Block i is produced on line l.
{zIndizes} Index = {<l,i,j,s>| l in Line, i in Block1, j in Block2, s in Micro: LI[l][i]==1 && LI[l][j]==1};

But now there is a little problem with a constraint in the model.
In the constraint, I would like to refer to the i and j from the tuple.
So I tried this but it doesn´t work:

forall(l in Line, d in Macro2)
sum (idx in Index: idx.i==i)sum(idx in Index: idx.j==j) sum(s in S[d])
stb[l][i][j]*z<l,i,j,s>....

Can anybody tell how the sum i and sum j have to be formulated so that the i,j are taken from tuple "Index"?

Thanks,

regards
MP_10
I cannot read your code, since you did not surround it with code tags, but I suspect that what you need to do its create a set of valid tuples and then index the constraint over all tuples in the set. I'm pretty sure the OPL documentation explains this and provides examples.

Paul

Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
• AlexFleischer
111 Posts

#### Re: Restrict combinations of indices for decision variable to reduce runtime.

‏2013-03-07T11:10:52Z
I cannot read your code, since you did not surround it with code tags, but I suspect that what you need to do its create a set of valid tuples and then index the constraint over all tuples in the set. I'm pretty sure the OPL documentation explains this and provides examples.

Paul

Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
Hi,

regards
754 Posts

#### Re: Restrict combinations of indices for decision variable to reduce runtime.

‏2013-03-17T15:50:43Z
Hi,

regards

Finally I solved the problem. I initially didn´t understand how the tuples work.

{forall(l in Line, d in Macro2)
sum (idx in zIndex: idx.l==l && idx.s in S[d])
stbhttp://idx.lhttp://idx.ihttp://idx.j*zidx ...}

Regards,

MP10
754 Posts

#### Re: Restrict combinations of indices for decision variable to reduce runtime.

‏2013-03-17T15:55:40Z

Finally I solved the problem. I initially didn´t understand how the tuples work.

{forall(l in Line, d in Macro2)
sum (idx in zIndex: idx.l==l && idx.s in S[d])
stbhttp://idx.lhttp://idx.ihttp://idx.j*zidx ...}

Regards,

MP10
ok now I try it with code-tags...

``````
forall(l in Line, d in Macro2) sum (idx in zIndex: idx.l==l && idx.s in S[d]) stb[idx.l][idx.i][idx.j]*z[idx] ...```
```