0% found this document useful (0 votes)
209 views2 pages

Glpk-Sos2 02

Special ordered sets of type 2 (SOS2) constraints are normally used to model piecewise linear functions in convex and non-convex separable programming. A piecewise linear function can be easily modeled using binary variables.

Uploaded by

berndvoges
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
209 views2 pages

Glpk-Sos2 02

Special ordered sets of type 2 (SOS2) constraints are normally used to model piecewise linear functions in convex and non-convex separable programming. A piecewise linear function can be easily modeled using binary variables.

Uploaded by

berndvoges
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1

GLPK GNU Linear Programming Kit A note on modeling piecewise linear functions in GLPK

SOS2 constraints in GLPK


Typeset from an ASCII posting to <[email protected]> from Andrew Makhorin on 02 June 2007. Additional note provided on 22 December 2008. Minor changes made to the text. Prepared by Robbie Morrison <[email protected]>. 23 December 2008. Release 02.
Additional note: piecewise linear functions expressed through SOS2 may be used to model not only non-linear objectives, but also non-linear equality and inequality constraints. This then allows general NLP (non-linear programming) problems to be reformulated as MIP (mixed-integer linear programming) problems. SOS2 constraints: special ordered sets of type 2 (SOS2) constraints are normally used to model piecewise linear functions in convex and non-convex separable programming. In the general case, an SOS2 constraint is completely defined by specifying a set of variables { t 1 , t 2 , , t n } and this is equivalent to the following three constraints:

t 1 , t 2 , , t n 0
t 1 t 2 t n = 1
only two adjacent variables,

ti

and potentially

t i1 , can be non-zero.

Given that we need to model the piecewise linear continuous function

y = f x
specified by its

node points

x 1 , y 1, x2 , y2 , , x n , y n

as shown below.

y (x3, y3) (x2 , y2 ) etc (x1, y1)

(xn , yn )

x
The standard description using an SOS2 constraint is the following:

x = x 1 t 1 x2 t 2 xn t n

y = y1 t 1 y2 t 2 y n t n
SOS2:

{ t 1 , t 2 , , t n }

where the SOS2 variables

t 1 , t 2 , , t n

play the role of interpolation parameters.

The implementation of SOS2 constraints within the simplex method assumes an additional rule to choose the variable to enter the basis. Namely, if t i is basic, only t i1 or t i1 can be basic, while all other SOS2 variables have to be non-basic (and therefore fixed at zero).

2
However, since the set of feasible solutions may be non-convex, such a version of the simplex method enables only a local optimum to be obtained. Modeling piecewise linear functions in GLPK: SOS2 constraints are not implemented in GLPK, but a piecewise linear function can be easily modeled using binary variables as follows. Let

z 1 , z 2 , , z n1

be binary variables, such that

z i {0,1} , where:
si :

zi = 1

means that

xi x xi1

and

yi y yi1

then, with

s1 , s 2 , , s n 1

segment variables, such that

z 1 z 2z n1 = 1
0 si zi
for

i = 1, 2 , , n1

x = y =

x 1 z1 x2 z2 xi zi

x 2 x1 s1 x 3x 2 s 2 x i1 xi si

x n1 z n1 x n xn1 sn1 y1 z1 y2 z 2 y i zi y 2 y 1 s1 y3 y 2 s 2 yi1 yi si

y n1 z n1 yn y n1 s n1

The main advantage of this description is that the MIP solver is always able to find a global optimum. Modeling SOS2 constraints in GLPK: if necessary, SOS2 constraints can be modeled independently when modeling a piecewise linear function thus, Let

{ t 1 , t 2 , , t n } be an SOS2 constraint. Then its equivalent description is the following:


z 1 z 2 z n1 = 1 0 si zi
for

i = 1, 2 , , n1

t1 t2 ti t n1 tn

= z1 s1 = z 2 s2 s 1 = z i si si1 = z n1 sn1 s n2 = s n1
means that only

where

potentially
_____

z 1 , z 2 , , z n1 are binary variables and z i = 1 t i1 are non-zero.

ti

and

Copyright : 2008 Robbie Morrison. All rights reserved. License : Unrestricted reuse in any form, for any purpose. Filename : glpk-sos2_02.odt|pdf Last mod : 23-Dec-2008

You might also like