The OPTMODEL Procedure |
You can easily translate the symbolic formulation of a problem into the OPTMODEL procedure. Let's consider the transportation problem, which is mathematically modeled as the following linear programming problem:
where is the set of origins, is the set of destinations, is the cost to transport one unit from to , is the supply of origin , is the demand of destination , and is the decision variable for the amount of shipment from to .
Here is a very simple example. The cities in the set of origins are Detroit and Pittsburgh. The cities in the set of destinations are Boston and New York. The cost matrix, supply, and demand are shown in Table 6.2.
Boston | New York | Supply | |
Detroit | 30 | 20 | 200 |
Pittsburgh | 40 | 10 | 100 |
Demand | 150 | 150 |
The problem is compactly and clearly formulated and solved by using the OPTMODEL procedure with the following code:
proc optmodel; /* specify parameters */ set O={'Detroit','Pittsburgh'}; set D={'Boston','New York'}; number c{O,D}=[30 20 40 10]; number a{O}=[200 100]; number b{D}=[150 150]; /* model description */ var x{O,D} >= 0; min total_cost = sum{i in O, j in D}c[i,j]*x[i,j]; constraint supply{i in O}: sum{j in D}x[i,j]=a[i]; constraint demand{j in D}: sum{i in O}x[i,j]=b[j]; /* solve and output */ solve; print x;
The output is shown in Output 6.4.
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.