Pastry Model Help

Assume in the pastry rating problem that pastry samples
have different colors, and we also would like to asses the
effect of color (Yellow, Red, or Purple) on the rating.
Assume that the 16 samples have colors
YYRPYRRPPPRRPPYY in the order they appear in the
data set. Adjust the model and data to compute the best
linear regression using three predictors: moisture,
sweetness, color.

MOD and DAT file below:
EA-HW10.mod (800 Bytes)
EA-HW10.dat (621 Bytes)

I keep receiving this error message:

data needs 2 subscripts, not 3
context: sum{v in VARS} sum{c in color} coeff[v] * data[n, v, >>> c] <<< = 1;

expected ; . or number
context: >>> 1 64 4 2 ‘Y’ <<<

I don’t understand what I am doing incorrectly. Please help point me in the right direction.

AMPL is reporting “data needs 2 subscripts, not 3” because you define

set SAMPLES := 1..N;
set NAMES;
param data {SAMPLES,NAMES};

which implies that references to param data should have 2 “subscripts”: They should be like data[i,n] where i is a member of SAMPLES and n is a member of NAMES. You have written data[n,v,c] which has 3 subscripts.

The other error message that you’re seeing has been discussed at at