Sunteți pe pagina 1din 3

Transportation LP Using Excel and LINGO

The cost matrix


Capacity
Demand:
Wh1
Wh2
Wh3

10
15
11

CustA
4
2
6
5

CustB
7
6
6
3

CustC
5
4
3
4

CustD
3
3
6
5
0 <= Solution status.
0 is OK, else see lingo.log

TotCost=
Wh1
Wh2
Wh3

53

Recommended Shipments

LINGO Script
MODEL:
SETS:
SOURCE: CAPACITY;
DEST: DEMAND;
SXD( SOURCE, DEST): COST, X;
ENDSETS
DATA:
! Get data from currently open spreadsheet;
SOURCE = @OLE( );
DEST = @OLE( );
COST = @OLE( );
CAPACITY = @OLE( );
DEMAND = @OLE( );
ENDDATA
MIN = TOTCOST;
TOTCOST = @SUM( SXD(I,J): COST(I,J)*X(I,J));
@FOR( SOURCE(I):
@SUM( SXD(I,J): X(I,J)) <= CAPACITY(I);
);
@FOR( DEST(J):
@SUM( SXD(I,J): X(I,J)) = DEMAND(J);
);
DATA: ! Put results back in spreadsheet;
@OLE( ) = @STATUS();
@OLE( ) = X;
@OLE( ) = TOTCOST;
ENDDATA
END
GO
QUIT

Page 2

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.

S-ar putea să vă placă și