haorenhui
2023-10-30 6d6cc10d9e8e242661da7fd655dec155a09d676c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Quintiq file version 2.0
#parent: #root
Method AddConstraintForOperationNewSupplies (
  const OperationOutput output,
  const Period_MP period,
  const Period_MP excludeperiod,
  CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program,
  Real coefficient,
  MPConstraint const,
  Real scalefactor_periodtaskqty_const,
  const LibOpt_Scope scope
) const
{
  TextBody:
  [*
    // soh yee Jan-26-2015 (created)
    operation := output.Operation();
    // The operation must be part of the operations for optimization
    if( not isnull( operation ) )
    {
      var := program.PTQtyVariables().Find( operation, period ); 
    
      // If the PTQty variable does not exist, then this PT is not valid for this optimizer run
      // ( because its newsupply/dependent demand is related to a pispip that is out of scope )
      if( not isnull( var ) )
      {
        // Term: coefficient *      factor         * scale * PTQty variable
        // UoM:  [coeff UoM] * [Unit to Output PISP] *  [-]  *    [Unit]
        const.NewTerm( coefficient * PeriodTaskOperation::GetNewSupplyQuantity( 1.0, output, 1.0 ) * scalefactor_periodtaskqty_const, var );                   
      }
    }
  *]
  InterfaceProperties { Accessibility: 'Module' }
}