renhao
2023-09-21 1aa9f2bb83dd9e4b7517f1cbf06b0db53979bb31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Quintiq file version 2.0
#parent: #root
MethodOverride HandleFeasible (
  MathematicalProgram program,
  LibOpt_Task task
) as LibOpt_Scope
{
  TextBody:
  [*
    start := OS::PrecisionCounter(); 
    runcontext := this.GetRunContextConst(); 
    
    isfirsthandlefeasiblecall := this.CurrentSubOptimizerLevel().IsFirst(); 
    isfirstnotlasthandlefeasiblecallatlevelzero := isfirsthandlefeasiblecall and not this.CurrentSubOptimizerLevel().IsLast() and this.CurrentSubOptimizerLevel().LevelNumber() = 0; 
    if ( isfirsthandlefeasiblecall ) // initialize of cplex needs to be const for paralellization. Any non-const processing is moved into the delayed initialization called on return of first handle feasible/infeasible. 
    {
      this.DelayedInitialization( program.astype( CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm ), task, runcontext, true );   
    }
    
    this.LogDetailsCPLEX( program, '', task.Scope() );
    
    qualityok := this.CanRescueSolution( program, task ) 
    passlevelzeroformeta := this.GetRunContextConst().IsMetaIteration() 
                            and  isfirstnotlasthandlefeasiblecallatlevelzero // for meta we are willing to accept lower quality for the fixed level 0. 
                            and not this.GetRunContextMeta().OptionUseHierarchicalCPLEXGoals() // 
    if( qualityok or passlevelzeroformeta )
    {
      this.CapacityPlanningAlgorithmHandleFeasiblePreProcessing( program.astype( CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm ), runcontext, task );
    }
    else
    {
      msg := 'Handle feasible aborted because quality insufficient'; 
      debuginfo( msg ); 
      this.DetailsCPLEX( this.DetailsCPLEX() + msg ); 
      this.HandleInfeasible( program, task ); 
    }
    end := OS::PrecisionCounter(); 
    durationtotal := (end- start) / OS::PrecisionCounterFrequency(); 
    task.Log( 'Duration h-feasible total = ' +[String] durationtotal ); 
    return task.Scope();
  *]
}