object.extractQuadratic
object.extractQuadratic |
Returns the variables and coefficients of the quadratic part of any expression.
vars1, vars2, coef = a.extractQuadratic()
a
|
An expression or variable.
|
vars1
|
A list containing the first variables of each bilinear term composing the quadratic expression in
a.
|
vars2
|
A list containing the second variables of each bilinear term of the quadratic expression in
a.
|
coef
|
A list containing the corresponding coefficients in the quadratic expression.
|
import xpress as xp x = xp.var() y = xp.var() z = xp.var() a = x + 2*y + x*y + 8 * x**2 b = 3*x**2 + z + 4 c = y**2 + x**2 - 6*x*y d = x**5 - 7*x*y - 4*x*y*z # nonlinear expression e = x*y + y*x # note: same bilinear term added twice. This is compressed to 2*x*y print (a.extractQuadratic()) # will print "([C1, C1], [C2,C1], [1,8])" assert (a.extractQuadratic() == ([x,x], [y,x], [1,8])) print (b.extractQuadratic()) # will print "([C1], [C1], [3])" print (c.extractQuadratic()) # will print "([C2, C1], [C2, C1], [1, 1])" print (d.extractQuadratic()) # will print "([C1], [C2], [-7])" print (e.extractQuadratic()) # will print "([C1], [C2], [2])"
© 2001-2019 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.