Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Regenerating opl Model to Solve

    Posted Thu December 31, 2015 07:09 PM

    Originally posted by: naveendivakaran


    Hi,

    I am trying to run a 2nd solve on a model that is basically a modified version of the original model, in which I have to modify the coefficients of an array of variables in a constraint. I am trying to do that without having to run the generate function. The way I tried to do this is:

     

    for(var i in opl.setWW)

            {

                opl.ctBacklog[i].UB = 1000;

                iconst = Math.ceil((opl.ObjWeeklyBacklog[i])*1/scale_factor);

                opl.ctScaled_Backlog[i].setCoef(opl.Scaled_ObjBacklog[i],-iconst);

                

            }

    where ctBacklog and ctScaled_Backlog are constraints on array of variables. I get a "No Solutions Error" when it is trying to run this for loop. What am I doing wrong? The approach that I am taking to meet my goal for now is to create a fresh opl object after the first solve, and modify coefficients there which works fine. But I have to generate the model which consumes 3 minutes, that I would like to avoid. Please let me know if there is a way without having to run the generate method.

     

    Method that works: (which requires regeneration 3 extra minutes)

     

                 vardef2 = opl.modelDefinition;

                 var data2 = opl.dataElements;

                 var cplex2 = new IloCplex();

                 var opl2 = new IloOplModel(def2,cplex2);        

                 opl2.addDataSource(data2); 

                    

            for(var i6 in opl.setWW)

            {

                opl2.ctBacklog[i6].UB = scale_factor+ub_tolerance;

                iconst = Math.ceil((opl.ObjWeeklyBacklog[i6])*1/scale_factor);

                opl2.ctScaled_Backlog[i6].setCoef(opl2.Scaled_ObjBacklog[i6],-iconst);

                

            }

     

    Please help me with this task.

     

    -Naveen

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Regenerating opl Model to Solve



  • 3.  Re: Regenerating opl Model to Solve

    Posted Sat January 02, 2016 03:11 PM

    Originally posted by: naveendivakaran


    Hi,
    I read the examples. I dont think it addresses what I am  looking for. Maybe a simple mod and dat file can explain what I am looking for. Let me know if it makes sense. It is just a dumb problem to explain what I am trying, as I cannot share my entire problem which is pretty huge.
    I have attached a Trial.mod, and Trial.dat file here. So here I am trying to get the results of the first solve and update the coefficients of a constraint in the original model with the first solve results, after updating the Upper Bound on another constraint. It gives the error: 

    Exception from IBM ILOG CPLEX: CPLEX Error  1217: No solution exists.    

    I hope you can understand what I am trying to do in the main script. What is the best way to achieve it without having to create a fresh opl model and running the generate function?
    Your help on this is greatly appreciated. Happy New Year!!
    -Naveen


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Regenerating opl Model to Solve

    Posted Mon January 04, 2016 09:01 AM

    Hi,

    let me apply what I meant in your example. (See attached trial.mod)

    What I did is store in temp the values before changing the coeffiients:

    for(var i7 in thisOplModel.setWW)
      thisOplModel.temp[i7]=Math.ceil((thisOplModel.a[i7]));
     
     
      for(var i7 in thisOplModel.setWW)
        {
            thisOplModel.ctPain[i7].UB = 100;
            writeln("attempt: ",i7)
            iconst = thisOplModel.temp[i7]; //Math.ceil((thisOplModel.a[i7]));
            thisOplModel.ctScaledPain[i7].setCoef(thisOplModel.a[i7],-iconst);
            
        }

    regards

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Regenerating opl Model to Solve

    Posted Mon January 04, 2016 10:47 AM

    Originally posted by: naveendivakaran


    Awesome!!

    Thank you very much. Can you also shed some light to why I need a temp variable? Just so that I understand the need for this solution?

    -Naveen


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: Regenerating opl Model to Solve

    Posted Mon January 04, 2016 10:59 AM

    Hi,

    modifying a model will invalidate all previous model solution structures: including thedecision variable data, and any post-processing data. 

    So as soon as you do

    thisOplModel.ctPain[i7].UB

    you cannot read

    thisOplModel.a[i7]

    any longer.

    That is why you need a temporary structure like temp

    regards

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: Regenerating opl Model to Solve

    Posted Mon January 04, 2016 11:02 AM

    Originally posted by: naveendivakaran


    Fantabulous!! Thank you very much!!


    #DecisionOptimization
    #OPLusingCPLEXOptimizer