Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Implementation of max() with a linear expression?

    Posted 07/21/10 10:06 AM

    Originally posted by: Haschmir


    Hello everyone,

    i hope you can helb me! My task is to implement a DLSP model with cplex in java. Now i have the problem that the expression to minimize the objective includes the following:

    Sum over two indices(k,t) of

    (double[k] s * max(0, (IloIntVar[k][t] v - IloIntVar[k]t-1 v)) + double [k] h * IloIntVar[k][t] y)

    Important: v[k][t] is initialized as a boolVarArray.

    Remark: This is only Pseudocode, so you know what kind of type my variables are. I hope you can understand my notation.

    Back to my problem: How to imlement the max()-function? In my case i have to sum a lot of expressions, so i think i need a linear expression to add all these. But in that case, i can't use cplex.max().

    I also tried a combination of four cplex.ifThen() where r[k][t] is a variable of the Typ IloIntVar (boolVarArray) and replaces the whole max()-function in my objective expression:

    cplex.ifThen(cplex.and(cplex.eq(y[k][t],1), cplex.eq(y[k]t-1,0)),cplex.eq(r[k][t],1));
    cplex.ifThen(cplex.and(cplex.eq(y[k][t],1), cplex.eq(y[k]t-1,1)),cplex.eq(r[k][t],0));
    cplex.ifThen(cplex.and(cplex.eq(y[k][t],0), cplex.eq(y[k]t-1,1)),cplex.eq(r[k][t],0));
    cplex.ifThen(cplex.and(cplex.eq(y[k][t],0), cplex.eq(y[k]t-1,0)),cplex.eq(r[k][t],0));

    The constraints are not listed in my LP, so i think this attempt of mine has failed too...

    I really hope you have any idea or solution to handle my Problem!

    If i missed any relevant threads already existing, i'm sorry, but i couldn't find something helping me. In case i forgot important informtions, pardon me, its my first time asking for help. :)

    Kind regards and thanking you in anticipation,

    Tobias
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Implementation of max() with a linear expression?

    Posted 07/21/10 03:13 PM

    Originally posted by: SystemAdmin


    If the coefficient s is positive, this is fairly easy. Define a new variable array
    z[][] >= 0,
    
    constrain
    z[k][t] >= v[k][t] - v[k][t-1],
    
    and use
    s*z[k][t]
    
    in the objective. If s is not positive (negative if you decide to maximize), you'll need to introduce binary variables.

    /Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Implementation of max() with a linear expression?

    Posted 07/21/10 04:41 PM

    Originally posted by: Haschmir


    Paul, thank you sooo much! You can't believe what kind of constraints i built...and nothing was so simple and correct like yours. ;) I haven't implemented it yet, but i can follow your idea and it makes sense!

    Thank you one more time!

    Kind Regards,

    Tobias
    #CPLEXOptimizers
    #DecisionOptimization