Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
4 replies Latest Post - ‏2013-09-27T18:06:15Z by outlookeye
outlookeye
outlookeye
17 Posts
ACCEPTED ANSWER

Pinned topic Is there a way to show/display the intermediate solutions while running the OPL?

‏2013-09-26T15:11:25Z |

I think the OPL will generate a series of intermediate results while looking for the optimal solutions for the problem. So is there a way that the series of intermediate results of the decision variables can be displayed while the OPL is running, but not complete?

Or I must set a running time, when the running stops according to the running time, the current intermediate solutions show up?

 

Thanks

  • AlexFleischer
    AlexFleischer
    1126 Posts
    ACCEPTED ANSWER

    Re: Is there a way to show/display the intermediate solutions while running the OPL?

    ‏2013-09-26T16:30:21Z  in response to outlookeye

    Hi,

    have you tried the setting

    Postprocess feasible solutions

    Specifies that the postprocessing script is applied to feasible solutions found before the final solution as well as to the final solution itself.

     

    regards

    • outlookeye
      outlookeye
      17 Posts
      ACCEPTED ANSWER

      Re: Is there a way to show/display the intermediate solutions while running the OPL?

      ‏2013-09-26T20:42:27Z  in response to AlexFleischer

      Hi Alex,

      Thank you for your response.

      I tried, but it seems the feasible solutions will be displayed in the "script log" only after the running is complete. Since the running takes to long time, so I want to check the feasible solutions during the running sometime.

      Previous I tried to terminate the running by setting the running time:

      execute {
        cplex.tilim = 600;
        }

      another way is:

      main{
        thisOplModel.generate();
        cplex.tilim = 600;
        cplex.solve();
        }

      But both ways don't work. The program doesn't end in 10mins. I use OLP IDE under ubuntu.

      Thanks

      Pan

      • AlexFleischer
        AlexFleischer
        1126 Posts
        ACCEPTED ANSWER

        Re: Is there a way to show/display the intermediate solutions while running the OPL?

        ‏2013-09-27T08:52:46Z  in response to outlookeye

        Hi,

        with the setting I gave you, you have to do a writeln in the postprocess part.

        Have you done that ?

         

        For example with this setting

        int Fixed        = 10;
        int NbWarehouses = 50;
        int NbStores     = 2000;

        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;

        subject to {
          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
        {
          var d=new Date();
          writeln("at date ",d," obj=",TotalFixedCost + TotalSupplyCost);
        }  
         

         

        gives

        // feasible solution with objective 104730
        at date 09/27/2013 10:48:38 573 obj=104730
        // feasible solution with objective 11410
        at date 09/27/2013 10:48:40 642 obj=11410
        // feasible solution with objective 11400
        at date 09/27/2013 10:48:42 378 obj=11400
        // feasible solution with objective 11380
        at date 09/27/2013 10:48:43 886 obj=11380
        // feasible solution with objective 11370
        at date 09/27/2013 10:48:45 068 obj=11370

         

        whereas without the setting it gives

         

        // solution (integer optimal, tolerance) with objective 11370
        at date 09/27/2013 10:52:06 002 obj=11370

         

        regards

         

         

        • outlookeye
          outlookeye
          17 Posts
          ACCEPTED ANSWER

          Re: Is there a way to show/display the intermediate solutions while running the OPL?

          ‏2013-09-27T18:06:15Z  in response to AlexFleischer

          Thanks Alex. I add writeln part in the postprocessing, and it works!

          Another question: I would like to terminate the OPL executing after a specific time, and what I have done is to add the codes in the postprocessing like this: (both ways are found in this forum or the user manual)

          execute {
            cplex.tilim = 600;
            }

          or another way is:

          main{
            thisOplModel.generate();
            cplex.tilim = 600;
            cplex.solve();
            }

           

          but both don't work. Could you please indicate where's the problem?