| Quintiq file version 2.0 | 
| #parent: #root | 
| Method InitConstraintsforCampaignCalcElementTypePeriodOverloadedEnd ( | 
|   CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program, | 
|   const LibOpt_Scope scope | 
| ) const | 
| { | 
|   TextBody: | 
|   [* | 
|     campaignoverloadend_constname := typeof( MPCalcElementTypePeriodOverloadedEndConstraint ); | 
|     scalefactor_PTQtyInCampaignElementTypeEnd_const := this.ScaleConstraintTerm( typeof( MPPTQtyInCampaignElementTypeEndVariable ), campaignoverloadend_constname ); | 
|     scalefactor_CampaignElementTypePeriodOverloadedEnd_const := this.ScaleConstraintTerm( typeof( MPCampaignElementTypePeriodOverloadedEndVariable ), campaignoverloadend_constname ); | 
|     scalefactor_DurationOfCampaignElementTypeEnd_const := this.ScaleConstraintTerm( typeof( MPDurationOfCampaignElementTypeEndVariable ), campaignoverloadend_constname ); | 
|      | 
|     traverse( scope.GetUnitPeriodInOptimizerRunConst(), Elements.OptCampaignUnitSubPeriod, ocusp ) | 
|     { | 
|       traverse( ocusp, OptCampaignCombiElement.OptCampaignElementType, ocet ) | 
|       { | 
|         constr := program.CalcElementTypePeriodOverloadedEndConstraints().New( ocet, ocusp ); | 
|         // Sum ( max capacity usage per quantity * PTQty in Element Type end ) | 
|         traverse( ocet, OptCampaignOperationInElementType, ocoet ) | 
|         { | 
|           maxcap := ocoet.Operation().GetCapacityUsagePerQuantity( ocusp.UnitPeriod() ); | 
|           varcampaignptqtyend := program.PTQtyInCampaignElementTypeEndVariables().Get( ocoet, ocusp ); | 
|           constr.NewTerm( maxcap * scalefactor_PTQtyInCampaignElementTypeEnd_const, varcampaignptqtyend );  | 
|         } | 
|         // Add slack variable ElementTypePeriodUnderloadedEnd | 
|         varcampaignoverloadend := program.CampaignElementTypePeriodOverloadedEndVariables().Get( ocet, ocusp ); | 
|         constr.NewTerm( -1.0 * scalefactor_CampaignElementTypePeriodOverloadedEnd_const, varcampaignoverloadend ); | 
|          | 
|         // Subtract total available capactity * relative duration of element end type | 
|         totalcap := ocusp.UnitPeriod().GetTotalAvailableCapacity(); | 
|         duration := ocusp.UnitPeriod().Duration(); | 
|         factor := totalcap / duration.HoursAsReal(); | 
|         varcampaigndurationend := program.DurationOfCampaignElementTypeEndVariables().Get( ocet, ocusp ); | 
|         constr.NewTerm( -factor * scalefactor_DurationOfCampaignElementTypeEnd_const, varcampaigndurationend ); | 
|       }  | 
|     } | 
|   *] | 
| } |