Topic
• Latest Post - ‏2013-04-24T07:08:01Z by AlexFleischer
JasonHan@UT
1 Post

Pinned topic triple index in IP

‏2013-04-23T17:27:42Z |

Hi,

I am a beginner of Cplex OPL, recently I encounter a problem about unequal matrix , here is code

rang hour=1..10;
rang day=1..5;
float data1[hour]=[3,2,5,7,2,6,1,4,5,6];
float start[day]=[3,6,2,4,5];
float end[day]=[9,10,6,8,9];
range interval=start[day]..end[day];
float data2[interval][hour]=?? /*how to use opl input dual index in this data*/

dvar boolean y[day][hour]

minimize sum(j in day, i in hour)(y[j][i]*data2[interval])

Subject to {

forall (j in day)

ctyji: sum(i in hour)(y[j][i]==3);

}

I have solve this question by using the matrix below

day1 <     5 7 2 6 1 4 5   >
day2 <               6 1 4 5 6>
day3 <  2 5 7 2 6             >
day4 <        7 2 6 1 4       >
day5 <            2 6 1 4 5   >

I used big number 99 fill the blank, but if I use the model to solve thousands data and this method is not working at all , how to solve this problem by using OPL. I think I should use loop function. Is there some way to resolve this, thanks a lot.

• AlexFleischer
3156 Posts

Re: triple index in IP

‏2013-04-24T07:08:01Z

Hi,

if your matrix is sparse, instead of using an array you could use a tuple set with only the needed values.

You would replace

float data2[interval][hour]

by

a tuple set with a tuple with 3 fields: interval, hour, and value.

Regards