Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method AddUnitPeriodsForTripHelper ( 
 | 
  UnitPeriod unitperiod, 
 | 
  Trip trip 
 | 
) 
 | 
{ 
 | 
  Description: 'add unit periods to sub puzzle neighborhood based on trip' 
 | 
  TextBody: 
 | 
  [* 
 | 
    // Add the related unit periods to unitperiodsforoptimization (only do this if at least one of the trips is valid) 
 | 
    unitperiod.LibOpt_ScopeAddHelper( relset, this );  
 | 
               
 | 
    // If the trip is from a TransportQuantity Unit, then add the departure period as well, to constrain the transport capacity 
 | 
    if( trip.LaneLeg().Lane().Unit().HasCapacityTypeTransportQuantity() ) 
 | 
    { 
 | 
      departureunitperiod := trip.DepartureUnitPeriod(); 
 | 
       
 | 
      departureunitperiod.LibOpt_ScopeAddHelper( relset, this );   
 | 
    } 
 | 
    else if( trip.LaneLeg().Lane().Unit().HasCapacityTypeTransportTime() ) 
 | 
    { 
 | 
      arrivalunitperiod := trip.ArrivalUnitPeriod();   
 | 
      departureunitperiod := trip.DepartureUnitPeriod(); 
 | 
      current := departureunitperiod;  
 | 
      arrivalstart := guard( arrivalunitperiod.Start(), DateTime::MaxDateTime() );  
 | 
      while( not isnull( current ) and current.Start() <= arrivalstart )  
 | 
      { 
 | 
        current.LibOpt_ScopeAddHelper( relset, this );  
 | 
        current := current.Next().astype( UnitPeriodTransportBase );   
 | 
      } 
 | 
    } 
 | 
  *] 
 | 
  InterfaceProperties { Accessibility: 'Module' } 
 | 
} 
 |