# Numerical Accuracy of the Solver

**URL:** <https://discourse.julialang.org/t/numerical-accuracy-of-the-solver/22297>\
**Category:** Optimization (Mathematical)\
**Tags:** optimization\
**Created:** [March 25, 2019, 11:45am UTC](https://discourse.julialang.org/t/numerical-accuracy-of-the-solver/22297 "2019-03-25T11:45:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rajat\_Sanyal](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@Rajat\_Sanyal](https://discourse.julialang.org/u/Rajat_Sanyal)\
**Post date:** [March 25, 2019, 11:45am UTC](https://discourse.julialang.org/t/numerical-accuracy-of-the-solver/22297/1 "2019-03-25T11:45:27Z")

</div>

I am solving a MIP problem using CPLEX solver. I have the following constraint: x \geq x\_{\min}y, where x is a non-negative variable and y is a binary variable. Let us consider x\_{\min} = 20, but I am getting the optimal solution such as x =0.0001. Though the value is very small but is there any way to get around this issue? Or, I am doing something wrong here.

---

<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:** [March 25, 2019, 2:21pm UTC](https://discourse.julialang.org/t/numerical-accuracy-of-the-solver/22297/2 "2019-03-25T14:21:05Z")

</div>

That constraint is satisfied if y=0? What are you trying to do?

Please read: [Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757).

You may be interested in Gurobi’s documentation on all things numerical: [Gurobi Guidelines for Numerical Issues](http://www.gurobi.com/documentation/8.1/refman/numerics_gurobi_guidelines.html)

---

<div class="post-metadata">

**Author:** ![Rajat\_Sanyal](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@Rajat\_Sanyal](https://discourse.julialang.org/u/Rajat_Sanyal)\
**Post date:** [March 26, 2019, 9:18am UTC](https://discourse.julialang.org/t/numerical-accuracy-of-the-solver/22297/3 "2019-03-26T09:18:26Z")

</div>

Yes, you pointed out correctly. I have one more constraint which I forgot to mention that is x \leq x\_{\max}y.

An example:

```julia
using JuMP, CPLEX, XLSX
import DataFrames

m = Model(with_optimizer(CPLEX.Optimizer))

@variable(m,u[1:5,1:5],lower_bound=0)
@variable(m,x[1:5,1:5],Bin)

c = rand(5,5)

@constraint(m,con1[i=1:5,j=1:5],u[i,j] <= 50*x[i,j])
@constraint(m,con2[i=1:5,j=1:5],u[i,j] >= 20*x[i,j])
@constraint(m,con3[j=1:5],sum(u[i,j] for i=1:5) == 80)

@objective(m,Min,sum((c[i,j]*u[i,j]+0.5*x[i,j]) for i=1:5,j=1:5))

status = optimize!(m)

df1 = DataFrames.DataFrame(JuMP.value.(x))
df2 = DataFrames.DataFrame(JuMP.value.(u))

XLSX.writetable("OUTPUT1.xlsx",
Op = (DataFrames.columns(df1), DataFrames.names(df1)),
Status = (DataFrames.columns(df2), DataFrames.names(df2)))

```

Note that the issue is not occurring for this (small) case. My question is if I get a solution such as x[i,j] = 0.0001 for a particular (i,j), is it because of any bug in the code or is it because of the numerical precision of the solver? If it due to the numerical precision, then is there any way to increase the numerical precision?

---

<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:** [March 26, 2019, 3:59pm UTC](https://discourse.julialang.org/t/numerical-accuracy-of-the-solver/22297/4 "2019-03-26T15:59:19Z")

</div>

Because of the numerical accuracy of the solver.

See

> **[integrality tolerance](https://www.ibm.com/docs/en/icos/12.9.0?topic=parameters-integrality-tolerance)**
>
> Specifies the amount by which an integer variable can be different from an integer and still be considered feasible.

`with_optimizer(CPLEX.Optimizer, CPLEX.CPX_PARAM_EPINT=1e-8)`

---

<div class="post-metadata">

**Author:** ![Rajat\_Sanyal](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@Rajat\_Sanyal](https://discourse.julialang.org/u/Rajat_Sanyal)\
**Post date:** [March 27, 2019, 12:29pm UTC](https://discourse.julialang.org/t/numerical-accuracy-of-the-solver/22297/5 "2019-03-27T12:29:59Z")

</div>

It is giving me the following error:

> LoadError: syntax: invalid keyword argument name “CPLEX.CPX\_PARAM\_EPINT”

for the following line:

```julia
m = Model(with_optimizer(CPLEX.Optimizer, CPLEX.CPX_PARAM_EPINT=1e-8))

```

---

<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:** [March 27, 2019, 12:37pm UTC](https://discourse.julialang.org/t/numerical-accuracy-of-the-solver/22297/6 "2019-03-27T12:37:32Z")

</div>

Oops. It might just be `(CPLEX.Optimizer, CPX_PARAM_EPINT=1e-8)`. I don’t have CPLEX so I haven’t tried.

---

<div class="post-metadata">

**Author:** ![Rajat\_Sanyal](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@Rajat\_Sanyal](https://discourse.julialang.org/u/Rajat_Sanyal)\
**Post date:** [March 27, 2019, 12:43pm UTC](https://discourse.julialang.org/t/numerical-accuracy-of-the-solver/22297/7 "2019-03-27T12:43:02Z")

</div>

> [@odow](#):
>
> CPX\_PARAM\_EPINT=1e-8

Thanks that works perfectly fine. 🙂
