Hello Johan,
I have an optimization model where exactly the same case occurs, which you have described in your last answer.
(I want to use the implies function to figure out if the value of the elements of the decision variable Q are zero or not. If an element is unequal to zero, it should be marked in the vector t with a "1" and if it is equal to 0, then a "0" should be added to the vector t.)
I have implemented the implies function as described by you with the three cases and the tolerance barrier "tol".
d = binvar(3);
for loop
Constraints = [Constraints, sum(d) == 1, lowerbound <= Q(k,1) <= upperbound, 0 <= t(k,1) <= 1];
Constraints = [Constraints, implies(d(1), [Q(k,1) <= -tol, t(k,1) == 1]) ];
Constraints = [Constraints, implies(d(2), [-tol <= Q(k,1) <= tol, t(k,1) == 0]) ];
Constraints = [Constraints, implies(d(3), [tol <= Q(k,1), t(k,1) == 1]) ];
end
Unfortunately, in some cases the solver sets the value for some elements of Q(k,1) to the value of "tol", even though the objective function would be minimized, if these elements would be 0. (This also leads to some elements in the vector t being marked with a 1, although they are supposed to be 0)
Therefore I would like to ask you if you could explain to me why some elements are set to the value "tol" and if you could help me with this problem.
Many thanks in advance!
Marius