Quintiq file version 2.0
|
#parent: #root
|
Method InitConstraintsGoalsForStockingPointInPeriods (
|
CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program,
|
const RunContextForCapacityPlanning runcontext,
|
const LibOpt_Scope scope
|
) const
|
{
|
Description: 'Init constraints goals for stocking point in periods'
|
TextBody:
|
[*
|
collectvaluesmodel := runcontext.IsMetaIteration();
|
|
totalstockingpointviolation := 0.0;
|
|
totalstockingpointcapacity_varname := typeof( MPTotalStockingPointCapacityVariable );
|
stockingpointcapacityoverloaded_varname := typeof( MPStockingPointCapacityOverloadedVariable );
|
|
totalstockingpointcapacity_constname := typeof( MPTotalStockingPointCapacityConstraint );
|
|
scalefactor_totalstockingpointcapacity_const := this.ScaleConstraintTerm( totalstockingpointcapacity_varname, totalstockingpointcapacity_constname );
|
scalefactor_stockingpointcapacityoverloaded_const := this.ScaleConstraintTerm( stockingpointcapacityoverloaded_varname , totalstockingpointcapacity_constname );
|
scalefactor_overmaxvar := CapacityPlanningSuboptimizer::GetVariableScaleFactor( stockingpointcapacityoverloaded_varname );
|
|
// stocking point capacity overloaded
|
// const constraint UoM: SP --> Please note that this means that if different SP have a different UoM,
|
// their SPCapacityOverloaded will have a different weight in the goal
|
const := program.TotalStockingPointCapacityConstraints().New();
|
const.Sense( '=' );
|
// using default RHS 0.0
|
// Term UoM: SP
|
const.NewTerm( 1.0 * scalefactor_totalstockingpointcapacity_const, program.TotalStockingPointCapacityVariables().Get() );
|
|
constmeta := null( MPConstraint );
|
if ( runcontext.IsMetaIteration() )
|
{
|
constmeta := program.TotalStockingPointCapacityMetaConstraints().New();
|
constmeta.Sense( '=' );
|
// using default RHS 0.0
|
// Term UoM: SP
|
constmeta.NewTerm( 1.0 * scalefactor_totalstockingpointcapacity_const, program.TotalStockingPointCapacityMetaVariables().Get() );
|
}
|
|
// Overloaded capacity
|
traverse( scope.GetStockingPointInPeriodInOptimizerRunConst(),
|
Elements,
|
spip,
|
not spip.StockingPoint_MP().IsPlannedInfinite()
|
and not spip.IsPeriodFrozen() )
|
{
|
// Term UoM: SP
|
coefficient := scalefactor_stockingpointcapacityoverloaded_const;
|
|
|
const.NewTerm( -1.0 * coefficient, program.StockingPointCapacityOverloadedVariables().Get( spip ) );
|
|
if ( runcontext.IsMetaIteration() )
|
{
|
constmeta.NewTerm( -1.0 * coefficient, program.StockingPointCapacityOverloadedMetaVariables().Get( spip ) );
|
}
|
|
if ( collectvaluesmodel )
|
{
|
change_inventory := program.Variable( 'UnscaledRHSModificationSPInPeriodInventoryLevelConstraints', spip ).UpperBound(); // we filter RHS of this constraints to remove noise. Need to take this into account to compute existing violation
|
totalstockingpointviolation := totalstockingpointviolation + coefficient * maxvalue( 0.0, (spip.InventoryLevelEnd() + change_inventory) - spip.MaxCapacity() ) / scalefactor_overmaxvar;
|
}
|
}
|
|
// workaround because cannot write to attribute
|
this.StoreValueInProgram( program,'collect_values_model_TotalStockingPointCapacityVariables', totalstockingpointviolation );
|
*]
|
InterfaceProperties { Accessibility: 'Module' }
|
}
|