## Basic Concepts Examples (omod0b)

```/***************************************************************/
/*                                                             */
/*          S A S   S A M P L E   L I B R A R Y                */
/*                                                             */
/*    NAME: omod0b                                             */
/*   TITLE: Basic Concepts Examples (omod0b)                   */
/* PRODUCT: OR                                                 */
/*  SYSTEM: ALL                                                */
/*    KEYS: OR                                                 */
/*   PROCS: OPTMODEL                                           */
/*    DATA:                                                    */
/*                                                             */
/* SUPPORT:                             UPDATE:                */
/*     REF:                                                    */
/*    MISC: Examples from the Basic Concepts section of the    */
/*          OPTMODEL chapter of Mathematical Programming.      */
/*                                                             */
/***************************************************************/

/*  Named Parameters  */
data coeff;
input c_xx c_x c_y c_xy c_yy;
datalines;
1 -1  -2 -1 1
;
proc optmodel;
var x, y;
number c_xx, c_x, c_y, c_xy, c_yy;
read data coeff into c_xx c_x c_y c_xy c_yy;
min z=c_xx*x**2 + c_x*x + c_y*y + c_xy*x*y + c_yy*y**2;
solve;

/*  Indexing  */
proc optmodel;
number p{1..3};
p[1]=5;
p[2]=7;
p[3]=9;
put p[*]=;
quit;

proc optmodel;
number p{i in 1..3} init 3 + 2*i;
put (sum{i in 1..3} p[i]);
quit;

proc optmodel;
number n init 100000;
var x{1..n};
min z = sum{i in 1..n}(x[i] - log(i))**2;
solve;
quit;

/*  Parameters  */
proc optmodel;
number pi=4*atan(1);
number r;
number circum=2*pi*r;
r=1;
put circum;       /* prints 6.2831853072 */
r=2;
put circum;       /* prints 12.566370614 */
quit;

/*  Expressions  */
proc optmodel;
var x init 0.5 >= 0 <= 1;
var y init (0.5 >= 0) <= 1;
print x y;
expand;
quit;

proc optmodel;
number original{i in 1..8} = sin(i);
number sorted{i in 1..8} init original[i];
call sortn(of sorted[*]);
print original sorted;

/*  Index Sets  */

proc optmodel;
put (sum{i in 1..10} i**2);
quit;

```