Introduction to Optimization example (intmp0)
/***************************************************************/
/* */
/* S A S S A M P L E L I B R A R Y */
/* */
/* NAME: intmp0 */
/* TITLE: Introduction to Optimization example (intmp0) */
/* PRODUCT: OR, GRAPH */
/* SYSTEM: ALL */
/* KEYS: OR */
/* PROCS: OPTMODEL */
/* DATA: */
/* */
/* SUPPORT: UPDATE: */
/* REF: */
/* MISC: Example from the Introduction to Optimization */
/* chapter of Mathematical Programming. */
/* */
/***************************************************************/
/***************************************************************
Model Building: PROC OPTMODEL
***************************************************************/
proc optmodel;
/* declare variables */
var choco >= 0, toffee >= 0;
/* maximize objective function (profit) */
maximize profit = 0.25*choco + 0.75*toffee;
/* subject to constraints */
con process1: 15*choco + 40*toffee <= 27000;
con process2: 56.25*toffee <= 27000;
con process3: 18.75*choco <= 27000;
con process4: 12*choco + 50*toffee <= 27000;
/* solve LP using primal simplex solver */
solve with lp / solver = primal_spx;
/* display solution */
print choco toffee;
quit;
data Products;
length Name $10.;
input Name $ Profit;
datalines;
Chocolate 0.25
Toffee 0.75
;
data Processes;
length Name $15.;
input Name $ Available_time Chocolate Toffee;
datalines;
Cooking 27000 15 40
Color/Flavor 27000 0 56.25
Condiments 27000 18.75 0
Packaging 27000 12 50
;
proc optmodel;
/* declare sets and data indexed by sets */
set <string> Products;
set <string> Processes;
num Profit{Products};
num AvailableTime{Processes};
num RequiredTime{Products,Processes};
/* declare the variable */
var Amount{Products};
/* maximize objective function (profit) */
maximize TotalProfit = sum{p in Products} Profit[p]*Amount[p];
/* subject to constraints */
con Availability{r in Processes}:
sum{p in Products} RequiredTime[p,r]*Amount[p] <= AvailableTime[r];
/* abstract algebraic model that captures the structure of the */
/* optimization problem has been defined without referring */
/* to a single data constant */
/* populate model by reading in the specific data instance */
read data Products into Products=[name] Profit;
read data Processes into Processes=[name] AvailableTime=Available_time
{p in Products} <RequiredTime[p,name]= col(p)>;
/* solve LP using primal simplex solver */
solve with lp / solver = primal_spx;
/* display solution */
print Amount;
quit;