Quintiq file version 2.0
|
#parent: #root
|
Method InitConstraintsForUnitPeriodTools (
|
CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program,
|
const LibOpt_Scope scope,
|
const CapacityPlanningSuboptimizer subopt
|
) const
|
{
|
Description: 'Initialize constraints for unit periods'
|
TextBody:
|
[*
|
period := this.Period_MP();
|
algorithm := subopt;
|
|
scalefactor_ptqty_toolisused := algorithm.ScaleConstraintTerm( typeof( MPPTQtyVariable ), typeof( MPUnitPeriodToolIsUsedConstraint ) );
|
scalefactor_unitperiodtoolisused_nroftoolchange := algorithm.ScaleConstraintTerm( typeof( MPUnitPeriodToolIsUsedVariable ), typeof( MPUnitPeriodNrOfToolChangeConstraint ) );
|
|
unitperiodoperations := algorithm.GetOperationsForUnitPeriod( scope, this );
|
|
//UnitPeriodNrOfToolChange = sum( UnitPeriodToolIsUsed ) - 1
|
constUnitPeriodNrOfToolChange := program.UnitPeriodNrOfToolChangeConstraints().New( this );
|
constUnitPeriodNrOfToolChange.Sense( '>=' );
|
constUnitPeriodNrOfToolChange.RHSValue( algorithm.ScaleConstraintRHS( typeof( MPUnitPeriodNrOfToolChangeConstraint ), -1.0 ) );
|
|
|
varUnitPeriodNrOfToolChange := program.UnitPeriodNrOfToolChangeVariables().Find( this );
|
scalefactor_unitperiodnroftoolchange_nroftoolchange := algorithm.ScaleConstraintTerm( typeof( MPUnitPeriodNrOfToolChangeVariable ) , typeof( MPUnitPeriodNrOfToolChangeConstraint ) );
|
|
if( not isnull( varUnitPeriodNrOfToolChange ) )
|
{
|
constUnitPeriodNrOfToolChange.NewTerm( 1.0 * scalefactor_unitperiodnroftoolchange_nroftoolchange, varUnitPeriodNrOfToolChange );
|
}
|
|
traverse( this, ToolInUnitPeriod.Tool, tool )
|
{
|
varUnitPeriodToolIsUsed := program.UnitPeriodToolIsUsedVariables().Get( this, tool );
|
|
//if( not isnull( varUnitPeriodToolIsUsed ) )
|
{
|
constUnitPeriodNrOfToolChange.NewTerm( -1.0 * scalefactor_unitperiodtoolisused_nroftoolchange, varUnitPeriodToolIsUsed );
|
|
constUnitPeriodToolIsUsed := program.UnitPeriodToolIsUsedConstraints().New( this, tool );
|
constUnitPeriodToolIsUsed.RHSValue( 0 );
|
constUnitPeriodToolIsUsed.Sense( "=" );
|
|
traverse( unitperiodoperations,
|
Elements,
|
operation,
|
guard( operation.RoutingStep().Tool() = tool.Name(), false ) )
|
{
|
ptqtyvar := program.PTQtyVariables().Find( operation, period );
|
if( not isnull( ptqtyvar ) )
|
{
|
constUnitPeriodToolIsUsed.NewTerm( scalefactor_ptqty_toolisused, ptqtyvar );
|
}
|
}
|
program.NewIfNotThenConstraint( AlgorithmNameConstraint::UnitPeriodToolIsUseGeneral( this, tool.Name() ), varUnitPeriodToolIsUsed, constUnitPeriodToolIsUsed )
|
}
|
}
|
*]
|
InterfaceProperties { Accessibility: 'Module' }
|
}
|