[go: up one dir, main page]

0% found this document useful (0 votes)
88 views3 pages

Transportation LP Using Excel and LINGO: The Cost Matrix

The document describes a transportation problem modeled in LINGO using Excel data. It includes a cost matrix, warehouse capacities, and customer demands. The LINGO script defines sets and variables to minimize total cost subject to meeting demands from available capacities. It retrieves data from the open Excel file, solves the model, and returns the solution status and optimal shipments back to Excel.

Uploaded by

james
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLS, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views3 pages

Transportation LP Using Excel and LINGO: The Cost Matrix

The document describes a transportation problem modeled in LINGO using Excel data. It includes a cost matrix, warehouse capacities, and customer demands. The LINGO script defines sets and variables to minimize total cost subject to meeting demands from available capacities. It retrieves data from the open Excel file, solves the model, and returns the solution status and optimal shipments back to Excel.

Uploaded by

james
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLS, PDF, TXT or read online on Scribd
You are on page 1/ 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.

You might also like