Quintiq file version 2.0
|
#parent: #root
|
Method Debug_FreezeDecisionVariables (
|
CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program,
|
const Period_MP start,
|
const Period_MP end,
|
const LibOpt_Scope scope,
|
Boolean unfreeze
|
) const
|
{
|
Description:
|
[*
|
Freeze the decision variables for debugging purpose
|
To check if the current planning is feasible in optimizer
|
Update this code if the initialization of period tasks and pispips change.
|
*]
|
TextBody:
|
[*
|
|
// Note:
|
// 1. Does not support the freezing of postponed sales demands as they will be merged back to the original one.
|
// Possible infeasible due to common violation of hard constraints such as:
|
// 1. Some of the dependent demands are not fulfilled.
|
// 2. The hard constraints found in optimizer setting if activated, such as lot sizes.
|
|
// Freeze the variables to its current value if it is within the selected optimization horizon
|
// periodtaskqtyvarname := AlgorithmNameVariable::PTQty();
|
|
runcontext := this.GetRunContextConst();
|
epsilonfreeze := 0.0;
|
|
traverse( scope.GetPeriodInOptimizerRunConst(), Elements, period )
|
{
|
traverse( period, UnitPeriod, unitperiod, scope.Contains( unitperiod.UnitPeriodInOptimizerRun() ) )
|
{
|
operations := this.GetOperationsForUnitPeriod( scope, unitperiod );
|
traverse( operations, Elements, operation,
|
not operation.IsFrozenInPeriod( period ) )
|
{
|
// period task
|
pt := PeriodTaskOperation::FindPeriodTaskOperationTypeIndex( period.Start(), operation.ID() );
|
quantity := guard( pt.Quantity(), 0.0 );
|
var := program.PTQtyVariables().Get( operation, period );
|
if ( unfreeze )
|
{
|
this.SetPTQtyVariableProperties( scope, runcontext, operation, period, var, false /*set start value*/, program );
|
}
|
else
|
{
|
nonegative := true;
|
this.FreezeIt( var, quantity, nonegative, epsilonfreeze );
|
}
|
|
|
// Dependent demand input group
|
/*
|
traverse( pt, DependentDemandInputGroup, ddig )
|
{
|
if( operation.HasLeadTime() ) // Get the dependent demands that is located at different period from the period of period task.
|
{
|
pispipperiods := construct( Period_MPs );
|
CapacityPlanningSuboptimizer::GetOperationDependentDemandPeriods( period, operation, pispipperiods );
|
|
traverse( pispipperiods, Elements, pispipperiod )
|
{
|
|
traverse( ddig, DependentDemand, dd, dd.ProductInStockingPointInPeriodPlanningLeaf().Period_MP() = pispipperiod )
|
{
|
input := dd.ProcessInput();
|
varpartialoperationdemandqty := program.PartialOperationDemandQtyVariables().Find( input.astype( OperationInput ), pispipperiod, period );
|
if ( not isnull( varpartialoperationdemandqty ) )
|
{
|
quantity := dd.FulfilledQuantity();
|
if ( unfreeze )
|
{
|
varpartialoperationdemandqty.LowerBound( 100.0 );
|
varpartialoperationdemandqty.LowerBound( 0.0 );
|
varpartialoperationdemandqty.UpperBound( 100.0 );
|
varpartialoperationdemandqty.UpperBound( Real::MaxReal() );
|
}
|
else
|
{
|
this.FreezeIt( varpartialoperationdemandqty, quantity );
|
}
|
}
|
}
|
}
|
}
|
else
|
{
|
quantity := ddig.OptimizerFulfilledQuantity();
|
error('Nikolay Kosarev: Is it unreachable? (should always be 2 indices')
|
//operationdemandqtyvar := program.FindVariable( operationdemandqtyvarname, period );
|
//if( not isnull( var ) )
|
//{
|
// this.FreezeVariableWithSlack( operationdemandqtyvar, quantity );
|
//}
|
}
|
}*/
|
}
|
}
|
|
|
traverse( scope.GetProductInTripInOptimizerRunConst(), Elements, productintrip,
|
not productintrip.Trip().DepartureUnitPeriod().IsPeriodFrozen() )
|
{
|
var := program.TripNewSupplyVariables().Get( productintrip );
|
if ( unfreeze )
|
{
|
var.LowerBound( -100.0 );
|
var.UpperBound( -100.0 );
|
var.LowerBound( productintrip.PITVarInitLowerBound() );
|
var.UpperBound( productintrip.PITVarInitUpperBound() );
|
}
|
else
|
{
|
qty := productintrip.Quantity();
|
nonegative := true;
|
this.FreezeIt( var, qty, nonegative, epsilonfreeze );
|
}
|
}
|
}
|
/*
|
// Freeze variables for SalesDemands
|
traverse( scope.GetLeafSalesDemandInPeriodInRun(),
|
Elements,
|
lsdip,
|
lsdip.AsSalesDemandInPeriodBase().Period_MP().IsAvailableForOptimization( start, end ) )
|
{
|
var := program.SalesDemandQtyVariables().Get( lsdip ); // Fulfilled quantity
|
if ( unfreeze )
|
{
|
var.LowerBound( -100.0 );
|
var.LowerBound( lsdip.SalesDemandQtyVarInitLowerBound() );
|
var.UpperBound( -100.0 );
|
var.UpperBound( lsdip.SalesDemandQtyVarInitUpperBound() );
|
}
|
else
|
{
|
qty := lsdip.FulfilledQuantity() ;
|
nonnegative := true;
|
this.FreezeIt( var, qty, nonnegative );
|
}
|
}
|
|
traverse( scope.GetAggregatedSalesDemandInPeriodInRun(), Elements, asdip, asdip.AsSalesDemandInPeriodBase().Period_MP().IsAvailableForOptimization( start, end ) )
|
{
|
traverse ( asdip,
|
DisaggregatedSalesDemandInPeriod,
|
dasdip,
|
not dasdip.IsPostponed()
|
and scope.Contains( dasdip.AsPlanningBaseSalesDemandInPeriod().PISPIPInOptimizerRun() ) )
|
{
|
var := program.DisaggregatedSalesDemandQtyVariables().Get( dasdip );
|
if ( unfreeze )
|
{
|
var.LowerBound( -100.0);
|
var.LowerBound( dasdip.SalesDemandQtyVarInitLowerBound() );
|
var.UpperBound( -100.0 );
|
var.UpperBound( dasdip.SalesDemandQtyVarInitUpperBound() );
|
}
|
else
|
{
|
qty := dasdip.FulfilledQuantity();
|
nonneg := true;
|
this.FreezeIt( var, qty, nonneg );
|
}
|
}
|
}
|
*/
|
|
// Freeze the variables to its current value if it is within the selected optimization horizon
|
/*
|
traverse( scope.GetPISPIPInOptimizerRun(), Elements.astype( ProductInStockingPointInPeriodPlanningLeaf), pispip )
|
{
|
traverse( pispip, DependentDemand, dd, isnull( dd.ProductInTrip() ) )
|
{
|
operationdemandqtyvar := program.OperationDemandQtyVariables().Find( dd.ProcessInput(), pispip.Period_MP() ); // Fulfilled quantity
|
if ( not isnull( operationdemandqtyvar ) )
|
{
|
if ( unfreeze )
|
{
|
operationdemandqtyvar.LowerBound( -100.0 );
|
operationdemandqtyvar.LowerBound( 0.0 );
|
operationdemandqtyvar.UpperBound( -100.0 );
|
operationdemandqtyvar.UpperBound( Real::MaxReal() );
|
}
|
else
|
{
|
this.FreezeIt( operationdemandqtyvar, dd.FulfilledQuantity() );
|
}
|
}
|
}
|
}
|
*/
|
*]
|
InterfaceProperties { Accessibility: 'Module' }
|
}
|