Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only

IloMapOutOfBoundException loading 2 dimension loTupleSetMap

  • 1.  IloMapOutOfBoundException loading 2 dimension loTupleSetMap

    Posted 07/06/09 08:47 PM

    Originally posted by: SystemAdmin


    [aacero said:]

    hi everyone

    We have a problem loading OPL model elements of type IloTupleSetMap indexed by IloTupleSet and and IloIntSet from java with Ilog Concert. The situation is as follows:

    1. The definition of the elements concerned in the .mod file is as follows (names are in spanish):

    {int} nMeses=...;

    tuple tFuente{
    key int idFuente;             
    string sNombre;         
    int bPozo;                   
    float fVolIni;               
    int idSFS;                   
    float fCapMaxNom;
    float fCapMinNom;
    float fBenefOrdinario;
    float fBenefComplementario;
    float fCosteFijo;
    float fCapMaxMes[nMeses];
    float fUmbOrdinario[nMeses];
    float fUmbComplementario[nMeses];
    float fAportaciones[nMeses];
    float fCoefVolSup[1..7];
    float fCoefEvap[nMeses];
    }

    {tFuente} Fuentes=...;

    tuple tUmbEstr{
    key int idFase;
    float umbEstrategico;
    float benefEstrategico;
    }

    {tUmbEstr} UmbEstrategicos[Fuentes][nMeses]=...;

    2. This model elements are initialized empty in the .dat file used by the model as follows:

      nMeses= {};
     
     
      Fuentes={};
     
     
    UmbEstrategicos=[];

     
    3. From java using Ilog Concert classes, we load the elements named "nMeses" of type  IloIntSet and element named "Fuentes" of type IloTupleSet without problems (seemingly...), but when we try to assign a value (a new TupleSet with makeTupleBuffer(-1)) to the element named "UmbEstrategicos" of type IloTupleSetMap we get the following exception:

    ===============================================================================
    EVERYTHING SEEMS TO BE OK HERE, 2 ELEMENTS SEEMS TO BE LOADED IN TUPLESET FUENTES
    ===============================================================================
     
    INFO  06.07.2009 11:13:47,544 [main] MapperConverterTest: creado set de tuplas en el modelo
      Fuentes =
      | idFuente || sNombre || bPozo || fVolIni || idSFS || fCapMaxNom || fCapMinNom || fBenefOrdinario || fBenefComplementario || fCosteFijo || fCapMaxMes || fUmbOrdinario || fUmbComplementario || fAportaciones || fCoefVolSup || fCoefEvap |
      {int:2 any:Embalse 2 int:0 num:80 int:1 num:80,4 num:8,4 num:1,5 num:1,5 num:0 any:[4,5, 5,5, 6,5, 7,5, 8,5, 9,5, 10,5, 11,5, 12,5, 1,5,
      2,5, 3,5] any:[4,5, 5,5, 6,5, 7,5, 8,5, 9,5, 10,5, 11,5, 12,5, 1,5,
      2,5, 3,5] any:[4,5, 5,5, 6,5, 7,5, 8,5, 9,5, 10,5, 11,5, 12,5, 1,5,
      2,5, 3,5] any:[16,5, 17,5, 18,5, 19,5, 20,5, 21,5, 22,5, 23,5, 24,5, 25,5,
      26,5, 27,5] any:[1,5, 2,5, 5,5, 4,5, 6,5, 7,5, 3,5] any:[16,5, 17,5, 18,5, 19,5, 20,5, 21,5, 22,5, 23,5, 24,5, 25,5,
      26,5, 27,5] }
      {int:1 any:Embalse 1 int:0 num:100 int:1 num:100,5 num:10,5 num:1,5 num:1,5 num:0 any:[4,5, 5,5, 6,5, 7,5, 8,5, 9,5, 10,5, 11,5, 12,5, 1,5,
      2,5, 3,5] any:[4,5, 5,5, 6,5, 7,5, 8,5, 9,5, 10,5, 11,5, 12,5, 1,5,
      2,5, 3,5] any:[4,5, 5,5, 6,5, 7,5, 8,5, 9,5, 10,5, 11,5, 12,5, 1,5,
      2,5, 3,5] any:[16,5, 17,5, 18,5, 19,5, 20,5, 21,5, 22,5, 23,5, 24,5, 25,5,
      26,5, 27,5] any:[4,5, 7,5, 6,5, 2,5, 5,5, 3,5, 1,5] any:[16,5, 17,5, 18,5, 19,5, 20,5, 21,5, 22,5, 23,5, 24,5, 25,5,
      26,5, 27,5] }
     
     
      ERROR 06.07.2009 11:14:03,495 [main] AbstractIloConverterStrategy: error mapping java.util.HashSet to ilog.concert.cppimpl.IloTupleSetMap
      ilog.concert.IloException: IloMapOutOfBoundException: Out of bounds when accessing element in the map indexed with
      Fuentes =
      | idFuente || sNombre || bPozo || fVolIni || idSFS || fCapMaxNom || fCapMinNom || fBenefOrdinario || fBenefComplementario || fCosteFijo || fCapMaxMes || fUmbOrdinario || fUmbComplementario || fAportaciones || fCoefVolSup || fCoefEvap |
      {int:2 any:Embalse 2 int:0 num:80 int:1 num:80,4 num:8,4 num:1,5 num:1,5 num:0 any:[4,5, 5,5, 6,5, 7,5, 8,5, 9,5, 10,5, 11,5, 12,5, 1,5,
      2,5, 3,5] any:[4,5, 5,5, 6,5, 7,5, 8,5, 9,5, 10,5, 11,5, 12,5, 1,5,
      2,5, 3,5] any:[4,5, 5,5, 6,5, 7,5, 8,5, 9,5, 10,5, 11,5, 12,5, 1,5,
      2,5, 3,5] any:[16,5, 17,5, 18,5, 19,5, 20,5, 21,5, 22,5, 23,5, 24,5, 25,5,
      26,5, 27,5] any:[1,5, 2,5, 5,5, 4,5, 6,5, 7,5, 3,5] any:[16,5, 17,5, 18,5, 19,5, 20,5, 21,5, 22,5, 23,5, 24,5, 25,5,
      26,5, 27,5] }
      {int:1 any:Embalse 1 int:0 num:100 int:1 num:100,5 num:10,5 num:1,5 num:1,5 num:0 any:[4,5, 5,5, 6,5, 7,5, 8,5, 9,5, 10,5, 11,5, 12,5, 1,5,
      2,5, 3,5] any:[4,5, 5,5, 6,5, 7,5, 8,5, 9,5, 10,5, 11,5, 12,5, 1,5,
      2,5, 3,5] any:[4,5, 5,5, 6,5, 7,5, 8,5, 9,5, 10,5, 11,5, 12,5, 1,5,
      2,5, 3,5] any:[16,5, 17,5, 18,5, 19,5, 20,5, 21,5, 22,5, 23,5, 24,5, 25,5,
      26,5, 27,5] any:[4,5, 7,5, 6,5, 2,5, 5,5, 3,5, 1,5] any:[16,5, 17,5, 18,5, 19,5, 20,5, 21,5, 22,5, 23,5, 24,5, 25,5,
      26,5, 27,5] }
     
      with the following mapIndex: {int:1 any:Embalse 1 int:0 num:100 int:1 num:100,5 num:10,5 num:1,5 num:1,5 num:0 any:[4,5, 5,5, 6,5, 7,5, 8,5, 9,5, 10,5, 11,5, 12,5, 1,5,
      2,5, 3,5] any:[4,5, 5,5, 6,5, 7,5, 8,5, 9,5, 10,5, 11,5, 12,5, 1,5,
      2,5, 3,5] any:[4,5, 5,5, 6,5, 7,5, 8,5, 9,5, 10,5, 11,5, 12,5, 1,5,
      2,5, 3,5] any:[16,5, 17,5, 18,5, 19,5, 20,5, 21,5, 22,5, 23,5, 24,5, 25,5,
      26,5, 27,5] any:[4,5, 7,5, 6,5, 2,5, 5,5, 3,5, 1,5] any:[16,5, 17,5, 18,5, 19,5, 20,5, 21,5, 22,5, 23,5, 24,5, 25,5,
      26,5, 27,5] }
     
     
      at ilog.concert.cppimpl.concert_wrapJNI.IloTupleSetMap_getSub_IloTupleSetMap__SWIG_2(Native Method)
      at ilog.concert.cppimpl.IloTupleSetMap.getSub_IloTupleSetMap(IloTupleSetMap.java:101)
      at ilog.concert.cppimpl.IloTupleSetMap.getSub(IloTupleSetMap.java:51)
      at es.cyii.mageryt.mapper.converters.impl.strategies.UmbEstratConverterStrategy.object2opl(UmbEstratConverterStrategy.java:105)
      at es.cyii.mageryt.mapper.converters.base.AbstractIloConverterStrategy.convert(AbstractIloConverterStrategy.java:55)
      at es.cyii.mageryt.mapper.converters.impl.Set2TupleSetMapCustomConverter.set2TupleSetMap(Set2TupleSetMapCustomConverter.java:48)
      at es.cyii.mageryt.mapper.converters.impl.Set2TupleSetMapCustomConverter.convert(Set2TupleSetMapCustomConverter.java:21)
      at net.sf.dozer.util.mapping.MappingProcessor.mapUsingCustomConverterInstance(MappingProcessor.java:864)
      at net.sf.dozer.util.mapping.MappingProcessor.mapUsingCustomConverter(MappingProcessor.java:897)
      at net.sf.dozer.util.mapping.MappingProcessor.map(MappingProcessor.java:146)
      at net.sf.dozer.util.mapping.MappingProcessor.map(MappingProcessor.java:122)
      at net.sf.dozer.util.mapping.MappingProcessor.map(MappingProcessor.java:117)
      at net.sf.dozer.util.mapping.DozerBeanMapper.map(DozerBeanMapper.java:98)
      at es.cyii.copernyco.services.mapper.impl.DozerMapperProvider.map(DozerMapperProvider.java:97)
      at es.cyii.mageryt.mapper.MapperConverterTest.object2TupleSetMap(MapperConverterTest.java:253)
      at es.cyii.mageryt.mapper.MapperConverterTest.object2OPL(MapperConverterTest.java:217)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
      at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:44)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
      at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
      at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)


    As you can see the element passed as index is between the elements used as indexers (!?!?!?) of the first dimension of element "UmbEstrategicos", why do we get an IloMapOutOfBoundException?!?!?

    A sample source code is as follows (this is one of multiple test that we've try..):

    ...
      [color=green]// we get the indexers from tupleSetMap, previously loaded with
    // oplModel.getDataElements.getElement("UmbEstrategicos").asTupleSetMap();[/color]
      IloDiscreteDataCollectionArray mapIndex = tupleSetMap.makeMapIndexer();

      for (Iterator fuenteIter = mapIndex.get(0).iterator(); fuenteIter
      .hasNext();) {
     
      IloTuple tupleFuente = (IloTuple) fuenteIter.next();

      for (Iterator mesesIter = mapIndex.get(1).iterator(); mesesIter
      .hasNext();) {
    [color=green]  // obtenemos el tupleSet asociado a la fuente y al mes y los
      // construimos[/color]
      int mes = (Integer) mesesIter.next();
     
    [color=green]  // ********** at this point is where it crash :( *********[/color]
      tupleSetMap.getSub(tupleFuente).set(mes, null);
                                   
                                      ......


      }
    }
    ...

    What's the right way to write and read elements in a IloTupleSetMap with 2 dimensions, first one a tupleSet and second one an intSet???


    Thank's in advance for your answers...

    bye.
    #CPLEXOptimizers
    #DecisionOptimization