# (binary) solution not satisfying constraint

Hello

I’m solving a small problem with Gurobi, which is given by `println(cover)`=

``````Min slack + slack + slack + slack
Subject to
y + y + y + y + y + y + y + y + y = 2.0
y + y + y + y + y + y + y + y + y + slack ≥ 1.0
y + y + y + y + y + y + slack ≥ 1.0
y + y + y + y + y + y + slack ≥ 1.0
y + y + y + y + y + slack ≥ 1.0
slack ≥ 0.0
slack ≥ 0.0
slack ≥ 0.0
slack ≥ 0.0
y binary
y binary
y binary
y binary
y binary
y binary
y binary
y binary
y binary
``````

The returned solution is `println(value.(y))`=

``````1-dimensional DenseAxisArray{Float64,1,...} with index sets:
Dimension 1, Any[134, 146, 158, 550, 551]
And data, a 5-element Array{Float64,1}:
0.0
0.0
0.0
0.0
1.0
``````

which does not satisfy the first constraint. How is that possible? (I can unfortunately not easily share the code).

Best,

Michael.

What are the values of `raw_status(model)`, `termination_status(model)` and `primal_status(model)`?

``````raw_status(model): Model was solved to optimality (subject to tolerances), and an optimal solution is available.
termination_status(model): OPTIMAL
primal_status(model): FEASIBLE_POINT
``````

By the way, the solution has been found heuristically, as can be seen in the output:

``````Optimize a model with 5 rows, 9 columns and 20 nonzeros
Variable types: 4 continuous, 5 integer (5 binary)
Coefficient statistics:
Matrix range     [1e+00, 1e+00]
Objective range  [1e+00, 1e+00]
Bounds range     [0e+00, 0e+00]
RHS range        [1e+00, 2e+00]
Found heuristic solution: objective 0.0000000

Explored 0 nodes (0 simplex iterations) in 0.00 seconds
Thread count was 1 (of 8 available processors)

Solution count 1: 0

Optimal solution found (tolerance 1.00e-04)
Best objective 0.000000000000e+00, best bound 0.000000000000e+00, gap 0.0000%
``````

Without code, it’s hard to offer advice.

It looks like there is a bug in your code because the printed values have 5 elements, but it looks like your model has many more. Moreover, y appears in the solution, but not in the model.

1 Like

Oops, indeed, I pasted the wrong model. Here comes the correct one:

``````Min slack + slack + slack + slack
Subject to
y + y + y + y + y = 2.0
y + y + y + y + slack ≥ 1.0
y + y + slack ≥ 1.0
y + y + y + slack ≥ 1.0
y + y + slack ≥ 1.0
slack ≥ 0.0
slack ≥ 0.0
slack ≥ 0.0
slack ≥ 0.0
y binary
y binary
y binary
y binary
y binary
``````

I’ll see if I can create a small instance of the bug.