|
|
Trees | Indices | Help |
|
|---|
Methods for adding, querying, and modifying PWL constraints.
A PWL constraint describes a piecewise linear relationship between two variables: vary=pwl(varx). The PWL constraint is described by specifying the index of the vary and varx variables involved and by providing the breakpoints of the PWL function (specified by the (breakx[i],breaky[i]) coordinate pairs). Before the first segment of the PWL function there may be a half-line; its slope is specified by preslope. After the last segment of the the PWL function there may be a half-line; its slope is specified by postslope. Two consecutive breakpoints may have the same x coordinate, in such cases there is a discontinuity in the PWL function. Three consecutive breakpoints may not have the same x coordinate.
| Instance Methods | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Inherited from |
|||
| Method Details |
Creates a new PWLConstraintInterface. The PWL constraint interface is exposed by the top-level Cplex class as Cplex.pwl_constraints. This constructor is not meant to be used externally.
|
Returns the number of PWL constraints in the problem. Example usage: >>> import cplex >>> c = cplex.Cplex() >>> c.pwl_constraints.get_num() 0 >>> indices = c.variables.add(names=['y', 'x']) >>> idx = c.pwl_constraints.add(vary='y', varx='x', ... preslope=0.5, postslope=2.0, ... breakx=[0.0, 1.0, 2.0], ... breaky=[0.0, 1.0, 4.0], ... name='pwl1') >>> c.pwl_constraints.get_num() 1 |
Adds a PWL constraint to the problem. vary: the index of the 'y' variable in the vary=pwl(varx) function. varx: the index of the 'x' variable in the vary=pwl(varx) function. preslope: before the first segment of the PWL function there is a half-line; its slope is specified by preslope. postslope: after the last segment of the the PWL function there is a half-line; its slope is specified by postslope. breakx: A list containing the indices of the 'x' variables involved. breaky: A list containing the indices of the 'y' variables involved. name: the name of the PWL constraint; defaults to the empty string. Returns the index of the PWL constraint. Example usage: >>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add(names=['y', 'x']) >>> idx = c.pwl_constraints.add(vary='y', varx='x', ... preslope=0.5, postslope=2.0, ... breakx=[0.0, 1.0, 2.0], ... breaky=[0.0, 1.0, 4.0], ... name='pwl1') >>> c.pwl_constraints.get_num() 1 |
Deletes PWL constraints from the problem. There are four forms by which pwl_constraints.delete may be called.
See CPXdelpwl in the Callable Library Reference Manual for more detail. Example usage: >>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add(names=['y', 'x']) >>> idx = c.pwl_constraints.add(vary='y', varx='x', ... preslope=0.5, postslope=2.0, ... breakx=[0.0, 1.0, 2.0], ... breaky=[0.0, 1.0, 4.0], ... name='pwl1') >>> c.pwl_constraints.get_num() 1 >>> c.pwl_constraints.delete(idx) >>> c.pwl_constraints.get_num() 0 |
Returns the names of a set of PWL constraints. May be called by four forms.
Example usage: >>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add(names=['y', 'x']) >>> idx = c.pwl_constraints.add(vary='y', varx='x', ... preslope=0.5, postslope=2.0, ... breakx=[0.0, 1.0, 2.0], ... breaky=[0.0, 1.0, 4.0], ... name='pwl1') >>> c.pwl_constraints.get_names(idx) 'pwl1' |
Returns the definitions of a set of PWL constraints. Returns a list of PWL definitions, where each definition is a list containing the following components: vary, varx, preslope, postslope, breakx, breaky (see add). May be called by four forms.
Example usage: >>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add(names=['y', 'x']) >>> idx = c.pwl_constraints.add(vary='y', varx='x', ... preslope=0.5, postslope=2.0, ... breakx=[0.0, 1.0, 2.0], ... breaky=[0.0, 1.0, 4.0], ... name='pwl1') >>> c.pwl_constraints.get_definitions(idx) [0, 1, 0.5, 2.0, [0.0, 1.0, 2.0], [0.0, 1.0, 4.0]] |
|
|
Trees | Indices | Help |
|
|---|