| Quintiq file version 2.0 | 
| #parent: #root | 
| MethodOverride Capture ( | 
|   LibOpt_Task task, | 
|   String comment | 
| ) | 
| { | 
|   TextBody: | 
|   [* | 
|     if ( isnull( task )  )  | 
|     { | 
|       this.CaptureForOTS( task );  | 
|     } | 
|     else | 
|     { | 
|       suboptimizer := guard( task.Component().astype( CapacityPlanningSuboptimizer ), null( CapacityPlanningSuboptimizer ) ); | 
|        | 
|       if ( isnull( suboptimizer ) )  | 
|       { | 
|         r := this.Run();  | 
|         suboptimizer := maxselect( r, Component.astype( CapacityPlanningSuboptimizer ), opt, true, opt.FocusLevel() );  | 
|       } | 
|        | 
|       macroplan := this.Run().Optimization().astype( Optimization ).MacroPlan();  | 
|       runcontext := suboptimizer.GetRunContext();  | 
|       runcontextmeta := suboptimizer.GetRunContextMeta();  | 
|          | 
|       if( not isnull( suboptimizer.RollbackKPI() ) ) | 
|       { | 
|         financialscore := RealVector::Construct();  | 
|         financialposscore := RealVector::Construct();  | 
|         financial_descr := '';  | 
|         rollbackkpi := suboptimizer.RollbackKPI().astype(  RollbackKPIMeta ).GetKPI( task, financialscore, financialposscore, financial_descr );  | 
|          | 
|         this.RollbackKPI( rollbackkpi.AsBinaryValue() ); | 
|         this.RollBackKPIFinancialTerms( financialscore.AsBinaryValue() );  | 
|         this.RollBackKPIFinancialTermsPositive( financialposscore.AsBinaryValue() );  | 
|         this.RollBackKPIFinancialDescription( financial_descr );  | 
|       } | 
|       // some custome snapshot info  | 
|        | 
|       if ( not isnull( runcontextmeta ) ) // not every run is meta | 
|       { | 
|         this.Capture( runcontextmeta );  | 
|         pits := sum( macroplan, Unit.Lane.LaneLeg.Trip, trip, trip.GetIsValidNonFrozenTrip(), trip.ProductInTrip( relsize ) );  | 
|         pto := sum(  macroplan, Unit.Operation, op, true, op.PeriodTaskOperation( relsize ) );  | 
|         this.NrProductInTripGlobal( pits );  | 
|         this.NrOperationPeriodTaskInGlobal( pto );  | 
|         nrcombis := counter(  macroplan, Optimization.CampaignCombiGeneration.OptCampaign.OptCampaignUnit.OptCampaignUnitSubPeriod.OptCampaignCombiActive, c, true, true );  | 
|         nrcombisall := sum(   macroplan, Optimization.CampaignCombiGeneration.OptCampaign.OptCampaignUnit.OptCampaignUnitSubPeriod, ocusp, true, ocusp.OptCampaignCombi( relsize ) );  | 
|         nrcombisselected := counter(  macroplan, Optimization.CampaignCombiGeneration.OptCampaign.OptCampaignUnit.OptCampaignUnitSubPeriod.OptCampaignCombiSelected, c, true, true );  | 
|         this.NrCampaignSequenceCombisActive( nrcombis );  | 
|         this.NrCampaignSequenceCombisSelected( nrcombisselected );  | 
|         this.NrCampaignSequenceCombisTotal( nrcombisall );  | 
|       } | 
|        | 
|       this.Capture (suboptimizer );  | 
|        | 
|       if ( isnull( suboptimizer.CurrentSubOptimizerLevel() )                  // when we are done the sub optimizer level will point to null | 
|            or this.Run().Optimization().astype( Optimization ).DebugMode()   | 
|            or not runcontext.IsMetaIteration() ) | 
|       { | 
|         this.CaptureMacroPlanKPIs( runcontext, suboptimizer, task.Scope() );  | 
|       } | 
|        | 
|       if ( not isnull( runcontext ) )  | 
|       { | 
|         this.Capture ( runcontext );  | 
|       } | 
|        | 
|       this.Capture(  task.Scope() ); | 
|        | 
|       traverse( macroplan, Optimization.AlgorithmScaling.ScaleFactor, sf )  | 
|       { | 
|         if ( sf.Type() = Optimization::ScalingTypeNameInventoryHolding() )  | 
|         { | 
|           this.ScalingFactorInventoryHolding( sf.Value() );  | 
|         } | 
|         else if ( sf.Type() = Optimization::ScalingTypeNameMass() )  | 
|         { | 
|           this.ScalingFactorMass( sf.Value() );  | 
|         } | 
|         else if ( sf.Type() = Optimization::ScalingTypeNameMonetary() )  | 
|         { | 
|           this.ScalingFactorMonetary( sf.Value() );  | 
|         } | 
|         else if ( sf.Type()= Optimization::ScalingTypeNameTime() )  | 
|         { | 
|           this.ScalingFactorTime( sf.Value() );    | 
|         } | 
|         else if ( sf.Type() = Optimization::ScalingTypeNameTimeAccount() )  | 
|         { | 
|           this.ScalingFactorTimeAccount( sf.Value() );  | 
|         } | 
|       }  | 
|        | 
|       if ( runcontext.IsOTS() )  | 
|       { | 
|         this.CaptureForOTS( task ); // ensure all KPI are recorded (expensive) | 
|       }  | 
|     } | 
|     this.Comment( comment ); // note that is need to be set for OTS just as input argument is given in order to correctly set target values | 
|   *] | 
| } |