@@ -191,12 +191,16 @@ def test_lp(self):
191
191
192
192
class TestGurobiPersistent (unittest .TestCase ):
193
193
def test_nonconvex_qcp_objective_bound_1 (self ):
194
- # the goal of this test is to ensure we can get an objective bound
195
- # for nonconvex but continuous problems even if a feasible solution
196
- # is not found
194
+ # the goal of this test is to ensure we can get an objective
195
+ # bound for nonconvex but continuous problems even if a feasible
196
+ # solution is not found
197
197
#
198
- # This is a fragile test because it could fail if Gurobi's algorithms improve
199
- # (e.g., a heuristic solution is found before an objective bound of -8 is reached
198
+ # This is a fragile test because it could fail if Gurobi's
199
+ # algorithms improve (e.g., a heuristic solution is found before
200
+ # an objective bound of -8 is reached
201
+ #
202
+ # Update: as of Gurobi 11, this test no longer tests the
203
+ # intended behavior (the solver has improved)
200
204
m = pe .ConcreteModel ()
201
205
m .x = pe .Var (bounds = (- 5 , 5 ))
202
206
m .y = pe .Var (bounds = (- 5 , 5 ))
@@ -208,14 +212,22 @@ def test_nonconvex_qcp_objective_bound_1(self):
208
212
opt .gurobi_options ['BestBdStop' ] = - 8
209
213
opt .config .load_solution = False
210
214
res = opt .solve (m )
211
- self .assertEqual (res .best_feasible_objective , None )
215
+ if opt .version () < (11 , 0 ):
216
+ self .assertEqual (res .best_feasible_objective , None )
217
+ else :
218
+ self .assertEqual (res .best_feasible_objective , - 4 )
212
219
self .assertAlmostEqual (res .best_objective_bound , - 8 )
213
220
214
221
def test_nonconvex_qcp_objective_bound_2 (self ):
215
- # the goal of this test is to ensure we can best_objective_bound properly
216
- # for nonconvex but continuous problems when the solver terminates with a nonzero gap
222
+ # the goal of this test is to ensure we can best_objective_bound
223
+ # properly for nonconvex but continuous problems when the solver
224
+ # terminates with a nonzero gap
225
+ #
226
+ # This is a fragile test because it could fail if Gurobi's
227
+ # algorithms change
217
228
#
218
- # This is a fragile test because it could fail if Gurobi's algorithms change
229
+ # Update: as of Gurobi 11, this test no longer tests the
230
+ # intended behavior (the solver has improved)
219
231
m = pe .ConcreteModel ()
220
232
m .x = pe .Var (bounds = (- 5 , 5 ))
221
233
m .y = pe .Var (bounds = (- 5 , 5 ))
@@ -227,7 +239,10 @@ def test_nonconvex_qcp_objective_bound_2(self):
227
239
opt .gurobi_options ['MIPGap' ] = 0.5
228
240
res = opt .solve (m )
229
241
self .assertAlmostEqual (res .best_feasible_objective , - 4 )
230
- self .assertAlmostEqual (res .best_objective_bound , - 6 )
242
+ if opt .version () < (11 , 0 ):
243
+ self .assertAlmostEqual (res .best_objective_bound , - 6 )
244
+ else :
245
+ self .assertAlmostEqual (res .best_objective_bound , - 4 )
231
246
232
247
def test_range_constraints (self ):
233
248
m = pe .ConcreteModel ()
0 commit comments