Lindo Systems

MODEL:! Fleet routing and assignment (fleetras) in LINGO;
! We are given a set of shipments/flights to be made
 between cities, with a specified departure and
 arrival time for each flight. 
 We have several types of vehicles/aircraft
 available.  The assignment part is to decide which vehicle
 is assigned to each flight.  The routing part is to 
 decide how to move each vehicle through the network so
 that it covers the flights assigned to it;
 ! Keywords: airline, routing, fleet routing, assignment,
   trucking, FTL routing;
SETS:  
 CITY :;  ! The cities involved;
 ACRFT:   ! Aircraft types;
  FCOST,  !  Fixed cost per day of this type;
  FSIZE;  !  Max fleet size of this type;
 FLIGHT:;  
 FXCXC( FLIGHT, CITY, CITY) :
  DEPAT,  ! Flight departure time;
  ARVAT;  ! arrival time at dest.;
 AXC( ACRFT, CITY): 
  OVNITE; ! Number staying overnite by type,city;
 AXF( ACRFT, FXCXC): 
  X,      ! Number aircraft used by type,flight;
  PC;     ! Profit contribution by type,flight;
ENDSETS
DATA:
 CITY = ORD  DEN  LAX; ! Cities involved;

 ACRFT, FCOST, FSIZE = ! Aircraft type, fixed cost, fleet size;
  MD90   .01    7
  B737   .01    2;

 FLIGHT = F221 F223 F274 F105 F228 F230 F259 F293 F412 F766 F238;

 FXCXC, DEPAT, ARVAT = 
!     Flight  Origin Dest. Depart Arrive;
         F221   ORD   DEN    800    934
         F223   ORD   DEN    900   1039
         F274   LAX   DEN    800   1116  
         F105   ORD   LAX   1100   1314
         F228   DEN   ORD   1100   1423
         F230   DEN   ORD   1200   1521
         F259   ORD   LAX   1400   1609
         F293   DEN   LAX   1400   1510
         F412   LAX   ORD   1400   1959
         F766   LAX   DEN   1600   1912
         F238   DEN   ORD   1800   2121;
 PC =   ! Profit contribution of each vehicle*flight combo;
  !MD90;   105  109  110  130  106  112  132  115  133  108  116
  !B737;   121  108  115  140  122  115  129  123  135  117  124;
ENDDATA
!-------------------------------------------------------------------;
! Maximize profit contribution from flights minus
   overhead cost of aircraft in fleet;
 MAX = @SUM( AXF( I, N, J, K): PC( I, N, J, K) * X( I, N, J, K))
     - @SUM( AXC( I, J): FCOST( I) * OVNITE( I, J));

! At any instant, departures in particular, the number of 
  cumulative arrivals must be >= number of cumulative departures; 
! For each flight of each aircraft type;
 @FOR( ACRFT( I):
  @FOR( FXCXC( N, J, K):
! Aircraft on ground in morning +
   number aircraft arrived thus far >=
   number aircraft departed thus far;
   OVNITE( I, J) + 
   @SUM( FXCXC( N1, J1, K1)| K1 #EQ# J #AND# 
                             ARVAT( N1, J1, K1) #LT# DEPAT( N, J, K):
               X( I, N1, J1, J)) >= 
   @SUM( FXCXC( N1, J1, K1)| J1 #EQ# J #AND#
                             DEPAT( N1, J1, K1) #LE# DEPAT( N, J, K):
               X( I, N1, J, K1));
         ););

! This model does not allow deadheading, so at the end of the day,
   arrivals must equal departures;
 @FOR( ACRFT( I):
   @FOR( CITY( J):
    @SUM( AXF( I, N, J1, J): X( I, N, J1, J)) =
    @SUM( AXF( I, N, J, K): X( I, N, J, K));
       );
     );

!  Each flight must be covered;
    @FOR( FXCXC( N, J, K):
       @SUM( AXF( I, N, J, K): X( I, N, J, K)) = 1;
        );

! Fleet size limits;
   @FOR( ACRFT( I): 
     @SUM( AXC( I, J): OVNITE( I, J)) <= FSIZE( I);
       ); 
! Fractional planes are not allowed;
   @FOR( AXF: @GIN( X); );
END