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
Quintiq file version 2.0
#parent: #root
Method GetIsBalanceSlackAllowed (
  const ProductInStockingPointInPeriod pispip,
  const constcontent ProductInStockingPointInPeriods smartplanpispips,
  constcontent ProductInStockingPoint_MPs intermediatepisps,
  const RunContextForCapacityPlanning runcontext
) const as Boolean
{
  Description:
  [*
    Determines whether we allow slack on the balance constraint.
    For smart plans that should only plan one step upstream we remove some of the balance slacks to make sure that we actually plan the step
    and that the balance violations occur at the input side rather than at the end or at an intermediate stage.
  *]
  TextBody:
  [*
    // Martijn Dec-7-2016 (created)
    // If this is not a smart plan run or if we are not only planning one step upstream, then we always allow balance slack.
    // Or if it is a single step smart plan and the pispip is not the end product and it is either not an intermediate product or it is a by product, then we allow the slack
    isallowed := not runcontext.IsSmartPlan()
                 or not runcontext.IsOnlyPlanOneStepUpstream()
                 or ( not exists( smartplanpispips, Elements.ProductInStockingPoint_MP, pisp, pisp = pispip.ProductInStockingPoint_MP() )
                      and ( pispip.ProductInStockingPoint_MP().Product_MP().IsDerivedByProduct()
                            or not exists( intermediatepisps, Elements, pisp, pisp = pispip.ProductInStockingPoint_MP() ) ) )
    
    return isallowed;
  *]
  InterfaceProperties { Accessibility: 'Module' }
}