File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8105,8 +8105,9 @@ cdef class Model:
81058105 coefficient ``lincoef`` associated with the same variable when it
81068106 also appears linearly in the quadratic part.
81078107 linterms : list of tuple
8108- Pairs ``(var, coef)`` for variables that appear only in the pure, i.e.,
8109- variables that do not participate in any quadratic or bilinear term.
8108+ Pairs ``(var, coef)`` for all variables with a nonzero linear
8109+ coefficient in the constraint, including variables that also
8110+ appear in quadratic or bilinear terms.
81108111
81118112 """
81128113 cdef SCIP_EXPR* expr
@@ -8550,7 +8551,7 @@ cdef class Model:
85508551 farkas_coef = SCIPgetVarFarkasCoef(self ._scip, var.scip_var)
85518552 if self .getObjectiveSense() == " maximize" :
85528553 farkas_coef = - farkas_coef
8553- except :
8554+ except Exception :
85548555 raise Warning (" no farkas coefficient available for variable " + var.name)
85558556 return farkas_coef
85568557
Original file line number Diff line number Diff line change @@ -290,13 +290,7 @@ def test_quad_coeffs():
290290
291291
292292def test_quad_coeffs_mixed_linear_and_quadratic ():
293- """ensure getTermsQuadratic exposes all linear coefficients
294293
295- ``linterms`` contains purely linear variables (those that do not appear
296- in the quadratic part). For variables that also appear quadratically,
297- their linear coefficients are stored in the ``lincoef`` component of
298- ``quadterms``.
299- """
300294 scip = Model ()
301295
302296 var1 = scip .addVar (name = "var1" , vtype = 'C' , lb = None )
@@ -324,6 +318,8 @@ def test_quad_coeffs_mixed_linear_and_quadratic():
324318 assert lin_only ["var4" ] == 8
325319 assert lin_only ["var3" ] == 4
326320 assert lin_only ["var2" ] == - 5
321+ # var1 has no linear component and must not appear in linterms
322+ assert "var1" not in lin_only or lin_only .get ("var1" , 0.0 ) == 0.0
327323
328324 # For completeness, checking if the coefficients from reconstructing the full linear
329325 # coefficients from both linterms and quadterms match
You can’t perform that action at this time.
0 commit comments