Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method AddTermsToInventorySpecificationConstraint ( 
 | 
  CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program, 
 | 
  MPConstraint constr, 
 | 
  const ProductInStockingPointInPeriodPlanning pispip, 
 | 
  Real specificationindays, 
 | 
  const LibOpt_Scope scope, 
 | 
  Real scalefactor_demandfulfillmentinpispip_constr, 
 | 
  Real scalefactor_rhs_constr 
 | 
) const 
 | 
{ 
 | 
  Description: 'Updates the terms/RHS of the input inventory specification constraint' 
 | 
  TextBody: 
 | 
  [* 
 | 
    // If the input pispip is a leaf pispip, we only need to add terms related to this product 
 | 
    activepispips := construct( ProductInStockingPointInPeriodPlannings, constcontent ); 
 | 
    if( pispip.IsLeafPlanning() ) 
 | 
    { 
 | 
      activepispips.Add( pispip ) 
 | 
    } 
 | 
    // If the input pispip is not a leaf pispip, we need to add terms for all of its leaf products 
 | 
    else 
 | 
    { 
 | 
      traverse( pispip.GetLeavesOfProductDimensionConst(), Elements.astype( ProductInStockingPointInPeriodPlanning ), activepispip, 
 | 
                  not activepispip.ProductInStockingPoint_MP().IsNegativeInventoryAllowed() ) 
 | 
      { 
 | 
        activepispips.Add( activepispip ); 
 | 
      } 
 | 
    } 
 | 
     
 | 
    delta_term_forRHS := 0.0;  
 | 
    traverse( activepispips, Elements, activepispip ) 
 | 
    { 
 | 
      relevantpispips := activepispip.GetNextPlanningPISPIPsForOpt( specificationindays ); 
 | 
      remainingdays_o := specificationindays; 
 | 
     
 | 
       
 | 
      traverse( relevantpispips, Elements, nextpispip ) 
 | 
      { 
 | 
        ratio := nextpispip.GetPISPIPRatioForSpecificationInDays( remainingdays_o ); 
 | 
       
 | 
        // If the next pispip is part of this optimizer run, add a term to the constraint, otherwise update the RHS 
 | 
        if( scope.Contains( nextpispip.PISPIPInOptimizerRun() ) ) 
 | 
        { 
 | 
          // Term: ratio * DemandFulfillmentInPISPIP variable 
 | 
          // UoM:  [-]   *         [PISP] 
 | 
          constr.NewTerm( -ratio * scalefactor_demandfulfillmentinpispip_constr, program.DemandFulfillmentInPISPIPVariables().Get( nextpispip ) ); 
 | 
        } 
 | 
        else 
 | 
        { 
 | 
          delta_term_forRHS := delta_term_forRHS + (ratio * nextpispip.FulfilledDemandQuantity());  
 | 
        } 
 | 
      } 
 | 
    } 
 | 
    newrhs := this.GetConstraintRHS( constr, scalefactor_rhs_constr ) + delta_term_forRHS;  
 | 
    constr.RHSValue( newrhs * scalefactor_rhs_constr ); 
 | 
  *] 
 | 
  InterfaceProperties { Accessibility: 'Module' } 
 | 
} 
 |