| Quintiq file version 2.0 | 
| #parent: #root | 
| Method InitVariablesForTrip ( | 
|   CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program, | 
|   const constcontent ProductInTrips userproductintrips, | 
|   const LibOpt_Scope scope, | 
|   const constcontent ProductInTrips pitinrun | 
| ) const | 
| { | 
|   Description: 'Initialize all variables related to trip containig period task lane leg.' | 
|   TextBody: | 
|   [* | 
|     // create period task related variables | 
|      | 
|     runcontext := this.GetRunContextConst();  | 
|     // Init variables for all demand and supply of trips for each product | 
|     traverse( pitinrun, Elements, productintrip ) | 
|     { | 
|       // TripDemandQty variable UoM: Input PISP | 
|       program.TripDemandQtyVariables().New( productintrip );        // Fulfilled demand quantity for product in trip | 
|       // TripNewSupply variable UoM: Output PISP | 
|       var := program.TripNewSupplyVariables().New( productintrip ); // The supply quantity for product in trip | 
|      | 
|       // Feedback as lowerbound | 
|       if( productintrip.HasFeedback() ) | 
|       { | 
|         lowerbound := sum( productintrip, FeedbackProductInTrip, feedback, | 
|                            feedback.GetIsValidFeedback() and feedback.UnitPeriod() = productintrip.Trip().ArrivalUnitPeriod(), | 
|                            feedback.FeedbackQuantity() ); | 
|      | 
|         if ( lowerbound > 0 )  | 
|         { | 
|           this.FreezeVariableLowerBound( var, lowerbound ); | 
|         } | 
|       } | 
|     } | 
|      | 
|     // Init variables for lot sizes and lot cost | 
|     if( runcontext.UseLotSize() or runcontext.UseLotCost() ) //Modified by Khor for Lot cost goal | 
|     { | 
|       traverse( scope.GetTripInOptimizerRun(), Elements, trip,  | 
|                 trip.DepartureUnitPeriod().Period_MP().IsWithinLotSizeHorizon() ) | 
|       { | 
|         unitperiod := trip.DepartureUnitPeriod(); | 
|        | 
|         // Lot size of trip on departure period | 
|         if( guard( unitperiod.HasLotSize(), false ) ) | 
|         { | 
|           // TripNrOfLots variable UoM: Number | 
|           tripnroflotsvar := program.TripNrOfLotsVariables().New( trip ); // Create integer variable | 
|      | 
|           // If this is a sliding windows run and the period is not in the sliding window, then relax the integer variable | 
|           if( runcontext.IsSlidingWindowsRun() | 
|               and not guard( unitperiod.Period_MP().GetIsInSlidingWindow( scope ), false ) ) | 
|           { | 
|             tripnroflotsvar.VariableType( 'Continuous' ); | 
|           } | 
|            | 
|           // TripLotSizeUnder variable UoM: Unit | 
|           varunder := program.TripLotSizeUnderVariables().New( trip );      // Additional quantity required to reach the multiples of lot size | 
|           varover := program.TripLotSizeOverVariables().New( trip );      // Subtractive quantity required to reach the multiples of lot size | 
|           this.FreezeVariableUpperBound( varunder, trip.LotSize() );  | 
|           this.FreezeVariableUpperBound( varover, trip.LotSize() ); | 
|         } | 
|       } | 
|     } | 
|      | 
|     // Freeze the user planning product in trip | 
|     // User quantity must be adhered by the optimizer. Optimizer cannot change the transported quantity. | 
|     traverse( userproductintrips, Elements, productintrip ) | 
|     { | 
|       pitvar := program.TripNewSupplyVariables().Find( productintrip );  | 
|       if ( not isnull( pitvar ) )  | 
|       { | 
|         this.FixVariableStyleGuide( pitvar, productintrip.Quantity() ); | 
|       } | 
|     } | 
|   *] | 
|   InterfaceProperties { Accessibility: 'Module' } | 
| } |