Topic
  • 1 reply
  • Latest Post - ‏2013-05-21T10:07:38Z by PhilippeLaborie
JorisK
JorisK
37 Posts

Pinned topic IloTransitionDistance

‏2013-05-15T09:36:18Z |

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]);
  }
}

 

Updated on 2013-05-15T10:32:28Z at 2013-05-15T10:32:28Z by JorisK
  • PhilippeLaborie
    PhilippeLaborie
    109 Posts

    Re: IloTransitionDistance

    ‏2013-05-21T10:07:38Z  

    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