AddPwLinFun
Purpose
Adds piecewise linear function to a TOMLAB MIP problem.
Calling Syntax
There are two ways to call addPwLinFun:
Syntax 1:
function Prob = addPwLinFun(Prob, 1, type, var, funVar, point, slope, a, fa)
Syntax 2:
function Prob = addPwLinFun(Prob, 2, type, var, funVar, firstSlope, point, value, lastSlope)
Inputs
Input | Description |
---|---|
Prob | The problem to add the function to. |
input | Flag indicating syntax used. |
type | A string telling whether to construct a general MIP problem or to construct an MIP problem only solvable by CPLEX. Possible values: 'mip', 'cplex'. |
var | The number of the variable on which the piecewise linear function depends. Must exist in the problem already. |
funVar | The number of the variable which will be equal to the piecewise linear function. Must exist in the problem already. |
firstSlope | Syntax 2 only. The slope of the piecewise linear function left of the first point, point(1). |
point | An array of break points. Must be sorted. If two values occur twice, there is a step at that point. Length r. |
slope | Syntax 1 only. An array of the slopes of the segments.
slope(i) is the slope between point(i-1) and point(i). slope(1) is the slope of the function left of point(1). slope(r+1) is the slope of the function right of point(r). If points(i-1) == points(i), slope(i) is the height of the step. |
value | Syntax 2 only. The values of the piecewise linear function at the points given in point.
f(point(i)) = value(i). If point(i-1) == point(i), value(i-1) is the right limit of the value at the point, and value(i) is the left limit of the value at the point. |
lastSlope | Syntax 2 only. The slope of the piecewise linear function right of the last point, point(r). |
a, fa | Syntax 1 only. The value of the piecewise linear function at point a is equal to fa. f(a) = fa, that is. |
Outputs
Output | Description |
---|---|
Prob | The new problem structure with the piecewise linear function added. New variables and linear constraints added. (MIP problem) |
Description
This function will make one already existing variable of the problem to be constrained equal to a piecewise linear function of another already existing variable in the problem. The independent variable must be bounded in both directions.
The variable constrained to be equal to a piecewise linear function can be used like any other variable; in constraints or the objective function.
Depending on how many segments the function consists of, a number of new variables and constraints are added to the problem.
Increasing the upper bound (x_U) or decreasing the lower bound (x_L) of the independent variable after calling this function will ruin the piecewise linear function.
If the problem is to be solved by CPLEX, set type = 'cplex' to enhance performance. Otherwise, let type = 'mip'. NOTICE! You can not solve a problem with another solver than CPLEX if type = 'cplex'.