| Quintiq file version 2.0 | 
| #parent: #root | 
| Method SetCPLEXParametersNonHierarchicalGoal ( | 
|   MathematicalProgram program, | 
|   const StrategyLevelMacroPlan runlevel, | 
|   const LibOpt_Scope scope | 
| ) const | 
| { | 
|   Description: 'Set the parameters (time limit, gap, etc) of the optimizer, according to setting per iteration' | 
|   TextBody: | 
|   [* | 
|     // soh yee Jul-2-2013 (created) | 
|     // ResetParameters is removing all parameters that were set by AddBooleanParameter, AddNumberParameter, AddRealParameter, AddStringParameter. | 
|     // That includes the AbsoluteGap and RelativeGap that we set below with AddRealParameter | 
|      | 
|     assert( not this.UseHierarchicalCPLEXGoals(), 'not expecting this code to be executed for multi-level cplex ' )  | 
|      | 
|     runcontext := this.GetRunContextConst();  | 
|     rcm := this.GetRunContextMeta(); | 
|      | 
|     if ( runcontext.IsMetaIteration() )  | 
|     { | 
|       if ( runcontext.GetIsMIP() )  | 
|       { | 
|         program.AddRealParameter( 2010, rcm.OptionIntegralityTolerance() ); // use default for meta unless user sets it explicitly | 
|         if ( not runcontext.UseShiftOptimization() or this.IsHardShiftOptimizationLevel( runcontext, scope ) )  | 
|         {     | 
|           program.AddRealParameter( 2009, rcm.OptionRelativeMIPGap() ); // use default for meta unless user sets it explicitly  | 
|         } | 
|       }     | 
|     } | 
|     else | 
|     { | 
|       if( runlevel.UseAbsoluteGap() ) | 
|       { | 
|         program.AddRealParameter( 2008, runlevel.AbsoluteGap() );      // absolute gap tolerance | 
|         program.AddRealParameter( 2009, 0.0 ); // explicitly must set rel gap to 0, otherwise solver can still terminate early based on that  | 
|       } | 
|       else | 
|       { | 
|         program.AddRealParameter( 2009, runlevel.RelativeGap() );      // relative gap tolerance | 
|         program.AddRealParameter( 2008, 0.0 ); // explicitly must set abs gap to 0, otherwise solver can still terminate early based on that  | 
|       } | 
|     } | 
|      | 
|     this.ActivateSolverSettings( program, runlevel );        // activate the solver settings for the next level | 
|      | 
|     timelimit := [Real]runlevel.TimeLimit(); | 
|     if ( runcontext.IsMetaIteration() and not this.IsFullPlanMetaPriorFocus() )  | 
|     { | 
|       factor := 4;  | 
|       timelimit := factor * rcm.OptionMaxTimePerIterationSeconds(); // set time out to be 'factor' X the target time used for tuning | 
|       debuginfo(  'Time out cplex:', timelimit );  | 
|     } | 
|     program.TimeLimit( timelimit );                    // time limit | 
|      | 
|     if( runcontext.IsForBenchmarking() )     // For total time limit of the benchmarking execution | 
|     { | 
|       if ( program.Threads() > runcontext.MaxNumberOfThreadsForBenchmarking() )  | 
|       { | 
|          | 
|         program.Threads( runcontext.MaxNumberOfThreadsForBenchmarking() );  | 
|       } | 
|     } | 
|      | 
|     maxthreadsglobal := ifexpr( this.MacroPlan().IsSizingParameterOn(), this.MacroPlan().ResourceManager_MP().MaxThreadForOptimization(), Number::MaxNumber() );  | 
|     program.Threads( minvalue( program.Threads(), maxthreadsglobal ) ); // limit by sizing parameter setting | 
|     program.AddNumberParameter( 1067, program.Threads() ); // otherwise CPLEX log shows thread parameter is not used | 
|      | 
|     debuginfo(  'program.Threads() = ', program.Threads() ); | 
|   *] | 
|   InterfaceProperties { Accessibility: 'Module' } | 
| } |