Apps.PiecewiseLinear History

Hide minor edits - Show changes to markup

February 13, 2013, at 10:09 AM by 69.169.188.188 -
Added lines 63-65:
    minimize slk_u[1:4]
    minimize slk_l[2:5]
Changed line 83 from:

File *.m.csv

to:

File m.csv

August 27, 2010, at 10:16 PM by 206.180.155.75 -
Added lines 68-113:
  End Equations

End Model </pre></font> (:htmlend:)


(:html:)<font size=2><pre>

Piece-wise function with the LOOKUP object

create the csv file

File *.m.csv

  input,  y[1],  y[2]
      1,     2,    4
      3,     4,    6
      5,    -5,   -7
     -1,     1,  0.5

End File

define lookup object m

Objects

  m = lookup

End Objects

connect m properties with model parameters

Connections

  x = m.input
  y[1] = m.y[1]
  y[2] = m.y[2]

End Connections

simple model

Model n

  Parameters
    x = 1
    y[1]
    y[2]
  End Parameters

  Variables
    y
  End Variables

  Equations
    y = y[1]+y[2]
March 06, 2010, at 02:45 AM by 206.180.155.75 -
Changed line 17 from:

(:html:)<font size=1><pre>

to:

(:html:)<font size=2><pre>

Changed line 71 from:

(:htmlend:)

to:

(:htmlend:)

April 23, 2009, at 10:46 AM by 158.35.225.231 -
Changed lines 15-71 from:
to:

(:html:)<font size=1><pre> 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 </pre></font> (:htmlend:)

February 23, 2009, at 07:45 AM by 158.35.225.228 -
Added lines 1-15:

Piece-wise Linear Approximation

A piece-wise linear function is an approximation of a nonlinear relationship. For more nonlinear relationships, additional linear segments are added to refine the approximation.

As an example, the piecewise linear form is often used to approximate valve characterization (valve position (% open) to flow). This is a single input-single output function approximation.

In Situ Adaptive Tabulation (ISAT) is an example of a multi-dimensional piecewise linear approximation. The piecewise linear segments are built dynamically as new data becomes available. This way, only regions that are accessed in practice contribute to the function approximation.