| Quintiq file version 2.0 | 
| #parent: #root | 
| Method InitConstraintsGoalsForCampaignLimitations ( | 
|   CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program, | 
|   const LibOpt_Scope scope | 
| ) const | 
| { | 
|   TextBody: | 
|   [* | 
|     totalmaxqtyover_constname := typeof( MPTotalCampaignMaxQtyOverConstraint ); | 
|     scalefactor_totalmaxqtyover_const := this.ScaleConstraintTerm( typeof( MPTotalCampaignMaxQtyOverVariable ), totalmaxqtyover_constname ); | 
|     scalefactor_maxqtyoverwithin_const := this.ScaleConstraintTerm( typeof( MPMaxCampaignElementTypeQtyOverWithinVariable ), totalmaxqtyover_constname ); | 
|     scalefactor_maxqtyovermultiperiod_const := this.ScaleConstraintTerm( typeof( MPMaxCampaignElementTypeQtyOverMultiPeriodVariable ), totalmaxqtyover_constname ); | 
|      | 
|     totalminqtyunder_constname := typeof( MPTotalCampaignMinQtyUnderConstraint ); | 
|     scalefactor_totalminqtyunder_const := this.ScaleConstraintTerm( typeof( MPTotalCampaignMinQtyUnderVariable ), totalminqtyunder_constname ); | 
|     scalefactor_minqtyunderwithin_const := this.ScaleConstraintTerm( typeof( MPMinCampaignElementTypeQtyUnderWithinVariable ), totalminqtyunder_constname ); | 
|     scalefactor_minqtyundermulti_const := this.ScaleConstraintTerm( typeof( MPMinCampaignElementTypeQtyUnderMultiVariable ), totalminqtyunder_constname ); | 
|      | 
|     totalmindurunder_constname := typeof( MPTotalCampaignMinDurUnderConstraint ); | 
|     scalefactor_totalmindurunder_const := this.ScaleConstraintTerm( typeof( MPTotalCampaignMinDurationUnderVariable ), totalmindurunder_constname ); | 
|     scalefactor_mindurunderwithin_const := this.ScaleConstraintTerm( typeof( MPMinCampaignElementTypeDurUnderWithinVariable ), totalmindurunder_constname ); | 
|     scalefactor_mindurundermulti_const := this.ScaleConstraintTerm( typeof( MPMinCampaignElementTypeDurUnderMultiVariable ), totalmindurunder_constname ); | 
|      | 
|     totalmaxdurover_constname := typeof( MPTotalCampaignMaxDurOverConstraint ); | 
|     scalefactor_totalmaxdurover_const := this.ScaleConstraintTerm( typeof( MPTotalCampaignMaxDurationOverVariable ), totalmaxdurover_constname ); | 
|     scalefactor_maxduroverwithin_const := this.ScaleConstraintTerm( typeof( MPMaxCampaignElementTypeDurOverWithinVariable ), totalmaxdurover_constname ); | 
|     scalefactor_maxdurovermulti_const := this.ScaleConstraintTerm( typeof( MPMaxCampaignElementTypeDurOverMultiVariable ), totalmaxdurover_constname ); | 
|        | 
|     totalmaxqtyoverconstr := program.TotalCampaignMaxQtyOverConstraints().New(); | 
|     totalmaxqtyoverconstr.RHSValue( 0.0 ); | 
|     totalmaxqtyoverconstr.Sense( "=" ); | 
|     vartotalmaxqtyover := program.TotalCampaignMaxQtyOverVariables().Get();  | 
|     totalmaxqtyoverconstr.NewTerm( 1.0 * scalefactor_totalmaxqtyover_const, vartotalmaxqtyover ); | 
|      | 
|     totalminqtyunderconstr := program.TotalCampaignMinQtyUnderConstraints().New(); | 
|     totalminqtyunderconstr.RHSValue( 0.0 ); | 
|     totalminqtyunderconstr.Sense( "=" ); | 
|     vartotalminqtyunder := program.TotalCampaignMinQtyUnderVariables().Get();  | 
|     totalminqtyunderconstr.NewTerm( 1.0 * scalefactor_totalminqtyunder_const, vartotalminqtyunder ); | 
|      | 
|     totalmindurunderconstr := program.TotalCampaignMinDurUnderConstraints().New(); | 
|     totalmindurunderconstr.RHSValue( 0.0 ); | 
|     totalmindurunderconstr.Sense( "=" ); | 
|     vartotalmindurunder := program.TotalCampaignMinDurationUnderVariables().Get(); | 
|     totalmindurunderconstr.NewTerm( 1.0 * scalefactor_totalmindurunder_const, vartotalmindurunder ); | 
|      | 
|     totalmaxduroverconstr := program.TotalCampaignMaxDurOverConstraints().New(); | 
|     totalmaxduroverconstr.RHSValue( 0.0 ); | 
|     totalmaxduroverconstr.Sense( "=" ); | 
|     vartotalmaxdurover := program.TotalCampaignMaxDurationOverVariables().Get(); | 
|     totalmaxduroverconstr.NewTerm( 1.0 * scalefactor_totalmaxdurover_const, vartotalmaxdurover ); | 
|      | 
|     ocusps := selectset( scope.GetUnitPeriodInOptimizerRunConst(), Elements.OptCampaignUnitSubPeriod, ocusp, true ) | 
|      | 
|     traverse( ocusps, Elements, ocusp ) | 
|     { | 
|       //If this is a transition, we want these constraints to be hard ones | 
|       //So we don't have these slack variables | 
|       traverse( ocusp, OptCampaignCombiElement.OptCampaignElementType, ocet, not ocet.istype( OptCampaignTransitionType ) ) | 
|       { | 
|         totalmaxqtyoverconstr.NewTerm( - 1.0 * scalefactor_maxqtyoverwithin_const, program.MaxCampaignElementTypeQtyOverWithinVariables().Get( ocet, ocusp ) ) | 
|         totalmaxqtyoverconstr.NewTerm( - 1.0 * scalefactor_maxqtyovermultiperiod_const, program.MaxCampaignElementTypeQtyOverMultiPeriodVariables().Get( ocet, ocusp ) ) | 
|         if ( isnull( ocusp.NextSubPeriod() ) ) | 
|         { | 
|           totalmaxqtyoverconstr.NewTerm( - 1.0 * scalefactor_maxqtyoverwithin_const, program.MaxCampaignElementTypeQtyOverWithinLastVariables().Get( ocet, ocusp ) ) | 
|         } | 
|          | 
|         totalminqtyunderconstr.NewTerm( - 1.0 * scalefactor_minqtyunderwithin_const, program.MinCampaignElementTypeQtyUnderWithinVariables().Get( ocet, ocusp ) ) | 
|         totalminqtyunderconstr.NewTerm( - 1.0 * scalefactor_minqtyundermulti_const, program.MinCampaignElementTypeQtyUnderMultiVariables().Get( ocet, ocusp ) ) | 
|          | 
|         totalmindurunderconstr.NewTerm( - 1.0 * scalefactor_mindurunderwithin_const, program.MinCampaignElementTypeDurUnderWithinVariables().Get( ocet, ocusp ) ); | 
|         totalmindurunderconstr.NewTerm( - 1.0 * scalefactor_mindurundermulti_const, program.MinCampaignElementTypeDurUnderMultiVariables().Get( ocet, ocusp ) ); | 
|          | 
|         totalmaxduroverconstr.NewTerm( - 1.0 * scalefactor_maxduroverwithin_const, program.MaxCampaignElementTypeDurOverWithinVariables().Get( ocet, ocusp ) ); | 
|         totalmaxduroverconstr.NewTerm( - 1.0 * scalefactor_maxdurovermulti_const, program.MaxCampaignElementTypeDurOverMultiVariables().Get( ocet, ocusp ) ); | 
|       } | 
|     } | 
|   *] | 
| } |