JuMP constraint building with dot call: how to use @dot

julia> using JuMP

julia> model = JuMP.Model()

julia> @variable(model, x[1:3])

julia> @variable(model, y[1:3])

julia> @. @constraint(model, x <= y)

gives error: ERROR: At REPL[19]:1: @constraint(model, (<=).(x, y)): Unsupported constraint expression: we don't know how to parse constraints containing expressions of type :..

@constraint(model, @. x <= y) does not work either, with the following error:

ERROR: At REPL[20]:1: `@constraint(model, #= REPL[20]:1 =# @__dot__ x <= y)`: Unsupported constraint expression: we don't know how to parse constraints containing expressions of type :macrocell.

I know that we can write @constraint(model, x .<= y), but the constraint can be much more complex in practice with many dots. Does JuMP support the @. syntax?

No. JuMP does not support the @. syntax. In general, macros do not compose well.

1 Like