Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  How to write true-false constraint in java?

    Posted 09/15/15 03:35 AM

    Originally posted by: hacimehmet


    Hi,

    I want to write the following code block with java. Can anyone help me?

    Especially part of (stationNumber[i]==j)). I cannot write this true or false part.

     

    In this code block, tasktime is an integer array, stastionNumber is a decision variable, stationtime is a decision variable. models, stations and tasks are ranges.

     

    forall(m in models,j in stations){

    sum (i in tasks) (taskTime[m][i] * (stationNumber[i]==j)) == stationtime[m][j];

    }

    Thank you in advance.


    #ConstraintProgramming-General
    #DecisionOptimization


  • 2.  Re: How to write true-false constraint in java?

    Posted 09/15/15 10:25 AM

    Originally posted by: ChrisBr


    Hello,

    You might try:

    for (int m = 0; m < models; m++)
      for (int j = 0; j < stations; j++) {
        IloIntExpr expr = cp.intExpr();
        for (int i = 0; i < tasks; i++)
          expr = cp.sum(expr, cp.prod(taskTime[m][i], cp.eq(stationNumber[i],j)));
        cp.add(cp.eq(expr, stationtime[m][j]));
      }
    

    I hope this helps,

    Chris.


    #ConstraintProgramming-General
    #DecisionOptimization


  • 3.  Re: How to write true-false constraint in java?

    Posted 09/16/15 04:03 AM

    Originally posted by: hacimehmet


    Thanks for your help Chris. This is my first code trying to write in java. I cannot understand some errors.

     In this part of code, it didn't give an error first time. But when i run the code it gave the following error. How can i correct the code.

     

    java.lang.RuntimeException: internal error: bad cast

    at ilog.concert.cppimpl.IloConcertUtils.ToCppIloIntExpr(IloConcertUtils.java:274)

    at ilog.cp.IloCP.eq(IloCP.java:3292)

    at example01.Karma_modelli_MHDP.main(Karma_modelli_MHDP.java:55)

     

    55. row is as follows:

    expr = cp.sum(expr, cp.prod(tasktime[m][i], cp.eq(stationnumber[i],j)));


    #ConstraintProgramming-General
    #DecisionOptimization


  • 4.  Re: How to write true-false constraint in java?

    Posted 09/17/15 04:49 AM

    Originally posted by: hacimehmet


    I solved the problem, thanks again for your help Chris.

    I made a mistake at defining variables. Now, It is OK.


    #ConstraintProgramming-General
    #DecisionOptimization