| Quintiq file version 2.0 | 
| #parent: #root | 
| Method DefaultScope ( | 
|   LibOpt_Optimizer optimizer | 
| ) as owning LibOpt_ScopeElements | 
| { | 
|   TextBody: | 
|   [* | 
|     scope := construct( LibOpt_ScopeElements ); | 
|      | 
|     settings := optimizer.ActiveSettings().astype( OptimizerSettings );  | 
|     periodstart := minselect( this, MacroPlan.Period_MP, p, not p.IsHistorical(), p.StartDate() );  | 
|     periodend := this.MacroPlan().LastPlanningPeriod();  | 
|      | 
|     periods := this.GetPeriodsForOTS( periodstart, periodend, settings );  | 
|      | 
|     traverse( periods, Elements, p )  | 
|     { | 
|       if ( isnull( p.PeriodInOptimizerRun() ) ) | 
|       { | 
|         p.PeriodInOptimizerRun( relnew );  | 
|       } | 
|       scope.Add( p.PeriodInOptimizerRun() );  | 
|     } | 
|      | 
|      | 
|     traverse( this.GetLaneLegsForOptimization(), Elements, laneleg )  | 
|     { | 
|       if ( isnull( laneleg.LaneLegForOptimization() ) )  | 
|       { | 
|         laneleg.LaneLegForOptimization( relnew );    | 
|       } | 
|       scope.Add( laneleg.LaneLegForOptimization() );  | 
|     } | 
|      | 
|     optacccounts := selectset( this, MacroPlan.Account_MP, account, account.IsUsedByOptimizer() )  | 
|     traverse( optacccounts, Elements, account )  | 
|     { | 
|       if ( isnull ( account.AccountInOptimizerRun() ) ) | 
|       { | 
|         account.AccountInOptimizerRun( relnew );  | 
|       } | 
|       scope.Add( account.AccountInOptimizerRun() );  | 
|     } | 
|      | 
|     puzzle := select( this, MacroPlan.OptimizerPuzzle, puzzle, true, puzzle.Name() = settings.PuzzleName() );  | 
|     if ( isnull( puzzle ) )  | 
|     { | 
|       puzzle := this.MacroPlan().OptimizerPuzzleWorld();  | 
|     } | 
|     if ( isnull( puzzle.OptimizerPuzzleInOptimizerRun() ) ) | 
|     { | 
|       puzzle.OptimizerPuzzleInOptimizerRun( relnew );  | 
|     } | 
|      | 
|     scope.Add( puzzle.OptimizerPuzzleInOptimizerRun() );  | 
|      | 
|     return &scope; | 
|   *] | 
|   InterfaceProperties { Accessibility: 'Module' } | 
| } |