Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Constraint names in DOCplexCloud

    Posted 09/13/18 02:48 PM

    Originally posted by: JaneM


    Can DOCplexCloud provide named constraints for infeasibilities?

    It seems that the DOCplexCloud version for CPLEX returns constraint numbers when there are infeasibilities.

    Infeasibility row 'c3510': 0 <= -1.

    Is there a way for the cloud version to return the constraint name?


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Constraint names in DOCplexCloud

    Posted 09/14/18 08:26 AM

    Hi

    you may use scripting to get that.

    See the example in CPLEX_Studio128\opl\examples\opl\relaxationIterator

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Constraint names in DOCplexCloud

    Posted 09/18/18 06:57 PM

    Originally posted by: JaneM


    I tried using the following based on the example, but it did not work.  

    It gave me errors that all of the variables in the .dat file are not defined.  

    There may be other lines needed as the example does not have a separate .dat file.

     

    Is there some documentation on what this code means.  I tried looking but couldn't find anything.

     

    Thanks, 

    Jane

     

     

    main {

      var status = 0;

      thisOplModel.generate();

    //  thisOplModel.convertAllIntVars();

    //  cplex.solve();

      var plan = thisOplModel;

      var curr;

    //  code for relaxation

      var def = thisOplModel.modelDefinition;

      var cplex1 = new IloCplex();

      var opl1 = new IloOplModel(defcplex1);

      opl1.settings.relaxationLevel=1;

      opl1.generate();

      writeln(opl1.printRelaxation());     

      

      opl1.end();

      cplex1.end();

    }

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Constraint names in DOCplexCloud

    Posted 09/20/18 04:18 PM

    Hi,

    you need to have a model.

    As in the example I gave you.

    Or if you decompose you could have

    simple.mod

    range r = 1..10;
    dvar int+ x[r] in 1..10;
    // Preferences are stated as data of the opl model.
    // prefs[i] will be used to represent the preference of seeing cts[i] in the relaxation.
    float prefs[i in r] = i;

    minimize sum(i in r) x[i];
    subject to {
       ct: sum(i in r) x[i] >= 10;
       forall(i in r)
         cts: x[i] >= i+5;
    }
    tuple xSolutionT{
        int r;
        int value;
    };
    {xSolutionT} xSolution = {<i0,x[i0]> | i0 in r};

    and then you may run main.mod in the cloud

    main {
       var source = new IloOplModelSource("simple.mod");
      var cplex = new IloCplex();
      var def = new IloOplModelDefinition(source);
         
       // Default behavior
       writeln("Default Behavior");
       
       var cplex1 = new IloCplex();
       var opl1 = new IloOplModel(def, cplex1);
       opl1.settings.relaxationLevel=1;
       opl1.generate();
       writeln(opl1.printRelaxation());     
       
       // now iterating manually
       writeln("now iterating manually");
       var iter = opl1.relaxationIterator;  
       for(var c in iter)
       {
         var constraint=c.ct;
         writeln(constraint.name);
         writeln("LB      = ",c.LB);
         writeln("UB      = ",c.UB);
         writeln("relaxedUB      = ",c.relaxedUB);
         writeln("relaxedLB      = ",c.relaxedLB);
       }
     
       opl1.end();
       cplex1.end();
       writeln();
       // With user-defined preferences
       writeln("With user-defined preferences");   
       var cplex2 = new IloCplex();
       var opl2 = new IloOplModel(def, cplex2);
       opl2.generate();
       
       // We attach prefs (defined as data in the opl model) as preferences
       // for constraints cts for the conflict refinement.
       opl2.relaxationIterator.attach(opl2.cts, opl2.prefs);
       writeln(opl2.printRelaxation());        
       opl2.end();
       cplex2.end();
    }

     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Constraint names in DOCplexCloud

    Posted 09/21/18 02:42 PM

    Originally posted by: JaneM


    Yes, I do have a model for this program.  

    Can you please explain what is wrong with what I wrote rather than have me try to compare the differences.  This main statement is part of my model and I have a .dat file that is the actual data and a .ops file. 

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: Constraint names in DOCplexCloud

    Posted 09/21/18 03:21 PM

    Originally posted by: JaneM


    I looked at the IDE Tutorials recommendation that you sent in other communication, the nurses model on relaxation, and it does not work on the cloud.  See output below. 

    My challenge is how to use the relaxation and infeasibility tools on the cloud. 


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: Constraint names in DOCplexCloud

    Posted 09/24/18 06:33 AM

    Hi,

    in your main model you should add

    thisOplModel.settings.names=1;

    because by default models in the cloud have no names.

    For instance, the relaxationiterator example gives

    [2018-09-24T10:30:30Z, INFO] "IloNumVarI#0x7fdb30dfe618 >= 6+5"
    [2018-09-24T10:30:30Z, INFO]     relax [11,Infinity] to [10,Infinity] value is 10
    [2018-09-24T10:30:30Z, INFO] "IloNumVarI#0x7fdb30dfe5e0 >= 7+5"
    [2018-09-24T10:30:30Z, INFO]     relax [12,Infinity] to [10,Infinity] value is 10
    [2018-09-24T10:30:30Z, INFO] "IloNumVarI#0x7fdb30dfe5a8 >= 8+5"
    [2018-09-24T10:30:30Z, INFO]     relax [13,Infinity] to [10,Infinity] value is 10
    [2018-09-24T10:30:30Z, INFO] "IloNumVarI#0x7fdb30dfe570 >= 9+5"
    [2018-09-24T10:30:30Z, INFO]     relax [14,Infinity] to [10,Infinity] value is 10
    [2018-09-24T10:30:30Z, INFO] "IloNumVarI#0x7fdb30dfe538 >= 10+5"
    [2018-09-24T10:30:30Z, INFO]     relax [15,Infinity] to [10,Infinity] value is 10
    [2018-09-24T10:30:30Z, INFO] Script execution finished with status 0.

    in the cloud

     

    but with

    thisOplModel.settings.names=1;

    you ll get

    2018-09-24T10:31:49Z, INFO] cts[6]
    [2018-09-24T10:31:49Z, INFO]     relax [11,Infinity] to [10,Infinity] value is 10
    [2018-09-24T10:31:49Z, INFO] cts[7]
    [2018-09-24T10:31:49Z, INFO]     relax [12,Infinity] to [10,Infinity] value is 10
    [2018-09-24T10:31:49Z, INFO] cts[8]
    [2018-09-24T10:31:49Z, INFO]     relax [13,Infinity] to [10,Infinity] value is 10
    [2018-09-24T10:31:49Z, INFO] cts[9]
    [2018-09-24T10:31:49Z, INFO]     relax [14,Infinity] to [10,Infinity] value is 10
    [2018-09-24T10:31:49Z, INFO] cts[10]
    [2018-09-24T10:31:49Z, INFO]     relax [15,Infinity] to [10,Infinity] value is 10
    [2018-09-24T10:31:49Z, INFO] Script execution finished with status 0.

     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 8.  Re: Constraint names in DOCplexCloud

    Posted 09/24/18 04:47 PM

    Originally posted by: JaneM


     

    Unfortunately, it is not sufficient to just do as you recommended.

    in your main model you should add

    thisOplModel.settings.names=1;

    After reviewing this information and trying many things, I finally tried adding this statement before the .generate statement.  That worked.

     

    I would like to get the relaxation code working, but it seems to be more than adding 

     thisOplModel.settings.relaxationLevel=1;


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 9.  Re: Constraint names in DOCplexCloud

    Posted 09/25/18 02:42 AM

    Hi,

    let me remind you of the meaning of relaxation level:

    relaxationLevel
    Changes the way automatic relaxation of infeasible models is done. Default: 0
    Value 0 means that all variables and labelled constraints can be relaxed. Value 1 means that only labelled constraints can be relaxed.

    Do you mean now your relaxation code does not work the same on prem and in the cloud ?

    Example of what you can do with relaxation : solveanyway

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 10.  Re: Constraint names in DOCplexCloud

    Posted 10/03/18 03:44 PM

    Originally posted by: JaneM


    The solveanyway code looks like it could be beneficial but the explanation is not sufficient for me to figure out. 

     

    As to the recommendations for relaxationLevel, my code doesn't work on my desktop version or in the cloud.   

     

    This main code is in the .mod file, at the end.  The model is in the same .mod file.  The code below is is what I now have and it returns "No solution available" when I run it on my desktop.  In the example at the beginning of this post, it seems that the main file is separate from the .mod file.   In the example, is the code with the main { } also in a .mod file or in something else.

    main {

      var status = 0;

      thisOplModel.settings.names=1;

      thisOplModel.settings.relaxationLevel=0;

      thisOplModel.generate();

     

      var plan = thisOplModel;

      var curr;

    //  code for relaxation

     

    if (cplex.solve() ) {

        curr=cplex.getObjValue();

        writeln();

        writeln("Objective = ", curr);

      }

      else {

        writeln("No solution.");

      }

      thisOplModel.postProcess();

    }


    #DecisionOptimization
    #OPLusingCPLEXOptimizer