Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Modulo

    Posted 06/28/12 09:48 AM

    Originally posted by: scubla88


    Hi,
    I'm a new user of CPLEX. I'm trying to model the CARP (The Capacitated ARC Routing Problem).
    I have a problem about a constraint. I want to do a sum of x[i][k][v] in a loop.
    I'm using c++, and I wrote this code:

    for(v=0;v<veicoli;v++){
    for(i=0;i<vertici;i++){
    IloExpr somma(env);

    for(int k=0;k<vertici;k++){
    somma+=x[i][k][v];
    }

    model.add(somma%2==0); // ???????
    somma.end();
    }

    I want the sum is even, but I have not found the operator "modulo" on the IloExpr, but only on IloIntExprArg but i can not use it.

    Can anyone help me???? Thank you very much!!!
    #ConstraintProgramming-General
    #DecisionOptimization


  • 2.  Re: Modulo

    Posted 07/04/12 03:52 AM

    Originally posted by: SystemAdmin


    The modulo operator (%) is defined only on integer expressions. In your code, you need to declare somma as an IloIntExpr and not as an IloExpr, like this: IloIntExpr somma(env).

    Regards

    Philippe
    #ConstraintProgramming-General
    #DecisionOptimization