Topic
  • 4 replies
  • Latest Post - ‏2012-12-31T02:16:24Z by SystemAdmin
SystemAdmin
SystemAdmin
1883 Posts

Pinned topic summation with max function

‏2012-12-01T17:43:33Z |
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]
)
)
;
Updated on 2012-12-31T02:16:24Z at 2012-12-31T02:16:24Z by SystemAdmin
  • AlexFleischer
    AlexFleischer
    1248 Posts

    Re: summation with max function

    ‏2012-12-03T16: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
  • SystemAdmin
    SystemAdmin
    1883 Posts

    Re: summation with max function

    ‏2012-12-26T16:16:44Z  
    Hi,

    which are data and which are decision variables?
    If you post your real model maybe someone will be able to help you.

    Regards
    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 provisioned-machine 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];

    }
  • SystemAdmin
    SystemAdmin
    1883 Posts

    Re: summation with max function

    ‏2012-12-27T01:02:11Z  
    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 provisioned-machine 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];

    }
    Look at these two lines:

    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,
    Stefano
    Updated on 2014-03-26T05:51:38Z at 2014-03-26T05:51:38Z by iron-man
  • SystemAdmin
    SystemAdmin
    1883 Posts

    Re: summation with max function

    ‏2012-12-31T02:16:24Z  
    Look at these two lines:

    <pre class="java dw" data-editor-lang="java" data-pbcklang="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
    Thank you very much.
    This problem is solved.