Hi all,
I have an objective function listed in below. But I can not compile it, the CPLEX said "cannot extract extractable". Can anyone help me to solve this. Thanks
rangeI = 1..M;
rangeJ2 = 1..M;
minimize
sum(j in rangeJ2)(
t[j] +
(max(i in rangeI)
(d[i] a[i]) * z[i][j]
)
)
;
Topic

Re: summation with max function
20121226T16:16:44ZThis is the accepted answer. This is the accepted answer. AlexFleischer
 20121203T16:04:28Z
Hi,
which are data and which are decision variables?
If you post your real model maybe someone will be able to help you.
Regards
Here are my code with comments.
This is a toy code to test my idea.
using CP;
int M = 10;//M number of newly arrival jobs
int N = 100; //N number of running instances
int maximumMachineCapacity = 100;
int maximumJobConsumption = 100;
int numberOfRunningMachines = 100;
range rangeI = 1..M; //M number of jobs
range rangeJ = 1..M;
range rangeJ2= 1..N; // there are N number of running VM
float ci in rangeI = 1;
int wnewi in rangeI = 100; //w'_k, capacity of new provisioned vm
int ri in rangeI = ((i % 10)+1) * 10;
int wj in rangeJ2 = 20; //w_j
int tj in rangeJ = 1; //the boot time of each running instance
int dj in rangeI = 1; //departureTime of each jobs, in second
int aj in rangeI = 1; //arrival of each jobs, in second
dvar int xi in rangeIj in rangeJ in 0..1; //whether job i is assigned to new provisionedmachine j
dvar int zi in rangeIj in rangeJ2 in 0..1; //whether job i is assigned to running machine j
dvar int yj in rangeI in 0..1; //whether machine j is provisioned
minimize
sum(j in rangeJ2)(
t[j] +
(max(i in rangeI)
(d[i] a[i]) * z[i][j]
)
)
;
subject to {
forall(j in rangeJ2)
sum(i in rangeI)
z[i][j] * r[i] <= w[j];
forall(j in rangeI)
sum(i in rangeI)
x[i][j] * r[i] <= wnew[j] * y[j];
forall(i in rangeI)
sum(j in rangeJ2)
z[i][j] +
sum(k in rangeJ)
x[i][k] == 1;
forall(j in rangeI)
forall(i in rangeI)
x[i][j] <= y[j];
} 
Re: summation with max function
20121227T01:02:11ZThis is the accepted answer. This is the accepted answer. SystemAdmin
 20121226T16:16:44Z
Hi, thanks for your reply.
Here are my code with comments.
This is a toy code to test my idea.
using CP;
int M = 10;//M number of newly arrival jobs
int N = 100; //N number of running instances
int maximumMachineCapacity = 100;
int maximumJobConsumption = 100;
int numberOfRunningMachines = 100;
range rangeI = 1..M; //M number of jobs
range rangeJ = 1..M;
range rangeJ2= 1..N; // there are N number of running VM
float ci in rangeI = 1;
int wnewi in rangeI = 100; //w'_k, capacity of new provisioned vm
int ri in rangeI = ((i % 10)+1) * 10;
int wj in rangeJ2 = 20; //w_j
int tj in rangeJ = 1; //the boot time of each running instance
int dj in rangeI = 1; //departureTime of each jobs, in second
int aj in rangeI = 1; //arrival of each jobs, in second
dvar int xi in rangeIj in rangeJ in 0..1; //whether job i is assigned to new provisionedmachine j
dvar int zi in rangeIj in rangeJ2 in 0..1; //whether job i is assigned to running machine j
dvar int yj in rangeI in 0..1; //whether machine j is provisioned
minimize
sum(j in rangeJ2)(
t[j] +
(max(i in rangeI)
(d[i] a[i]) * z[i][j]
)
)
;
subject to {
forall(j in rangeJ2)
sum(i in rangeI)
z[i][j] * r[i] <= w[j];
forall(j in rangeI)
sum(i in rangeI)
x[i][j] * r[i] <= wnew[j] * y[j];
forall(i in rangeI)
sum(j in rangeJ2)
z[i][j] +
sum(k in rangeJ)
x[i][k] == 1;
forall(j in rangeI)
forall(i in rangeI)
x[i][j] <= y[j];
}
int t[j in rangeJ] = 1; //the boot time of each running instance minimize sum(j in rangeJ2)(t[j] + (max(i in rangeI) (d[i] a[i]) * z[i][j]));
t is defined over rangeJ (1..10), but the sum to minimize is defined over rangeJ2 (1..100), so you have an Index Out Of Bound Exception at Runtime. You probably want either to define t over rangeJ2, or to define the sum over rangeJ.
Regards,
StefanoUpdated on 20140326T05:51:38Z at 20140326T05:51:38Z by ironman 
Re: summation with max function
20121231T02:16:24ZThis is the accepted answer. This is the accepted answer. SystemAdmin
 20121227T01:02:11Z
Look at these two lines:
<pre class="java dw" dataeditorlang="java" datapbcklang="java" dir="ltr">int t[j in rangeJ] = 1; //the boot time of each running instance minimize sum(j in rangeJ2)(t[j] + (max(i in rangeI) (d[i] a[i]) * z[i][j])); </pre>
t is defined over rangeJ (1..10), but the sum to minimize is defined over rangeJ2 (1..100), so you have an Index Out Of Bound Exception at Runtime. You probably want either to define t over rangeJ2, or to define the sum over rangeJ.
Regards,
Stefano
This problem is solved.