# Condition in @objective

**URL:** <https://discourse.julialang.org/t/condition-in-objective/46526>\
**Category:** Optimization (Mathematical)\
**Created:** [September 12, 2020, 8:43pm UTC](https://discourse.julialang.org/t/condition-in-objective/46526 "2020-09-12T20:43:56Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [September 13, 2020, 8:47pm UTC](https://discourse.julialang.org/t/condition-in-objective/46526/5 "2020-09-13T20:47:17Z")

</div>

A [simple reproducible example](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757/81) will show you what is happening. `iszero` evaluates on the objective expression and returns `false`, which gets promoted to `0`.

```julia
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.

---

_[View the full topic](https://discourse.julialang.org/t/condition-in-objective/46526)._
