Piecewise linear approximation

From Cornell University Computational Optimization Open Textbook - Optimization Wiki
Jump to navigation Jump to search

Authors: Tianhong Tan, Shoudong Zhu (CHEME 6800, 2021 Fall)

Introduction

Currently, approximating a complex non-linear function or smooth curve is very common in industry area. Like the very popular one, piecewise linear approximation, which is applied in a variety of real-world areas, such as signal processing and image processing in electronics information industry, pattern recognition in AI area[1]. The problem of piecewise linear approximation can be classified by which type of norms applied in approximating process, whether the length of segments is fixed or not and whether the approximation is continuity or discontinuity[2]. We can use piecewise linear approximation to represent any non-linear or linear function by any accuracy order by any accuracy by adding more nodes or segments until the accuracy is met[3]. The meaning of piecewise linear approximation's existence is it allow us to transform non-linear problem to be solved by linear formation, which is easier to be executed by machine and the amount of calculation is acceptable[4].

Theory, Methodology & Algorithms

Basics

For a function in a finite range , one can find sampling points to evaluate the function values. Then the can be approximated by a series of linear segments , where . Any given value between and can be written as the following form:

(1)

is a unique number between and .

The approximation of is calculated by a convex combination of and :

(2)

Algorithm Implementation

Though the piecewise linear approximation is quite straightforward from intuition, it is still necessary to translate the ideas discussed in the above section into some expressions that is easy for the applications in a MILP solver to deal with more complex problems. Therefore, the formulation is further developed to include both binary and continuous variables with several constraints. Then the values are 'pushed' to become associated with the neighboring pair of consecutive break points. The constraints are listed below:

(3)

(4)

(5)

(6)

(7)

's are binary variables while 's are continuous variables from to . (3) indicates that only one takes the value of and all the other 's are . Therefore, (4) imposes that the only two 's that are non-zero are and , which are corresponding to the two neighbors of : and . (5) and (6) ensure that and , which is consistent with the expression of the approximation in (2). Finally, (7) Computes , which is the linear approximation of [5].

The above formulation utilizes the idea of Special Ordered Sets (SOSs), which are powerful tools to model piecewise linear approximation problems [6]. They are defined as ordered sets of variables. In type 1 SOS (S1), only one variable can be non-zero, and 's in (3) form an S1. In type 2 SOS (S2), only two neighboring variables can be non-zero, and 's in (4) form an S2.

More Advanced Developments

To increase the accuracy of the approximation, the simplest way is just to add more nodes. Indeed, this approach can make the approximation sufficiently close to the original function as the the number of sampling points becomes large enough. However, it can be very computationally expensive. Therefore, a question has been posed: given a fixed number of segmentation lines , () and known sampling points , (), how to find a set which denotes the sampling points to be chosen as the end points of the segmentation lines so that the total squared error is minimized. To solve this optimization problem, a dynamic programming framework has been proposed. is defined as the minimum cost to the sampling points with segments. And is the minimum squared error of approximating with one segment. Then the recurrent relation can be written as: . With boundary conditions: ,, (for ), , the problem can be solved, and [7].

Numerical Example

Sampling Points Setting

In this section we consider the trigonometric function , which is widely used in engineering and many other fields, as an example. 9 evenly distributed sampling points is added for the convenience of illustration. And from the following figure, we can see that the approximation straight lines are already close enough to the original sine function just with a small number of sampling points.

Fig.1 Piecewise linear approximation of f(x) = sin(x)

In this example, the piecewise linear approximation of for points , which correspond to , could be computed with the following constraints:

(8)

(9)

(10)

(11)

(12)

Function Value Evaluation

To compute with the above setting, the first thing to do is to determine the two non-zeros 's. In this case, they are and because is between and . Then and can be obtained by solving (10) and (11). Finally, is calculated by (12): , which is basically just a simple interpolation within the range . And it is very close to the exact value: .

It is worth noticing that more sampling points can be added to increase the accuracy of the approximation. And these discretization points do not necessarily to be evenly distributed as what is shown in this example.

Applications

Human Computer Interface (HCI) System

Electrooculogram based human-computer interfaces, which are designed to estimate and predict the position of eyeball are proposed based on bio-signal. However, large scale data that the signaling system produced, like the eyeball’s movement time and eyeball’s position are very hard to handle, piecewise linear approximation is added to modified sliding window algorithms in order to reduce the complexity of the process, which can capture the position of the eyeball’s position in less than 0.2 second.[8].

Wearable Sensors

Piecewise linear approximation algorithms can be applied to orientation sensor signals in order to reduce the amount and the dimension of data, which means that the data can be stored, transmitted and processed with less space. Therefore, wearable sensors will reduce consuming the energy when they are capturing different scenarios, while at the same time it does not lose general trajectory information[9].

Artificial neural network with nonlinear activation function

In artificial neural network, sigmoidal approximation can be finished by Taylor series expansion, Polynomial approximation and look-up table and piecewise linear approximation. But the piecewise linear approximation method is an extremely direct way to approximate sigmoidal function, because all the calculation of nonlinear terms can be done by combining different straight lines of different gradient, which can directly map the inputs to sigmoidal outputs. In this way, it results a very fast approximation and a smarter way to reduce the complexity of non-linear terms[10].

Chemical Plant Planning Optimization

Plant-wide planning optimization of PVC production process is proved to be a mixed integer nonlinear programming (MINLP), where includes highly nonlinear term, like the whole plant energy consumption. As the mixed-integer linear program algorithm is much more mature and efficient than MINLP algorithm, a mathematic model based on piecewise approximation is proposed to approximate the nonlinear terms of the original MINLP model. In such transformation, the original MINLP can be transformed into a MILP model[11].

Conclusion

Piecewise approximation played a key role in deterministic global optimization area, which definitely reduce the complexities of nonlinear items and its simplicity is indispensable for engineers.

References

  1. Manis, G., Papakonstantinou, G., Tsanakas, P.(1997)."Optimal piecewise linear approximation of digitized curves" Proceedings of 13th International Conference on Digital Signal Processing, 1079-1081
  2. Dunham, J. G. (1986). "Optimum Uniform Piecewise Linear Approximation of Planar Curves". IEEE Transactions on Pattern Analysis and Machine Intelligence, 67-75.
  3. Imamoto, A., Tang, B. (2008). Optimal Piecewise Linear Approximation of Convex Functions. Proceedings of the World Congress on Engineering and Computer Science.
  4. Bradley, Hax, Magnanti.(1977). Applied Mathematical Programming, http://web.mit.edu/15.053/www/AppliedMathematicalProgramming.pdf
  5. D'Ambrosio, C., Lodi, A., Martello, S. (2010). Piecewise Linear Approximation of Functions of Two Varibles in MILP Models, Operations Research Letters, 38, 39-46.
  6. Tomlin, J. A., “Special Ordered Sets and an Application to Gas Supply Operations Planning”, Ketron Management Science, Inc., Mountain View, CA 94040-1266, USA.
  7. Camponogara, E., Nazari, L. (2015) Models and Algorithms for Optimal Piecewise-Linear Function Approximation, Mathematical Problems in Engineering, 2015, Article ID 876862. http://dx.doi.org/10.1155/2015/876862
  8. Yang, J. J., Gang, G. W., Kim, T. S. (2018). Development of EOG-Based Human Computer Interface (HCI) System Using Piecewise Linear Approximation (PLA) and Support Vector Regression (SVR). Electronics, 7, 38.
  9. Grützmacher, F., Kempfle, J., Van Laerhoven, K., Haubelt, C. (2021). FastSW: Efficient Piecewise Linear Approximation of Quaternion-Based Orientation Sensor Signals for Motion Capturing with Wearable IMUs. Sensors, 21, 5180.
  10. Mishra, A., Zaheeruddin., Raj, K. (2007). "Implementation of a digital neuron with nonlinear activation function using piecewise linear approximation technique" Internatonal Conference on Microelectronics, 69-72.
  11. Gao, X. Y., Feng, Z. H., Wang, Y. H., Huang, X. L., Huang, D. X., Chen, T., Lian, X. (2018). Industrial & Engineering Chemistry Research, 57 (4), 1233-1244.