Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
  • 1.  Conditional sum objective function with decision variable

    Posted Wed May 20, 2020 10:44 AM
    Hi!
    I am new to OPL and CPLEX and I'm trying to formulate an objective function where I want to maximize the number of products delivered within a time limit.

    Some of my input and decision variables:
    int d[S][T] = ...; // demand from site i at time t
    int l = ...; // time limit in which the product needs to be at the depot after demand is available (240 minutes)
    int l2 = ...; // time limit 2 (360 minutes)

    dvar boolean x[S][T][V][R]; // equal to 1 if products at site i at time t are picked up by vehicle v in route r, 0 otherwise
    dvar int+ w[V][R]; // arrival time of vehicle v at depot after completing route r

    So when the demand becomes available, the products needs to be at the depot within 'l' minutes, otherwise penalties will occur.
    If the product arrives: 
    - within the limit (240 minutes) --> no penalty
    - between 241 and 360 minutes --> penalty1 occurs (p1)
    - after 361 minutes --> penalty2 occurs (p1)

    Right now I have this objective function, but it won't work because I put a decision variable as condition in the sum.

    maximize sum (i in S, t in T : w[v][r] <= t + l, v in V, r in R) d[i][t] * x[i][t][v][r]
    + sum (i in S, t in T : w[v][r] => t + l && w[v][r] <= t + l2, v in V, r in R) d[i][t] * x[i][t][v][r] * p1
    + sum (i in S, t in T : w[v][r] => t + l2, v in V, r in R) d[i][t] * x[i][t][v][r] * p2

    Is something like this possible in CPLEX?
    Thank you in advance!

    ------------------------------
    Floor M
    ------------------------------

    #DecisionOptimization


  • 2.  RE: Conditional sum objective function with decision variable

    Posted Wed May 20, 2020 06:49 PM
    You cannot condition sums on decision variable values directly using CPLEX. You can accomplish what you want by adding more binary variables and more constraints.

    Let delta[v][r] and lambda[v][r] be binary variables. Add the constraints w[v][r] <= t + l + (l2-l)*delta[v][r] + (M-l)*lambda[v][r], where M is a (constant) upper bound on how long after release the product hits the depot. Change the objective function to just the sum of c[i][t][v][r], where c is a new (nonnegative continuous) variable with the same dimensions as x. Next, add the following constraints for all combinations of i, t, v and r:

    (1) c[i][t][v][r] <= d[i][t] * x[i][t][v][r]

    (2) c[i][t][v][r] <= d[i][t] * (1 - (1-p)*delta[v][r] - (1-p2)*lambda[v][r])

    If x is 0, (1) forces the contribution of this term to the objective to be 0. Otherwise, if the stuff is on time, the solver will set delta and lambda to 0 and get the full value d[i][t] as the objective contribution. If the stuff is mildly late, the solver will set delta to 1 and lambda to 0 and get p*d[i][t] as contribution. If it's serious late, the solver will set delta to 0 and lambda to 1, and get p2*d[i][t] as the objective contribution.


    ------------------------------
    Paul Rubin
    Professor Emeritus
    Michigan State University
    ------------------------------



  • 3.  RE: Conditional sum objective function with decision variable

    Posted Thu May 21, 2020 03:29 AM
    Hi,

    you could also with a minimal change to your model use logical constraint in the objective:

    range S=1..2;
    range T=1..3;
    range V=1..2;
    range R=1..2;
    
    int d[s in S][t in T] = s*t; // demand from site i at time t
    int l = 10; // time limit in which the product needs to be at the depot after demand is available (240 minutes)
    int l2 = 10; // time limit 2 (360 minutes)
    
    int p1=1;
    int p2=2;
    
    dvar boolean x[S][T][V][R]; // equal to 1 if products at site i at time t are picked up by vehicle v in route r, 0 otherwise
    dvar int+ w[V][R]; // arrival time of vehicle v at depot after completing route r
    
    maximize sum (i in S, t in T , v in V, r in R) ( w[v][r] <= t + l) *d[i][t] * x[i][t][v][r]
    + sum (i in S, t in T , v in V, r in R) ( (w[v][r] >= t + l) && (w[v][r] <= t + l2))*d[i][t] * x[i][t][v][r] * p1
    + sum (i in S, t in T , v in V, r in R) (w[v][r] >= t + l2)*d[i][t] * x[i][t][v][r] * p2;
    
    subject to
    {
      
    }
    ​

    works fine

    ------------------------------
    ALEX FLEISCHER
    ------------------------------



  • 4.  RE: Conditional sum objective function with decision variable

    Posted Thu May 21, 2020 10:39 AM
    Thank you so much for your reply, it works now! :)

    ------------------------------
    Floor M
    ------------------------------