Originally posted by: SystemAdmin
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 c
i in rangeI = 1;
int wnew
i in rangeI = 100; //w'_k, capacity of new provisioned vm
int r
i in rangeI = ((i % 10)+1) * 10;
int w
j in rangeJ2 = 20; //w_j
int t
j in rangeJ = 1; //the boot time of each running instance
int d
j in rangeI = 1; //departureTime of each jobs, in second
int a
j in rangeI = 1; //arrival of each jobs, in second
dvar int x
i in rangeIj in rangeJ in 0..1; //whether job i is assigned to new provisioned-machine j
dvar int z
i in rangeIj in rangeJ2 in 0..1; //whether job i is assigned to running machine j
dvar int y
j 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];
}
#DecisionOptimization#OPLusingCPLEXOptimizer