Decision Optimization

Decision Optimization

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


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

    Posted 12/09/15 04:32 AM

    Originally posted by: ouaigooo


    Hi

    Post-processing sometimes crashes when accessing "dexpr" after having called convertAllIntVars().

    Exception from IBM ILOG Concert: convertAllIntVars() is not supported for this dexpr element.
    

    What are the rules to respect in order to avoid this ?

    Thanks for your help !


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: convertAllIntVars

    Posted 12/09/15 10:17 AM

    Hi,

    let me give you an example derived from the convert example that works:

    dvar int x in 0..10;

    dexpr float y=2*x;
    minimize x;
    subject to {
      ct :   
        x >= 1/2;
    }

    execute
    {
    writeln("x=",x);

    writeln("y=",y);
    }

    main {
      var status = 0;
      thisOplModel.generate();
      if (cplex.solve()) {
        writeln("Integer Model");   
        writeln("OBJECTIVE: ",cplex.getObjValue());  
        thisOplModel.postProcess() ;
        if (cplex.getObjValue() != 1) {
          status = -1;
        }
      }

      thisOplModel.convertAllIntVars();
      if (cplex.solve()) {
        writeln("Relaxed Model");   
        writeln("OBJECTIVE: ",cplex.getObjValue());  
        //thisOplModel.postProcess() ;  // indeed uncommenting this breaks
        if (cplex.getObjValue() != 0.5) {
          status = -1;
        }
      }
       
      thisOplModel.unconvertAllIntVars();
      if (cplex.solve()) {
        writeln("Unrelaxed Model");   
        writeln("OBJECTIVE: ",cplex.getObjValue());
        thisOplModel.postProcess() ;
        if (cplex.getObjValue() != 1) {
          status = -1;
        }
      }
      status;
    }

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: convertAllIntVars

    Posted 12/09/15 10:30 AM

    Originally posted by: ouaigooo


    Thanks, but it doesn't help that much.

    I could indeed expect that there exist examples where it works.

    But the question is: why it doesn't work in my case ?

    With the subsidary question: when does it work and when not ?

     

    Here is more info about my code:

    It crashes in an execute block (post-processing):

    for (var t in OPTSTEPS) f.writeln(t.start + ";" + t.stop + ";" + TIME_STAMP[t] + ";" + power_el[i][t]);

     

    In the model file, we have:

    dvar float boiler_Pel[BOILERS,SCENARII,BSTEPS] in -10..10;

    dvar float+ machine_power_var[MACHINES diff BOILERS][SCENARII][OPTSTEPS];
    dexpr float machine_power[x in MACHINES][i in SCENARII][t in OPTSTEPS] =
     ((x in BOILERS) ? boiler_Pel[x,i,Bstep[t]] : machine_power_var[x,i,t]);

    dexpr float power_el[i in SCENARII][o in OPTSTEPS] = 0
        + sum(x in RESIDUAL_POWER: (o.start < x.stop) && (o.stop > x.start)) x.value * (minl(o.stop, x.stop) - maxl(o.start, x.start)) / (o.stop - o.start)
        + sum(x in MACHINES) item(MACHINE_SIGN,<x>).value * machine_power[x,i,o]
    ;

    RESIDUAL_POWER is pure data.

    Any guess why it crashes and how I could adapt ?

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: convertAllIntVars

    Posted 12/10/15 02:24 AM

    Hi,

    the issue is with dexpr float that relates to dvar int so a workaround is to use dvar float vars in order to help.

    Let me give you an example that works fine:

    dvar int x in 0..10;
    dvar float fx in 0..10;

    dexpr float y=2*fx;
    minimize x;
    subject to {
    fx==x;

      ct :   
        x >= 1/2;
    }

    execute
    {
    writeln("x=",x);

    writeln("y=",y);
    }

    main {
      var status = 0;
      thisOplModel.generate();
      if (cplex.solve()) {
        writeln("Integer Model");   
        writeln("OBJECTIVE: ",cplex.getObjValue());  
        thisOplModel.postProcess() ;
        if (cplex.getObjValue() != 1) {
          status = -1;
        }
      }

      thisOplModel.convertAllIntVars();
      if (cplex.solve()) {
        writeln("Relaxed Model");   
        writeln("OBJECTIVE: ",cplex.getObjValue());  
        thisOplModel.postProcess() ;
        if (cplex.getObjValue() != 0.5) {
          status = -1;
        }
      }
       
      thisOplModel.unconvertAllIntVars();
      if (cplex.solve()) {
        writeln("Unrelaxed Model");   
        writeln("OBJECTIVE: ",cplex.getObjValue());
        thisOplModel.postProcess() ;
        if (cplex.getObjValue() != 1) {
          status = -1;
        }
      }
      status;
    }

     

    which gives

     

    Integer Model
    OBJECTIVE: 1
    x=1
    y=2
    Relaxed Model
    OBJECTIVE: 0.5
    x=0.5
    y=1
    Unrelaxed Model
    OBJECTIVE: 1
    x=1
    y=2

     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: convertAllIntVars

    Posted 12/10/15 02:51 AM

    Originally posted by: ouaigooo


    Hi Alex,

    You said:

    the issue is with dexpr float that relates to dvar int so a workaround is to use dvar float vars in order to help.

    I'm afraid we don't speak about the same.

    By "my case", I mean my problem, not your example.

    There is no dvar int in my code.

    Can you help to answer the 2 questions:

    But the question is: why it doesn't work in my case ?

    With the subsidary question: when does it work and when not ?

    or shall I report (again) to CPLEX support ?

    Regards

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: convertAllIntVars

    Posted 12/10/15 03:54 AM

    Hi,

    since you wrote that

    convertAllIntVars().

    did not work I thought some dvar int were involved.

    About

            But the question is: why it doesn't work in my case ?

            With the subsidary question: when does it work and when not ?

    It is quite hard to answer without a full example that does not work.

    What you could try as a workaround is to replace convertAllIntVars() by some other way of linear relaxation.

    Any way, the most efficient way to get an answer is always to open a PMR though support

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: convertAllIntVars

    Posted 12/10/15 04:19 AM

    Originally posted by: ouaigooo


    I'll open a PMR. Thanks for your help anyway !
     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer