0
votes

I cannot put the whole code here, and was not able to reproduce the problem with a small code, but here is the beginning of the code:

using JuMP, Cbc, StatsBase

n = 3;
V = 1:(2n+1);

model = Model(with_optimizer(Cbc.Optimizer, seconds=120));

@variable(model, x[V], Bin);

...

@objective(model, Min, total_blah);

JuMP.optimize!(model)
result = termination_status(model)

JuMP.objective_value(model)

xsol = JuMP.value.(x);

The problem I have is that the solver returns a solution where some of the xsol have values like 0.99995, where I am expecting Binary, ie either 0 or 1.

Can someone explain this behavior?

1
Can you link to the code? - Oscar Smith
Maybe the solver is not able to find a feasible solution within the 120 second time limit that you set? Instead of using a time limit, you could try setting maxSolutions=1 or set ratioGap to something large enough that the solver terminates in a reasonable time. - Cameron Bieganek
Solvers have an Integer feasibility tolerance. I believe CBC uses a default of 1e-6 for this. - Erwin Kalvelagen

1 Answers

1
votes

I looked this up and CBC has an option called integerTolerance (or integerT) that helps CBC to decide whether a variable is integer valued. Using CBC.exe, I see:

Coin:integerTolerance
integerTolerance has value 1e-006

Indeed the default is 1e-6. You cannot set it to zero but you can make it smaller (valid range is 1e-020 to 0.5). (The only solver I know of that allows this tolerance to be set to zero is Cplex; usually doing that leads to longer solution times).

In general I would advice to keep it as it is. If small deviations from integer values irritate you, I would round integer variables in the solution before printing. This gives better looking solutions (but this rounding step may make the solution slightly infeasible).