/*----------------------------------------------------------------
S A S S A M P L E L I B R A R Y
NAME: omodg01
TITLE: Getting Started Examples (omodg01)
PRODUCT: OR
SYSTEM: ALL
KEYS: OR
PROCS: OPTMODEL
DATA:
SUPPORT: UPDATE:
REF:
MISC: Examples from the Getting Started section of the
OPTMODEL chapter of Mathematical Programming.
----------------------------------------------------------------*/
/* An Unconstrained Optimization Example */
/* invoke procedure */
proc optmodel;
var x, y; /* declare variables */
/* objective function */
min z=x**2 - x - 2*y - x*y + y**2;
/* now run the solver */
solve;
print x y;
quit;
/* The Rosenbrock Problem */
proc optmodel;
number alpha = 100; /* declare parameter */
var x {1..2}; /* declare variables */
/* objective function */
min f = alpha*(x[2] - x[1]**2)**2 +
(1 - x[1])**2;
/* now run the solver */
solve;
print x;
quit;
/* A Transportation Problem */
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;
quit;