# Help Regarding a mathematical model

I have made the folloowing model:

set SalesRep;
set Brick;

param distance {i in SalesRep, j in Brick};
param existing {i in SalesRep, j in Brick} binary;

var select {i in SalesRep, j in Brick} binary;

minimize Trans_Cost: sum{(i,j) in SalesRep cross Brick} distance[i,j]*select[i,j];

subject to Representative {j in Brick}:
sum{i in SalesRep} select[i,j] = 1;

subject to Index {i in SalesRep}:
0.8 <= sum{j in Brick} workload[j]*select[i,j] <= 1.2;

The data file for it is:

set SalesRep := SR1 SR2 SR3 SR4;

set Brick := BR1 BR2 BR3 BR4 BR5 BR6 BR7 BR8 BR9 BR10 BR11 BR12 BR13 BR14 BR15 BR16 BR17 BR18 BR19 BR20 BR21 BR22;

BR1 0.1609

BR2 0.1164

BR3 0.1026

BR4 0.1516

BR5 0.0939

BR6 0.132

BR7 0.0687

BR8 0.093

BR9 0.2116

BR10 0.2529

BR11 0.0868

BR12 0.0828

BR13 0.0975

BR14 0.8177

BR15 0.4115

BR16 0.3795

BR17 0.071

BR18 0.0427

BR19 0.1043

BR20 0.0997

BR21 0.1698

BR22 0.2531;

param distance :=

SR1 SR2 SR3 SR4:

BR1 16.16 24.08 24.32 21.12

BR2 19 26.47 27.24 17.33

BR3 25.29 32.49 33.42 12.25

BR4 0 7.93 8.31 36.12

BR5 3.07 6.44 7.56 37.37

BR6 1.22 7.51 8.19 36.29

BR7 2.8 10.31 10.95 33.5

BR8 2.87 5.07 5.67 38.8

BR9 3.8 8.01 7.41 38.16

BR10 12.35 4.52 4.35 48.27

BR11 11.11 3.48 2.97 47.14

BR12 21.99 22.02 24.07 39.86

BR13 8.82 3.3 5.36 43.31

BR14 7.93 0 2.07 43.75

BR15 9.34 2.25 1.11 45.43

BR16 8.31 2.07 0 44.43

BR17 7.31 2.44 1.11 43.43

BR18 7.55 0.75 1.53 43.52

BR19 11.13 18.41 19.26 25.4

BR20 17.49 23.44 24.76 23.21

BR21 11.03 18.93 19.28 25.43

BR22 36.12 43.75 44.43 0;

param existing: SR1 SR2 SR3 SR4:=

BR1 0 0 0 1

BR2 0 0 0 1

BR3 0 0 0 1

BR4 1 0 0 0

BR5 1 0 0 0

BR6 1 0 0 0

BR7 1 0 0 0

BR8 1 0 0 0

BR9 0 0 1 0

BR10 0 1 0 0

BR11 0 1 0 0

BR12 0 1 0 0

BR13 0 1 0 0

BR14 0 1 0 0

BR15 1 0 0 0

BR16 0 0 1 0

BR17 0 0 1 0

BR18 0 0 1 0

BR19 0 0 0 1

BR20 0 0 0 1

BR21 0 0 0 1

BR22 0 0 0 1;

Finally I made a run file:

reset;

model Code2.mod;

data code2.dat;

option solver gurobi;

solve;

display Trans_Cost;

I am receiving the following error:

ampl: include code2.run;

code2.dat, line 29 (offset 475):
expected number
context: SR1 SR2 >>> SR3 <<< SR4:
ampl:

Compare your data for param `distance`,

``````param distance :=
SR1 SR2 SR3 SR4:
BR1 16.16 24.08 24.32 21.12
``````

to the data in the same file for param `existing` (which is correct):

``````param existing: SR1 SR2 SR3 SR4:=
BR1 0 0 0 1
``````

You can see that in the data for `distance`, the := and : characters are in the wrong places. It should be

``````param distance:
SR1 SR2 SR3 SR4:=
BR1 16.16 24.08 24.32 21.12
``````

However, since you defined

``````param distance {i in SalesRep, j in Brick};
``````

then in your data, you would need to have the rows labelled by members of `SalesRep`, and the columns labelled by members of `Brick`. But your data is transposed, with the rows labelled by `Brick` and the columns by `SalesRep`. You need to tell AMPL that the data has been transposed, by adding `(tr)` to the table like this:

``````param distance (tr):
SR1 SR2 SR3 SR4:=
BR1 16.16 24.08 24.32 21.12
``````

The same change needs to be made to the data for `existing`.

Thank you for the reply. Yes it has sorted the issue. Thanks again.