Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
Expand all | Collapse all

Set time limit in OPL model

  • 1.  Set time limit in OPL model

    Posted 04/01/17 03:31 AM

    Originally posted by: TRAN Van Ut


    Hello,

    Could you please help me, how to set time limit to slove this problem.

    Moreover, I want to have:

    timelimit =10 seconds

    if timeslove > 10 then:

         Intime = 1

         return the solution if it has

    Else   

         Intime = 0

         return the solution

    Thanks in advance for your help

    This is my code:

    /*********************************************
     * OPL 12.6.1.0 Model 
     *********************************************/
    using CPLEX;
    // Number of Jobs
    int nbJobs = ...;
    int LmaxStar = ...;
    range Process = 1..nbJobs;
    int p     [Process] = ...;
    int d     [Process] = ...;
    int w     [Process] = ...;
    dvar int P     [Process];
    dvar boolean x[Process][Process];
    dvar int+ h;
    minimize h;
    subject to
    {    
        forall(k in Process)
          sum(j in Process) x[j][k] == 1;                           
        forall(j in Process)
          sum(k in Process) x[j][k] == 1;                          
        forall (k in Process)
            sum(j in Process,l in 1..k ) (p[j] * x[j][l])- sum(j in Process)(d[j]*x[j][k]) <= LmaxStar;
         forall(j in Process)
          P[j] == sum(k in Process) k * x[j][k];
        sum(j in Process) w[j] * P[j] == h;
    }
    execute
    {
        cplex.tilim = 10; / / >>>>>> it not work
        var f=new IloOplOutputFile("A.txt");
        f.write(h + "      ");
        for(var j=1; j <= nbJobs; j++)
            for(var k=1; k <= nbJobs; k++)
            {    if (x[j][k] > 0)
                    f.write(x[j][k]*k+" ")
            }
        f.close();


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Set time limit in OPL model

    Posted 04/01/17 05:43 AM

    Hi

    execute
    {
        cplex.tilim = 10;

    )

    should be before the subject to block

    regards

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer