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

Pinned topic IloTransitionDistance

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


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(
at ilog.concert.cppimpl.IloConcertUtils.ToCppIloIntArray2(
at ilog.cp.IloCP.transitionDistance(
at algorithms.exact.cp.ModelBuilder.buildrmcp(
at algorithms.exact.cp.ModelBuilder.<init>(
at algorithms.exact.cp.CP.<init>(
at main.CPTest.<init>(
at main.CPTest.main(
Exception in thread "main" java.lang.NullPointerException
at algorithms.exact.cp.CP.solve(
at main.CPTest.<init>(
at main.CPTest.main(


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
    118 Posts

    Re: IloTransitionDistance



    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,