| Quintiq file version 2.0 | 
| #parent: #root | 
| Method SetFeedBackQuantities ( | 
|   MacroPlan mp, | 
|   RunContextForCapacityPlanning runcontext, | 
|   LibOpt_Scope scope | 
| ) | 
| { | 
|   TextBody: | 
|   [* | 
|     if ( runcontext.IsMetaIteration() )  | 
|     { | 
|       ptcount := 0;  | 
|       periods := scope.GetPeriodInOptimizerRun();  | 
|       traverse( mp, Unit.Operation, operation, operation.FeedbackPeriodTaskOperation( relsize ) > 0 or operation.HasMinimumQuantity() )  | 
|       { | 
|         traverse( periods, Elements, period, PeriodTaskOperation::GetIsValidPeriodTask( operation, period ) ) // we don't want to plan feedback in frozen unit periods for example  | 
|         { | 
|           operationmin := 0.0;  | 
|           if( runcontext.UseProcessMinimumQuantity() | 
|               and operation.HasMinimumQuantity() | 
|               and period.IsWithinLotSizeHorizon() )  | 
|           { | 
|             operationmin := operation.MinimumQuantity();  | 
|           } | 
|            | 
|           feedbackqty := sum( operation,  | 
|                               FeedbackPeriodTaskOperation,  | 
|                               feedback, | 
|                               feedback.GetIsValidFeedback()  | 
|                               and feedback.UnitPeriod().Period_MP() = period, | 
|                               feedback.FeedbackQuantity() ); | 
|                                | 
|           pt := select(  operation, PeriodTaskOperation, ptask, true, ptask.UnitPeriod().Period_MP() = period );  | 
|           largestlowerbound := maxvalue(  feedbackqty, operationmin ); | 
|             | 
|           if ( largestlowerbound > 0 )  | 
|           { | 
|             if ( isnull( pt ) )  | 
|             { | 
|               up := select(  operation, Unit.UnitPeriod, uperiod, uperiod.Period_MP() = period );  | 
|               pt := PeriodTaskOperation::CreateValidPeriodTask( operation, | 
|                                                                 up, | 
|                                                                 0.0, | 
|                                                                 false ); | 
|             } | 
|             if ( guard( pt.Quantity() < largestlowerbound, false )  | 
|                  and ( not feedbackqty = 0 and pt.Quantity() = 0 )  ) // in this case 0 UNION [operationmin, infty ) is the bound on the variable ( semi continues)  | 
|             { | 
|               pt.SetOptimizerQuantity( largestlowerbound );    | 
|               debuginfo(  'Pre processing Period = ', period.Start(), 'operation=', operation.Name(), 'feedback = ', feedbackqty, 'lowerbound set = ', largestlowerbound  );  | 
|      | 
|               ptcount++;  | 
|             } | 
|           } | 
|         } | 
|       } | 
|      | 
|       Transaction::Transaction().Propagate ( attribute( PeriodTaskOperation, QuantityToProcess ) );  | 
|       Transaction::Transaction().Propagate ( attribute( PeriodTaskOperation, Quantity ) );  | 
|      | 
|       this.PlanFeedbackPIT( scope, runcontext );  | 
|        | 
|       Transaction::Transaction().Propagate( attribute( ProductInTrip, Quantity ) );  | 
|        | 
|       debuginfo(  'Planned feedback for #periotaskoperation = ', ptcount );  | 
|     } | 
|   *] | 
|   InterfaceProperties { Accessibility: 'Module' } | 
| } |