f1 == f2.
Here f1 and f2 can be any objects for which the
difference f1-f2 yields an affine function.
Inequality constraints are created by expressions of the form
where f1 and f2 can be any objects for which the differencef1 <= f2,f2 >= f1,
f1-f2 yields a convex piecewise-linear function.
The comparison operators first convert the expressions to
f1-f2 == 0, resp. f1-f2 <= 0,
and then return a new constraint object with constraint
function
f1-f2.
In the following example we create three constraints
>>> x = variable(5,'x') >>> c1 = (x <= 1) >>> c2 = (x >= 0) >>> c3 = (sum(x) == 2)
The built-in fucntion len() returns the dimension of the constraint function.
Constraints have four public attributes.
| ) |
'=' if the constraint is an equality constraint,
and '<' if the constraint is an inequality constraint.
| ) |
len(c).
It is used to represent the Lagrange multiplier or dual variable
associated with the constraint.
Its value is initialized as None, and can be modified
by making an assignment to c.multiplier.value.
c.name = 'newname' also
changes
c.multiplier.name to 'newname_mul'.