Quintiq file version 2.0
|
#parent: #root
|
Method InitConstraintsForCampaignMaxDurationWithin (
|
CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program,
|
const LibOpt_Scope scope
|
) const
|
{
|
TextBody:
|
[*
|
maxdurwithin_constname := typeof( MPMaxCampaignElementTypeDurationWithinConstraint );
|
scalefactor_DurationWithin_const := this.ScaleConstraintTerm( typeof( MPDurationOfCampaignElementTypeMidVariable ), maxdurwithin_constname );
|
scalefactor_DurationEnd_const := this.ScaleConstraintTerm( typeof( MPDurationOfCampaignElementTypeEndVariable ), maxdurwithin_constname );
|
scalefactor_NrOfElementsWithin_const := this.ScaleConstraintTerm( typeof( MPNrOfCampaignElementWithinUnitSubPeriodVariable ), maxdurwithin_constname );
|
scalefactor_IsLastElementType_const := this.ScaleConstraintTerm( typeof( MPIsLastCampaignElementTypeVariable ), maxdurwithin_constname );
|
scalefactor_MaxElementTypeDurOverMid_const := this.ScaleConstraintTerm( typeof( MPMaxCampaignElementTypeDurOverWithinVariable ), maxdurwithin_constname );
|
|
traverse( scope.GetUnitPeriodInOptimizerRunConst(), Elements.OptCampaignUnitSubPeriod, ocusp )
|
{
|
//Only do this for campaign / transitions that have a MaxDuration (and thus, MaxDuration is finite)
|
traverse( ocusp, OptCampaignCombiElement.OptCampaignElementType, ocet, ocet.HasMaxDuration() )
|
{
|
constr := program.MaxCampaignElementTypeDurationWithinConstraints().New( ocet, ocusp );
|
constr.RHSValue( 0.0 );
|
|
durationvar := program.DurationOfCampaignElementTypeMidVariables().Get( ocet, ocusp );
|
constr.NewTerm( 1.0 * scalefactor_DurationWithin_const, durationvar );
|
|
//If this is a transition, we want these constraints to be hard ones
|
if( not ocet.istype( OptCampaignTransitionType ) )
|
{
|
constr.NewTerm( -1.0 * scalefactor_MaxElementTypeDurOverMid_const, program.MaxCampaignElementTypeQtyOverWithinVariables().Get( ocet, ocusp ) );
|
}
|
constr.NewTerm( -ocet.MaxDuration().HoursAsReal() * scalefactor_NrOfElementsWithin_const, program.NrOfCampaignElementWithinUnitSubPeriodVariables().Get( ocet, ocusp ) );
|
|
//add one more term for the last ocusp in horizon
|
if( isnull( ocusp.NextSubPeriod() ) )
|
{
|
constr.NewTerm( - ocet.MaxDuration().HoursAsReal() * scalefactor_IsLastElementType_const, program.IsLastCampaignElementTypeVariables().Get( ocet, ocusp ) )
|
durvar := program.DurationOfCampaignElementTypeEndVariables().Get( ocet, ocusp );
|
constr.NewTerm( 1.0 * scalefactor_DurationEnd_const, durvar );
|
}
|
}
|
}
|
*]
|
}
|