This can be formulated by a complementarity constraint:
x[1]*x[3] = 0
However, this is nonlinear (and non-convex). A linear approach can look like:
x[1] <= M*δ
x[3] <= M*(1-δ)
δ ∈ {0,1}
We added a binary variable δ to the problem. I assume here that x[1] and x[3] are non-negative variables, and that M is a reasonable upper bound on x[1] and x[3].
If x[1] and x[3] are free variables (i.e., they can assume positive and negative values), one can write:
-M*δ <= x[1] <= M*δ
-M*(1-δ) <= x[3] <= M*(1-δ)
δ ∈ {0,1}
Notes:
- It is important to choose a value for M with care. It should not be too large, but too small will cut off solutions. It is possible to use different big-M values for the different places we used M instead of just one value.
- If you don't have good bounds available on x[1],x[3] then you can use a SOS1 (Special Ordered Set of Type 1) construct, or indicator constraints (implications). This is a bit more advanced and exotic, so see the AMPL documentation for details on how to use these in AMPL models.
- The above is in "math" notation, but transcribing this into AMPL syntax is not difficult. The first step is always to get the concepts right, and mathematical notation is a good tool for that.