| Quintiq file version 2.0 | 
| #parent: #root | 
| Method InitConstraintsGoalsForDriverOneTime ( | 
|   CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program, | 
|   const RunContextForCapacityPlanning runcontext, | 
|   const LibOpt_Scope scope | 
| ) const | 
| { | 
|   Description: 'Init constraints goals for account depends on one time cost' | 
|   TextBody: | 
|   [* | 
|     // One time cost accounts | 
|      | 
|      | 
|     ptisused_varname := typeof( MPPTIsUsedVariable ); | 
|     driveronetime_varname := typeof( MPDriverOneTimeVariable ); | 
|     driveronetime_constname := typeof( MPDriverOneTimeConstraint ); | 
|      | 
|     scalefactor_driver_dconst := this.ScaleConstraintTerm( driveronetime_varname, driveronetime_constname ); | 
|     scalefactor_ptisused_dconst := this.ScaleConstraintTerm( ptisused_varname, driveronetime_constname ); | 
|      | 
|     scalefactor_rhs_dconst := this.ScaleConstraintRHS( driveronetime_constname, 1.0 ); | 
|      | 
|     driver := select( this, MacroPlan.AccountCostDriver, driver, driver.Name() = Translations::MP_AccountAssignmentCostDriverOneTime() ); | 
|     traverse( scope.GetAccountsInOptimizerRunConst(), Elements, account, account.HasOneTimeAssignment() ) | 
|     { | 
|       // dcconst constraint UoM: Monetary | 
|       dcconst := program.DriverOneTimeConstraints().New( account, driver ); | 
|       dcconst.Sense( '=' ); | 
|       dcconst.RHSValue( 0.0 * scalefactor_rhs_dconst ); | 
|       // Term UoM: Monetary | 
|       dcconst.NewTerm( 1.0 * scalefactor_driver_dconst, program.DriverOneTimeVariables().Get( account, driver ) ); | 
|      | 
|       if ( runcontext.UseOneTimeCost() )  | 
|       { | 
|         traverse( account, AccountAssignment, aa, aa.AccountCostDriver() = driver and aa.AccountCost( relsize ) > 0  ) | 
|         { | 
|           // Operation (only include those that are part of this optimizer run and related to a unit period that is part of this optimizer run) | 
|           traverse( aa, astype( UnitAccount ).UnitAccountInPeriodForOneTimeCost.UnitPeriod, up, | 
|                     scope.Contains(  up.UnitPeriodInOptimizerRun() ) ) | 
|           { | 
|             traverse( up, Unit.OperationForOptimizationInScope, operation, operation.HasOneTimeCost() )  | 
|             { | 
|               cost := operation.GetBaseOneTimeCost( aa, up ); | 
|               isusedvar := program.PTIsUsedVariables().Find( operation, up.Period_MP() ); | 
|               // If the isused variable does not exist, then this combination of period and operation is not considered by the optimizer | 
|               if( not isnull( isusedvar ) ) | 
|               { | 
|                 // Term:      -cost      * PTIsUSed variable | 
|                 // UoM:  [Monetary/Unit] *    [-]    *    [Unit] | 
|                 dcconst.NewTerm( -cost * scalefactor_ptisused_dconst, isusedvar ); | 
|               } | 
|             } | 
|           } | 
|         } | 
|       } | 
|     } | 
|   *] | 
|   InterfaceProperties { Accessibility: 'Module' } | 
| } |