Condition in @objective

A simple reproducible example will show you what is happening. iszero evaluates on the objective expression and returns false, which gets promoted to 0.

julia> using JuMP

julia> model = Model()
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: NO_OPTIMIZER
Solver name: No optimizer attached.

julia> @variable(model, x)
x

julia> iszero(x)
false

julia> @objective(model, Min, iszero(x))
false

julia> objective_function(model)
0

Please ask more targeted questions with simplified reproducible examples.

1 Like