| Quintiq file version 2.0 | 
| #parent: #root | 
| Method InitConstraintsGoalsForDriverChangeover ( | 
|   CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program, | 
|   const LibOpt_Scope scope | 
| ) const | 
| { | 
|   Description: 'Init constraints goals for account depends on time, applicable to unit period time' | 
|   TextBody: | 
|   [* | 
|     // Mathematical variable names | 
|     driverchangeover_varname := typeof( MPDriverChangeoverVariable ); | 
|     unitperiodnroftoolchange_varname := typeof( MPUnitPeriodNrOfToolChangeVariable ); | 
|     // Constraint names | 
|     tconstname := typeof( MPDriverChangeoverConstraint ); | 
|     // scaling factor calculations | 
|     scalefactor_driver_tconst := this.ScaleConstraintTerm( driverchangeover_varname, tconstname ); | 
|     scalefactor_unitperiodtime_tconst := this.ScaleConstraintTerm( unitperiodnroftoolchange_varname, tconstname ); | 
|      | 
|     scalefactor_rhs_tconst := this.ScaleConstraintRHS( tconstname, 1.0 ); | 
|      | 
|     driver := select( this, MacroPlan.AccountCostDriver, driver, driver.Name() = Translations::MP_AccountAssignmentCostDriverChangeover() ); | 
|     traverse( scope.GetAccountsInOptimizerRunConst(), Elements, account, account.HasChangeOverAssignment() ) | 
|     { | 
|      | 
|       // tconst constraint UoM: Monetary | 
|       tconst := program.DriverChangeoverConstraints().New( account, driver ); | 
|       tconst.Sense( '=' ); | 
|       tconst.RHSValue( 0.0 * scalefactor_rhs_tconst ); | 
|       // Term UoM: Monetary | 
|       tconst.NewTerm( 1.0 * scalefactor_driver_tconst, program.DriverChangeoverVariables().Get( account, driver ) ); | 
|      | 
|       traverse( account, AccountAssignment, aa, aa.AccountCostDriver() = driver and aa.AccountCost( relsize ) > 0  ) | 
|       { | 
|         traverse( aa, astype( UnitAccount ).UnitAccountInPeriodForChangeover.UnitPeriod, up, | 
|                   scope.Contains( up.UnitPeriodInOptimizerRun() ) ) | 
|         { | 
|           varUnitPeriodNrOfToolChange := program.UnitPeriodNrOfToolChangeVariables().Find( up ); | 
|            | 
|           if( not isnull( varUnitPeriodNrOfToolChange ) ) | 
|           { | 
|             cost := up.astype( UnitPeriodTime ).GetBaseCostPerChangeover( aa.astype( UnitAccount ) ); | 
|             // Term:    -cost * UnitPeriodNrOfToolChange variable | 
|             // UoM: [Monetary/Unit] *    [-]    *    [Unit] | 
|             tconst.NewTerm( -cost * scalefactor_unitperiodtime_tconst, varUnitPeriodNrOfToolChange ); | 
|           } | 
|         } | 
|       } | 
|     } | 
|   *] | 
|   InterfaceProperties { Accessibility: 'Module' } | 
| } |