# The solution deteriorates if the domain of decisions is improperly set when using Ipopt

**URL:** <https://discourse.julialang.org/t/the-solution-deteriorates-if-the-domain-of-decisions-is-improperly-set-when-using-ipopt/126743>\
**Category:** Optimization (Mathematical)\
**Tags:** jump, ipopt, caveat\
**Created:** [March 10, 2025, 4:47am UTC](https://discourse.julialang.org/t/the-solution-deteriorates-if-the-domain-of-decisions-is-improperly-set-when-using-ipopt/126743 "2025-03-10T04:47:28Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![WalterMadelim](https://avatars.discourse-cdn.com/v4/letter/w/3e96dc/32.png) [@WalterMadelim](https://discourse.julialang.org/u/WalterMadelim)\
**Post date:** [March 15, 2025, 5:36am UTC](https://discourse.julialang.org/t/the-solution-deteriorates-if-the-domain-of-decisions-is-improperly-set-when-using-ipopt/126743/5 "2025-03-15T05:36:06Z")

</div>

We can also employ a global optimizer to do the same task, the correct code should be like this

```julia
import JuMP, MosekTools
CP = JuMP.Model(() -> MosekTools.Optimizer())
JuMP.@variable(CP, t)
JuMP.@variable(CP, x >= 1e-6)
JuMP.@constraint(CP, [-t, x, 1] in JuMP.MOI.ExponentialCone())
JuMP.@objective(CP, Min, t) # minimize `x -> x * log(x)` over positive reals
JuMP.optimize!(CP)
JuMP.assert_is_solved_and_feasible(CP; allow_local = false)

```

A direct extension of this is to solve a (nonconvex) problem that has a “linear times convex” objective. e.g. this nonconvex problem (NC):  
\min\_{x\_1 \> 0, x\_2} \{x\_1 x\_2 \log x\_1 \; | \; 0 \le x\_2 \le 2 \}   
The code example of a convex relaxation (CR) that can solve (NC) to global optimality is as follows:

```julia
import JuMP, MosekTools
CR = JuMP.Model(() -> MosekTools.Optimizer()); JuMP.set_silent(CR);
JuMP.@variable(CR, t);
JuMP.@variable(CR, x[1:2]);
JuMP.set_lower_bound(x[1], 1e-6);
JuMP.set_lower_bound(x[2], 0); JuMP.set_upper_bound(x[2], 2);
JuMP.@variable(CR, X[eachindex(x), eachindex(x)], Symmetric);
# JuMP.set_lower_bound(X[1, 2], 0)
JuMP.@constraint(CR, [-t, X[1, 2], x[2]] in JuMP.MOI.ExponentialCone());
JuMP.@constraint(CR, X[1, 2] <= 2 * x[1]); # VI
JuMP.@objective(CR, Min, t);
JuMP.optimize!(CR)
JuMP.assert_is_solved_and_feasible(CR; allow_local = false)
x = JuMP.value.(x) # [0.3678829664527772, 2.0]
ub = x[2] * x[1] * log(x[1]) # -0.735758882309103
lb = JuMP.objective_bound(CR) # -0.735758881911808

```

In this example, we again discover the fact that:  
although the lb might become tighter after adding the SDP cut, the primal feasible solution **could nonetheless deteriorate**. Therefore it is surely advantageous to collect primal candidate solutions **along the way**.

A related caveat about the function `x -> x * log(x)` is [here](https://discourse.julialang.org/t/reformulation-perspectification-technique-a-code-example-using-jump/126729/3).

---

_[View the full topic](https://discourse.julialang.org/t/the-solution-deteriorates-if-the-domain-of-decisions-is-improperly-set-when-using-ipopt/126743)._
