# How to omit arithmetic error of MIP solver in JuMP?

Hi all,
I am working on a nonlinear type MIP optimization problem solved through JuMP.
My solution is based on Juniper and HiGHS:

``````using Juniper
using HiGHS
using JuMP
using Ipopt
R10, R20 = 0.18, 0.195

L11, L21 = 2.4, 2.4

Ld_dec = 2.4

w1 = R10 / sum([R10, R20])

w2 = R20 / sum([R10, R20])

lb = 0.42 / Ld_dec

ub = 3.87 / Ld_dec

dec_step = 300

nl_solver = optimizer_with_attributes(Ipopt.Optimizer, "print_level"=>0)

mip_solver = optimizer_with_attributes(HiGHS.Optimizer, "output_flag"=>false)

minlp_solver = optimizer_with_attributes(Juniper.Optimizer, "nl_solver"=>nl_solver, "mip_solver"=>mip_solver)

mfc = Model(minlp_solver)

# set_silent(mfc)

@variable(mfc, u, Bin)

@variable(mfc, v, Bin)

@variable(mfc, 0.0<=x<=ub)

@variable(mfc, 0.0<=y<=ub)

@NLconstraint(mfc, x<=ub*u)

@NLconstraint(mfc, x>=lb*u)

@NLconstraint(mfc, y<=ub*v)

@NLconstraint(mfc, y>=lb*v)

@constraint(mfc, x+y==1)

@NLobjective(mfc, Min, (u*w1 * (x*Ld_dec-L11)^2 + v*w2 * (y*Ld_dec-L21)^2) + (u*w1*(0.01245 + 0.0257 * (x*Ld_dec - 2.38)^2) + v*w2*(0.01245+ 0.0257 * (y*Ld_dec - 2.38)^2)) * dec_step)

optimize!(mfc)

println("x: \$(value(x))")

println("y: \$(value(y))")
``````

I obtained:

``````#branches: 2
Obj: 1.7942803188090848
x: 0.9999999966479224
y: 3.3520777017322965e-9
``````

The expected results should be x=1.0, y=0.0.
This is due to an arithmetic calculation accuracy problem? How can I obtain an ‘accurate’ desired results?
Thank you in advance!

This is due to an arithmetic calculation accuracy problem?

Yes. solvers do not use exact arithmetic, they use tolerances, and will only ever be accurate to their tolerance, which is usually somewhere between 1e-6 and 1e-9.

See

How can I obtain an ‘accurate’ desired results?

You cannot find the exact solution. This is a limitation of numerical solvers.

I see. Thank you very much for the explanation! @odow