To define Route, you can write
param Route {i in Races, j in Races} :=
if x[i,j].val > 0.5 then 1 else 0;
Notes:
- AMPL doesn’t let you define a param in terms of a variable, but you can define Route in terms of
x[i,j].val
which is the current value of the variablex
. - Some solvers can return slightly non-integer values for integer variables, so it’s safer to test
x[i,j].val > 0.5
rather thanx[i,j].val = 1
.