## Specifying Data in AMPL

### One-dimensional sets

set PROD := bands coils plate ;

set STORE := "A&P" JEWEL 'B&W' VONS;

set DAY := '1' '2' '3' '4' '5' '6' '7';

Note: If a string in the list includes any characters other than letters, digits, underscores, period, +, and -, it must be enclosed in quotes. A string looks likea number must also be quoted.

Model: set AREA {PROD};

set AREA[bands] := east north;

### Two-dimensional sets

Model : set ORIG; set DEST; set LINKS with {ORIG, DEST};

set LINKS := (CLEV, DET) (PITT,FRE) (LAF,PITT) (CLEV,PITT);
CLEV DET PITT FRE LAF PITT CLEV PITT;
set LINKS : DET FRE PITT :=
CLEV + - +
PITT - + -
LAF - - +;
( CLEV, *) DET PITT
(PITT, *) FRE
(LAF, *) PITT;

### Higher-dimensional sets

Model: set ROUTES within {ORIG, DEST, PROD};

set ROUTES := (CLEV, DET, coils) (PITT, FRE, bands) (LAF, PITT, bands) (CLEV, PITT, coils);

set ROUTES :=

CLEV DET coils PITT FRE bands

LAF PITT bands CLEV PITT coils;

set ROUTES :=

(CLEV, * ,*) DET coils PITT coils

(PITT, *, *) FRE bands

(LAF, *, *) PITT bands;

set ROUTES :=

set (*,*, coils) : DET FRE PITT :=

CLEV - - -

PITT - + -

LAF - - +

set (*,*, bands) : DET FRE PITT :=

CLEV + - +

PITT - - -

LAF - - - ;

### One-dimensional parameters

#### Unindexed parameters

param avail := 40;

#### Indexed parameters

Model: set PROD; param rate {PROD} > 0;

Data:

set PROD := bands coils plate ;

param rate := bands 200, coils 140, plate 160;

param profit := bands 25, coils 30, plate 39;

param market := bands 6000, coils 4000, plate 3500;

param rate:=

bands 200 coils 140 plate 160;

param: rate profit market :=

bands 200 25 60000

coils 140 30 40000

plate 160 29 3500;

### Two-dimensional parameters

Model: set ORIG; set DEST; param cost {ORIG,DEST} >=0;

Data:

param cost: CLEV PITT LAF:=

CLEV 39 55 55

PITT 50 15 30

LAF 20 21 12;

param cost: CLEV PITT :=

CLEV 39 55

PITT 50 15

LAF 20 21

: LAF :=

CLEV 55

PITT 30

LAF 12;

param cost : DET FRE PITT :=

CLEV 20 . 100

PITT . 50 .

LAF . . 30;

Note: A dot(.) indicates that "no value specified here". You can use a different symbol, say "--", by including the following statement in the data:

Defaultsym "--";

param cost :=

[CLEV,*] DET 20 PITT 100

[PITT,*] PITT 50

[LAF] PITT 30;

### Higher-dimensional parameters:

similar to two-dimensional parameters.

### Default values:

param demand default 1;

param cost {ORIG, DEST, PROD} >=0, default 9999;

param cost {ORIG, DEST, p in PROD} >=0, default huge_cost[p];

param demand default Infinity;