Sie sind auf Seite 1von 3

Transportation LP Using Excel and LINGO

The cost matrix


Capacity CustA CustB CustC CustD
Demand: 4 7 5 3
Wh1 10 2 6 4 3
Wh2 15 6 6 3 6
Wh3 11 5 3 4 5
0 <= Solution status.
0 is OK, else see lingo.log
TotCost= 53 Recommended Shipments
Wh1 0 0 0 0
Wh2 0 0 0 0
Wh3 0 0 0 0
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.

Das könnte Ihnen auch gefallen