Version 6.0 added an interface for piecewise linear (PWL) objective functions. For constraints, there is no dedicated interface for piecewise linear expressions, but these can be solved easily via special ordered sets of type 2 (SOS-2). For example, suppose you want \( y = f(x) \) where \( f() \) is a piecewise linear function over the points \( (x_1, y_1), ..., (x_n, y_n) \). To do this, add variables \( \lambda_i \) and the constraints:

$$ x = \sum_i \lambda_i x_i $$

$$ y = \sum_i \lambda_i y_i $$

$$ \sum_i \lambda_i = 1 $$

$$ \lambda_i \ge 0 \quad \forall i $$

$$ \lambda_i \in \mathrm{SOS2} \quad \forall i $$

## Comments

0 comments

Article is closed for comments.