! Generic set-based LINGO Transportation model, (ParkingDense.lng)
applied to a parking spot to apartment assignment problem;
! This model is meant to be used with ParkingDensex.xlsx;
! Keywords: Transportation model, Parking;
SETS:
SPOT: CAP; ! Each group of spots has a capacity;
APT: DEM; ! Each apartment group has a demand;
SXA( SPOT, APT): COST, ASSIGN; ! Each combination has a cost.
We want to determine the number to assign to each combination,
so as to minimize the cost (i.e., distance traveled);
ENDSETS DATA:
! This is the dense case, all combinations are possible;
SPOT = @ole(); ! Get list of parking spots from currently open spreadsheet;
CAP = @ole(); ! Get capacity. Will use open spreadsheet if no name;
APT = @ole(); ! Get list of apartments needing parking spots;
DEM = @ole(); ! Get demand of each apartment block;
COST = @ole(); ! and the Cost (distance) of each combination;
ENDDATA
!---------------------------------------------------------;
! Minimize total distance traveled;
[obj] MIN = @SUM(SXA(i,j): COST(i,j) * ASSIGN(i,j));
! Capacity constraints for each group of spots;
@FOR( SPOT( i):
@SUM( SXA(i,J): ASSIGN( I, J)) <= CAP( I);
);
! Demand constraints for each group of apartments;
@FOR( APT( J):
@SUM( SXA( I,j): ASSIGN( I, J)) = DEM( J);
);
DATA:
! Send the results back to the spread sheet
to the range name matching variable name;
@OLE() = ASSIGN;
@OLE()= obj;
ENDDATA
|