xpress.pwl
xpress.pwl |
Returns a piecewise linear function over a variable.
xpress.pwl(dict)
dict
|
Python dictionary containing, as keys, two-elements tuples, and, as values, linear expressions in a variable. If the piecewise linear function has only constant values (i.e. it is a piecewise constant function), the independent variable can be specified with the key-value pair
None: x.
|
x = xp.var() # Nonnegative variable y = xp.var(lb=-xp.infinity) # dependent variable, unrestricted t = xp.var() w = xp.var() p = xp.problem(x, y) # Sets a piecewise linear objective: a ramp function p.setObjective (xp.pwl({(-xp.infinity, -1): -2, (-1, 1): 2*x, (1, xp.infinity)]: 2})) p.addConstraint (t == xp.pwl({(1,2): 4*x, (2,4): 2, (4,5): -1})) # Piecewise CONSTANT function: add a key-value pair None: x to specify # independent variable p.addConstraint (t == xp.pwl({(1,2): 4, (2,4): 2, (4,5): -1, None: x})) p.addConstraint (xp.pwl({(-1,0): x, (0,1): 2*x, (1,10): 2}) <= xp.pwl({(0,10): 2*z, (10,20): z+2, (20,xp.infinity): 4}))
© 2001-2020 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.