Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

IloTransitionDistance

  • 1.  IloTransitionDistance

    Posted Wed May 15, 2013 05:36 AM

    Originally posted by: JorisK


    Dear,

    I'm trying to implement a model using ILOG CP (12.5.1)+java interface. My model requires sequence dependent setup times. Whenever I define the following:

    IloTransitionDistance td = cp.transitionDistance(costMatrix);

    my java program crashes with the following exception:

     

    ilog.concert.IloException: X& IloArray::operator[] (IloInt i) : Out of bounds operation: index superior to size of array
    at ilog.concert.cppimpl.concert_wrapJNI.IloIntArray2_set_IloIntArray(Native Method)
    at ilog.concert.cppimpl.IloIntArray2.set_IloIntArray(IloIntArray2.java:57)
    at ilog.concert.cppimpl.IloConcertUtils.ToCppIloIntArray2(IloConcertUtils.java:471)
    at ilog.cp.IloCP.transitionDistance(IloCP.java:8153)
    at algorithms.exact.cp.ModelBuilder.buildrmcp(ModelBuilder.java:129)
    at algorithms.exact.cp.ModelBuilder.<init>(ModelBuilder.java:26)
    at algorithms.exact.cp.CP.<init>(CP.java:16)
    at main.CPTest.<init>(CPTest.java:24)
    at main.CPTest.main(CPTest.java:33)
    Exception in thread "main" java.lang.NullPointerException
    at algorithms.exact.cp.CP.solve(CP.java:22)
    at main.CPTest.<init>(CPTest.java:26)
    at main.CPTest.main(CPTest.java:33)

     

    What could be the cause of this exception? My costMatrix is a 2 dimensional int array where costMatrix[i][j] provides the cost to travel from i to j. The costMatrix only contains non-negative entries.

    This on the other hand does work:

    IloTransitionDistance td =cp.transitionDistance(costMatrix.length);

     

    for(int i=0; i<rmcp.nrOfVertices; i++){
      for(int j=0; j<rmcp.nrOfVertices; j++){
         td.setValue(i, j, costMatrix[i][j]);
      }
    }

     


    #CPOptimizer
    #DecisionOptimization


  • 2.  Re: IloTransitionDistance

    Posted Tue May 21, 2013 06:08 AM

    Originally posted by: PhilippeLaborie


    Hello,

    This is indeed a bug in the Java API when the transition distance is built from a 2-dimensional Java array. The work-around is, as you did, to directly fill the transition distance.

    Thanks for reporting the problem,

    Philippe


    #CPOptimizer
    #DecisionOptimization