Professional Documents
Culture Documents
Parking Assignment/Transportation Model: Inputs
Parking Assignment/Transportation Model: Inputs
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
12 <-Demands
<==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.