Thank you for your answer.
1) Ok, than I will use that option to get more info about the solution from the solver.
2) I also implemented a small example that seems to work;
dimensions = 5;
x = binvar(dimensions,1,'full');
y = sdpvar(dimensions,1,'full');
con = [];
for index = 1:dimensions
con = con + [0 >= y(index) >= -index*x(index)];
end
obj = ones(1, dimensions) * y;
opts = sdpsettings('verbose',2,'solver','gurobi','debug',1);
for index = 1:2^(dimensions) + 1
diagnostics{index} = solvesdp(con,obj,opts);
diagnostics{index}.info
disp('---------------------------------------------')
if ~strcmp(diagnostics{index}.info(1:12), 'Successfully')
disp('Terminated')
disp(strcat('Infeasible after', [' ', num2str(index - 1)], ' canonical cuts'));
disp(strcat('Number of dimensions are', [' ' ,num2str(dimensions)]))
break
end
x_values{index} = double(x);
y_values{index} = double(y);
x_equal_one = find(x_values{index} == 1);
x_equal_zero = find(x_values{index} == 0);
con = con + [ones(1, length(x_equal_one)) * x(x_equal_one)...
- ones(1,length(x_equal_zero)) * x(x_equal_zero)...
<= length(x_equal_one) - 1];
end
It generates the solutions in the "correct" order, and the objective value function stays the same or decreases after each canonical cut applied. Hence the canonical cuts seems to work (although maybe not implemented in the easiest way). I am not sure that I have multiple optimal solutions to my first problem, but I suspect that I have. What I want to investigate if that is the case, and if so generate a number of them. So I apply the following schema:
0) Iter_count = 0
1) Solve the original problem. Store the solution.
2) IF iter_count < max_iter: Remove current solution. Iter_count = iter_count + 1
2.1) ELSE return the soltuions found so far.
3) Solve the new problem
4) IF objective function value = objective function value of first solution found: another optimal point found. Store this solution. Go to step 2)
4.1) ELSE IF objective function value > objective function value of first solution found OR problem infeasible: no more optimal solutions to the problem. Return the solutions found so far.
4.2 ) ELSE Error message since it should not be possible to get here (then I find better solutions after removing at least one solution, which should not be possible). Returns solutions found for debugging, including the current.
If I have only one optimal solution, I should go through this as 1) -> 2) -> 3) -> 4.1) and thus only return one solution to the optimization problem.
What happens is that when I apply these cuts to remove the current solution, the solver returns solutions that are infeasible with respect to some of the original constraints and have a better objective value, hence I go through it as 1) -> 2) -> 3) -> 4.2). I know there will always be numerical round-offs and such things (therefore I, e.g. do the comparison for objective value is J_new <= J_first + sqrt(eps) ) but the order of magnitude of my continuous variables are 10^3 and the constraint violations are of 10^2 and in some cases even 10^3. Unfortunately the problem I have is vary large: I have around 35 000 binary variables, 15 000 continues variables and the constraints are
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
| ID| Constraint| Type|
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
| #1| Numeric value| Element-wise inequality 500x1|
| #2| Numeric value| Element-wise inequality 26500x1|
| #3| Numeric value| Equality constraint 53x1|
| #4| Numeric value| Element-wise inequality 53x1|
| #5| Numeric value| Element-wise inequality 53x1|
| #6| Numeric value| Element-wise inequality 13197x1|
| #7| Numeric value| Element-wise inequality 13197x1|
| #8| Numeric value| Element-wise inequality 13250x1|
| #9| Numeric value| Element-wise inequality 1250x1|
| #10| Numeric value| Element-wise inequality 1250x1|
| #11| Numeric value| Element-wise inequality 1250x1|
| #12| Numeric value| Element-wise inequality 1250x1|
| #13| Numeric value| Element-wise inequality 1750x1|
| #14| Numeric value| Element-wise inequality 1750x1|
| #15| Numeric value| Equality constraint 5x250|
| #16| Numeric value| Equality constraint 5x250|
| #17| Numeric value| Equality constraint 5x250|
| #18| Numeric value| Equality constraint 5x250|
| #19| Numeric value| Equality constraint 7x250|
| #20| Numeric value| Equality constraint 7x250|
| #21| Numeric value| Element-wise inequality 13250x1|
| #22| Numeric value| Element-wise inequality 250x1|
| #23| Numeric value| Element-wise inequality 250x1|
| #24| Numeric value| Element-wise inequality 34x1|
| #25| Numeric value| Element-wise inequality 34x1|
| #26| Numeric value| Equality constraint 1x250|
| #27| Numeric value| Equality constraint 1x250|
| #28| Numeric value| Element-wise inequality 500x1|
| #29| Numeric value| Element-wise inequality 500x1|
| #30| Numeric value| Element-wise inequality 500x1|
| #31| Numeric value| Element-wise inequality 250x1|
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
so around 100 000 if I am not wrong. I do not know how many of these might be violated, I have just noticed that one of these "sets" of contraints that is put on only continues variables gets violated for some indices. The violation is, as I said, in the same order of magnitude as the variable values (10^2 - 10^3). This is what confuses me, since the solver returns it as if it were a feasible solution. Do you have any idea of why this happens? Could it be that there are so many constraints so that the norm of the violation is somehow still small enough to consider it as feasible?
Best
Axel