# Gurobi integer programming not working

I’m trying to do an integer programming problem with GUROBI in MATLAB. My code is the following:

``````function[d, uu, ul, cprime, c, b, u, cvx_optval] = demandresponse1(n)

d = randn(1);
bnds = randn(n,2);
uu = max(bnds, [], 2);
ul = min(bnds, [], 2);
uhat = (uu+ul)/2; %this is the average of the upper and lower bounds
cprime = randn(n, 1);
c = randn(n, 1);

%Start the CVX optimization
cvx_begin
variable u(n);
variable b(n) binary;
minimize((d - sum(u))^2 + sum(cprime.*b  + (c.^2).*(u-b.*uhat).^2));
subject to
(b.*ul) <= u <= (b.*uu);
cvx_end

end
``````

In the above, I declare `variable b(n) binary`. But when I actually run the optimization, I get the following output. `b` is not an array of binary values; what happened?

``````>> [d, uu, u, b, u] = demandresponse1(5)

Calling Gurobi 5.60: 33 variables, 17 equality constraints
------------------------------------------------------------
Optimize a model with 17 rows, 33 columns and 53 nonzeros
Presolve removed 0 rows and 10 columns
Presolve time: 0.01s
Presolved: 35 rows, 41 columns, 79 nonzeros
Variable types: 36 continuous, 5 integer (5 binary)

Root relaxation: objective -7.947353e+00, 3 iterations, 0.00 seconds

Nodes    |    Current Node    |     Objective Bounds      |     Work
Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time

H    0     0                      -0.1941943   -7.94735  3992%     -    0s
0     0   -0.26352    0    1   -0.19419   -0.26352  35.7%     -    0s
0     0   -0.22958    0    1   -0.19419   -0.22958  18.2%     -    0s
0     0   -0.22938    0    1   -0.19419   -0.22938  18.1%     -    0s
0     0   -0.22938    0    1   -0.19419   -0.22938  18.1%     -    0s

Cutting planes:
Gomory: 1

Explored 3 nodes (39 simplex iterations) in 0.06 seconds
Thread count was 2 (of 2 available processors)

Optimal solution found (tolerance 1.00e-04)
Best objective -1.941942815787e-01, best bound -1.941976010650e-01, gap 0.0017%
------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): -0.194194

d =

0.5377

uu =

1.8339
0.3426
3.5784
2.7694
-1.3077

u =

-0.1241
1.4897
1.4090
1.4172
0.6715

b =

3.0349
0.7254
-0.0631
0.7147
-0.2050

u =

-0.1241
1.4897
1.4090
1.4172
0.6715``````

Looks like a bug; I would suggest submitting a report to http://support.cvxr.com with the necessary data and info to reproduce the problem.

I had the exact same problem, any news on this?