Quintiq file version 2.0
|
#parent: #root
|
Method ExtendCombi
|
{
|
TextBody:
|
[*
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
//If the campaign or transition that starts the combi has a max duration then we need combis for
|
//each subperiod up till the max dutation ending with each possible transition like:
|
//A | A-> B (both in the same period
|
//A | A | A-> B
|
//A | A | A | A-> B
|
//
|
//
|
//If the campaign or tranisit that starts the combi has a min duration and no max duration then we
|
//want a mid combi which exist of a single subperiod with the campaign/transition and a combi with
|
//the min duration. Which campaign A minduration is 2 days this looks like:
|
//A
|
//A | A : A-> B
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
lastelement := this.LastCombiElement();
|
hasminduration := this.HasminDurationCombi();
|
hasmaxduration := this.HasMaxDurationCombi();
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
//If the combi does not have a max duration then we need one combi with a single element so we need
|
//to duplicate the combi here to preserve the single element combi
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
if( not this.HasFixedStartAndDuration()
|
and this.OptCampaignCombiElement( relsize ) = 1
|
and not this.HasMaxDurationCombi()
|
)
|
{
|
singlecombi := this.DuplicateCombi();
|
singlecombi.IsCompleteCombi( true );
|
}
|
|
|
//For debugging
|
/*
|
this.CalcName();
|
if( this.OptCampaignUnitSubPeriod().StartTime().Date() = Date::Construct( 2018,1,1) )
|
{
|
info( this.Name()
|
, hasminduration
|
, this.MaxEndTimeFirstElement(), this.MaxEndTimeFirstElement() , lastelement.OptCampaignUnitSubPeriod().EndTime()
|
, this.NeedsExtensionElement()
|
, this.NeedsExtensionSubPeriod()
|
)
|
}
|
*/
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//If the combi has a min and or maxduration it and the duration is longer than the last subperiod added then the
|
//combi needs to be extended with an additional subperiod.
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
if( this.NeedsExtensionSubPeriod() )
|
{
|
//If the last element is longer than the period add the same element again but the attached to the next period
|
if( hasmaxduration )
|
{
|
if( not hasminduration
|
or ( hasminduration and lastelement.OptCampaignUnitSubPeriod().EndTime() >= this.MinEndTimeFirstElement() ) )
|
{
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//Duplicate the combi if it is longer than minduration. The original will be used to grow with more
|
//subperiods. The copy is used to complete the combi with the next element in the last periodthis.MinEndTimeFirstElement()
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
combi := this.DuplicateCombi();
|
combi.ExtendCombiwithNextElement();
|
}
|
}
|
//Add the next subperiod with the same element type
|
this.ExtendCombiWithNextSubPeriod();
|
}
|
else if( this.NeedsExtensionElement() )
|
{
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//if there is already a 2nd element type in the combi then every extensions requires a duplicate to keep track of
|
//all possible combination.
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
if( not lastelement.IsFirstElementTypeInCombi() )
|
{
|
combi := this.DuplicateCombi();
|
combi.IsCompleteCombi( true );
|
}
|
this.ExtendCombiwithNextElement();
|
|
}
|
else
|
{
|
this.IsCompleteCombi( true );
|
}
|
*]
|
}
|