Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  OPL run configuration as a background process

    Posted 04/23/18 01:18 PM

    Originally posted by: open_ball


    Hi,

    I`m running a model with oplrun in the background as it is explained here :https://www.ibm.com/support/knowledgecenter/en/SSSA5P_12.6.2/ilog.odms.ide.help/OPL_Studio/refoplide/topics/opl_ideref_proces_launch_oplrun.html

    Since the model is being run in the background, I am not able to see the running time, the optimality gap etc. Is there a way to print these information in the console screen or save as a txt file in the working directory, let's say every 2 hours while the model keeps running.  

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: OPL run configuration as a background process



  • 3.  Re: OPL run configuration as a background process

    Posted 04/29/18 08:29 PM

    Originally posted by: open_ball


    Hi Alex,

    So, I just want to make my question little clearer. I have just one big model and it takes days to solve it. When I use regular run configurations, I receive the following error: "OplRun is not responding, you must relaunch the RunConfig". Therefore, I was launching the run configuration in the background as it is explained in the link that I shared above. 

     

    When I do that, I am not able to see anything while the model is running. When it is finished, the program just gives me the output.

     

    My question is whether it is possible to print out some information like the running time, current status, the optimality gap etc. every 10 minutes while the model is running in the background. The reason is that OPL sometimes keeps running even though the solution is reported as infeasible in the Statistics Module. Since I run the model in the background, I am not able to see if there is infeasibility or if everything is alright. 

     

    When I clicked the link that you sent, it just shows how to call models in parallel. I'm sorry if my question was not clear enough. 


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: OPL run configuration as a background process

    Posted 04/30/18 01:57 AM

    Hi,

    in the link I gave you all the jobs are called in // and in each job you have

    execute
    {
    var o=new IloOplOutputFile("c:\\res"+n+".txt");
    date=new Date();
    o.writeln(date);
    o.writeln(Open);
    o.close();
    }

    which will generate an output file.

    You could do the same in order to get a log.

    By the way you could also use oplrun in command line : https://www.ibm.com/support/knowledgecenter/SSSA5P_12.6.0/ilog.odms.ide.help/OPL_Studio/refoplrun/topics/oplrun_description.html

    Or call CPLEX in the cloud from the studio : https://developer.ibm.com/docloud/try-docloud-free/

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: OPL run configuration as a background process

    Posted 05/04/18 09:11 PM

    Originally posted by: open_ball


    Hi Alex,

     

    Sorry to bother again, but I could not figure out how to do this. If I modify the code block that you sent, wouldn't that be a post process meaning that it would run after completing the model. 

     

    If that would not be a problem for you, can you give me a small example? Suppose we have the portfolio optimization problem  and I want to create a new log file at every ten seconds. 


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: OPL run configuration as a background process

    Posted 05/05/18 04:07 AM

    Hi,

    // --------------------------------------------------------------------------
    // Licensed Materials - Property of IBM
    //
    // 5725-A06 5725-A29 5724-Y48 5724-Y49 5724-Y54 5724-Y55
    // Copyright IBM Corporation 1998, 2013. All Rights Reserved.
    //
    // Note to U.S. Government Users Restricted Rights:
    // Use, duplication or disclosure restricted by GSA ADP Schedule
    // Contract with IBM Corp.
    // --------------------------------------------------------------------------

    // The scalable warehouse example has been artificially increased in size
    // so that the search is long enough for you to have time to interrupt it and look at feasible solutions.
    // The resulting size is greater than the size allowed in trial mode.
    // If you want to run this example, you need a commercial edition of CPLEX Studio to run this example.
    // If you are a student or teacher, you can also get a full version through the IBM Academic Initiative.

    //int n=...;
    //int nbthreads=...;
    int Fixed        = 40;
    int NbWarehouses = 40;
    int NbStores     = 80;


    assert( NbStores > NbWarehouses );

    range Warehouses = 1..NbWarehouses;
    range Stores     = 1..NbStores;
    int Capacity[w in Warehouses] =
      NbStores div NbWarehouses +
      w % ( NbStores div NbWarehouses );
    int SupplyCost[s in Stores][w in Warehouses] =
      1 + ( ( s + 10 * w ) % 100 );
    dvar int Open[Warehouses] in 0..1;
    dvar float Supply[Stores][Warehouses] in 0..1;
    dexpr int TotalFixedCost = sum( w in Warehouses ) Fixed * Open[w];
    dexpr float TotalSupplyCost = sum( w in Warehouses, s in Stores )  SupplyCost[s][w] * Supply[s][w];
    //minimize TotalFixedCost + TotalSupplyCost;
    dvar float obj;
    minimize obj;
    subject to {
    ctObj:obj==TotalFixedCost + TotalSupplyCost;


      forall( s in Stores )
        ctStoreHasOneWarehouse:
          sum( w in Warehouses )
            Supply[s][w] == 1;
      forall( w in Warehouses )
        ctOpen:
          sum( s in Stores )
            Supply[s][w] <= Open[w] * Capacity[w];
    }

    execute
    {
    writeln("Open=",Open);
    }


    main
    {
    thisOplModel.generate();
    var o=new IloOplOutputFile("log.txt")
    cplex.intsollim=1;
    for(var i=1;i<=10;i++)
    {
        

        cplex.solve();
        thisOplModel.postProcess();
        o.writeln("sol ",i);
        o.writeln("getBestObjValue = ",cplex.getBestObjValue());
        o.writeln("getObjValue = ",cplex.getObjValue());
        o.writeln("Open = ",thisOplModel.Open);
        o.writeln();
        
    }
    o.close();
    }

     

    generates log.txt

    sol 1
    getBestObjValue = 1796.666666667
    getObjValue = 1870
    Open =  [1 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1
         1 1 1]

    sol 2
    getBestObjValue = 1796.666666667
    getObjValue = 1820
    Open =  [0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1
         1 1 1]

    sol 3
    getBestObjValue = 1820
    getObjValue = 1820
    Open =  [0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1
         1 1 1]

    sol 4
    getBestObjValue = 1820
    getObjValue = 1820
    Open =  [0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1
         1 1 1]

    sol 5
    getBestObjValue = 1820
    getObjValue = 1820
    Open =  [0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1
         1 1 1]

    sol 6
    getBestObjValue = 1820
    getObjValue = 1820
    Open =  [0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1
         1 1 1]

    sol 7
    getBestObjValue = 1820
    getObjValue = 1820
    Open =  [0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1
         1 1 1]

    sol 8
    getBestObjValue = 1820
    getObjValue = 1820
    Open =  [0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1
         1 1 1]

    sol 9
    getBestObjValue = 1820
    getObjValue = 1820
    Open =  [0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1
         1 1 1]

    sol 10
    getBestObjValue = 1820
    getObjValue = 1820
    Open =  [0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1
         1 1 1]

     

    regards

    https://www.linkedin.com/pulse/puzzles-having-fun-useful-mathematics-alex-fleischer/


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: OPL run configuration as a background process

    Posted 05/05/18 11:02 AM

    Originally posted by: open_ball


    Alex,

     

    I really appreciate, you are the best! This was exactly what I was looking for.

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer