You are on page 1of 4

Parking Assignment/Transportation model

Inputs: Distance Matrix


Parking Apartments
Parking Cap-
Slots acity A1-2 A3-5 A6-8 A9-29 A30-34 A35-42 A43-49 A50-52 A53-59
P1_7 7 33 26 10 18 22 24 25 33 34
P8_20 13 23 5 6 29 7 8 9 24 21
P21_34 14 42 12 23 43 20 21 8 20 24
P35_43 9 53 29 38 48 24 8 12 23 50
P44_49 6 36 37 48 57 27 23 10 11 36
P50_67 18 19 9 25 49 24 37 21 12 8
P68_79 12 9 13 37 57 35 41 23 29 7
P80_97 18 32 35 58 74 41 35 33 12 20
P98_111 14 24 43 50 73 48 32 31 20 20
P112_139 28 32 46 61 88 51 41 40 29 22

7 6 4 23 10 11 13 9 19

The Results
Number Assigned From Each Apt Block to Each Parking Lot
P1_7
P8_20
P21_34
P35_43
P44_49
P50_67
P68_79
P80_97
P98_111
P112_139

Total travel distance=


A60-62
72
40
36
46
39
31
24
21
13
7

12 <-Demands

otal travel distance=

<==Solution status
If not 0, check lingo.log file.
LINGO Script

MODEL:
SETS:
SPOT: CAP; ! Each group of spots has a capacity;
APT: DEM; ! Each appartment group has a demand;
SXP( SPOT, APT): COST, X; ! Each combination has a cost
and number assigned;
ENDSETS
DATA:
! Get the data from appropriate ranges from current workbook;
SPOT, APT, COST, DEM, CAP= @ole();
ENDDATA

!---------------------------------------------------------;
MIN = TOT_COST;
TOT_COST = @SUM(SXP: COST * X);
@FOR( SPOT( I):
@SUM( APT( J): X( I, J)) <= CAP( I);
);
@FOR( APT( J):
@SUM( SPOT( I): X( I, J)) = DEM( J);
);

DATA:
! Stick the results back in the sheet;
@ole(, 'lingo_status') = @STATUS();
@ole() = X, TOT_COST;
ENDDATA

END
GO !Solve the model;
QUIT !Exit the script processor;

Page 3
1) You may have to set your security level( Tools | Options | Security | Macro Security) to Low,
( or Tools | Macro | Security on older versions),
in order to get Excel to tolerate the macro that is used to run the model.
2) If you add a new row, be sure that you do the Insert | Row in the
strict interior of the list of the current rows section(s), so that ranges get expanded.
If you insert a row at the edge of a range, the new row will not be included
in the range. The LINGO model knows what a datum means based upon the range in which
it appears.
3) If you add a new column, be sure that you do the Insert | Column in the
strict interior, etc.
4) If there seems to be an error in the execution of the model, then look at
the file, lingo.log.

5) You should only have one spreadsheet open at once. Unless you specifically
supply a spreadsheet name, the LINGO model gets its data from the (only)
open .xls file.

You might also like