Skip to content

Commit d7d5e9b

Browse files
author
Johan Löfberg
committed
Extract variable bounds when nonlinear operators are used in Gurobi
1 parent 6e8a55a commit d7d5e9b

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

solvers/yalmip2gurobinonlinear.m

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@
9090
K = interfacedata.K;
9191
end
9292

93+
% Normally, YALMIP should not bother about bounds. Solvers are more
94+
% efficient at extracting these from general constraints. However, when
95+
% meta-solvers such as bnb or bmibnb are the origin for the call, they are
96+
% already prepared and should be used. Why is binary clean-up here? No
97+
% idea, maybe some issue in early versions of Gurobi? Can probably be
98+
% removed but kept for now.
9399
if ~isempty(ub)
94100
LB = lb;
95101
UB = ub;
@@ -106,8 +112,14 @@
106112
UB = inf(n,1);
107113
end
108114

109-
if ~isempty(semicont_variables)
110-
% Bounds must be placed in LB/UB
115+
% Although YALMIP assumes bounds are extracted, this is not the case for
116+
% semi-continuous. The structure of these are explicitly communicated in
117+
% the bounds (variable is x=0 or l<=x<=u).
118+
% The presolve routine for nonlinear models is weak and requires explicit
119+
% bounds, so we go here for that case too
120+
if ~isempty(semicont_variables) || ~isempty(interfacedata.evalMap)
121+
% Bounds must be placed in LB/UB for semi-cont, so we go through the
122+
% effort to detect all bounds
111123
[LB,UB,cand_rows_eq,cand_rows_lp] = find_lp_bounds(F_struc,K,LB,UB);
112124
F_struc(K.f+cand_rows_lp,:)=[];
113125
F_struc(cand_rows_eq,:)=[];

0 commit comments

Comments
 (0)