Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method CreateTrips ( 
 | 
  LaneLegs lanelegsforoptimizations, 
 | 
  Period_MPs periods, 
 | 
  output Trips updatedtrips_o 
 | 
) 
 | 
{ 
 | 
  Description: 'Pre-create trips to be fed as input for CPLEX' 
 | 
  IsAbstract: true 
 | 
  TextBody: 
 | 
  [* 
 | 
    // soh yee May-24-2015 (created) 
 | 
    validatestring := ''; 
 | 
    sanitycheckfeedback := ''; 
 | 
     
 | 
    //startofhorizon := this.MacroPlan().StartOfHistorical(); 
 | 
    earliesttripdeparture := minselect( periods, Elements, period, true, period.SequenceNr() ).Start(); 
 | 
     
 | 
    // For each lane leg, create all possible trips that does not fall outside selected planning horizon. 
 | 
    traverse( lanelegsforoptimizations, Elements, laneleg ) 
 | 
    { 
 | 
      startoftrip := laneleg.LeadTime() + earliesttripdeparture;      // Used to identify if the departure date of trip falls outside selected planning horizon 
 | 
     
 | 
      // Only create trips if the departure date and arrival date is within the selected planning horizon. 
 | 
      traverse( periods, Elements, period, period.End() >= startoftrip ) 
 | 
      { 
 | 
        trip := select( laneleg, Trip, trip, guard( trip.ArrivalUnitPeriod().Period_MP() = period, false ) ); 
 | 
     
 | 
        if( isnull( trip ) 
 | 
            and Trip::ValidateInput( validatestring, sanitycheckfeedback, laneleg, period ) ) // Only create valid trip 
 | 
        { 
 | 
          trip := Trip::Create( laneleg, period ); 
 | 
        } 
 | 
     
 | 
        if( not isnull( trip ) ) 
 | 
        { 
 | 
          // Create product in trips for each existing trip. 
 | 
          traverse( laneleg, LaneLegInput.ProductInStockingPoint_MP.Product_MP, product ) 
 | 
          { 
 | 
            trip.AddProduct( product, 0.0, false ); 
 | 
          } 
 | 
          updatedtrips_o.Add( trip ); 
 | 
        } 
 | 
      } 
 | 
    } 
 | 
  *] 
 | 
  InterfaceProperties { Accessibility: 'Module' } 
 | 
} 
 |