[AMPL 25029] Help! syntax error and why

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:

  1. 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 variable x.
  2. Some solvers can return slightly non-integer values for integer variables, so it’s safer to test x[i,j].val > 0.5 rather than x[i,j].val = 1.

Your question has been moved to our new user forum at discuss.ampl.com, and a response has been posted. To see the response, use this link:

https://discuss.ampl.com/t/ampl-25029-help-syntax-error-and-why/1069/2

To reply, click the red “Reply” button that follows the response. (Do not send an email reply to this message.)