Model pwl Parameters ! independent variable x = 6.0 ! data points xp[1] = 1 yp[1] = 1 xp[2] = 2 yp[2] = 0 xp[3] = 3 yp[3] = 2 xp[4] = 3.5 yp[4] = 2.5 xp[5] = 4 yp[5] = 2.8 xp[6] = 5 yp[6] = 3 End Parameters Variables ! piece-wise linear segments x[1] <=xp[2] x[2:4] >xp[2:4], <=xp[3:5] x[5] >xp[5] ! dependent variable y ! slack variables slk_u[1:4] slk_l[2:5] End Variables Intermediates slope[1:5] = (yp[2:6]-yp[1:5]) / (xp[2:6]-xp[1:5]) y[1:5] = (x[1:5]-xp[1:5])*slope[1:5] End Intermediates Equations x = x[1] + slk_u[1] x = x[2:4] + slk_u[2:4] - slk_l[2:4] x = x[5] - slk_l[5] y = yp[1] + y[1] + y[2] + y[3] + y[4] + y[5] End Equations End Model