~ubuntu-branches/ubuntu/maverick/commons-math/maverick

« back to all changes in this revision

Viewing changes to src/site/xdoc/userguide/optimization.xml

  • Committer: Bazaar Package Importer
  • Author(s): Damien Raude-Morvan
  • Date: 2009-08-22 01:13:25 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090822011325-hi4peq1ua5weguwn
Tags: 2.0-1
* New upstream release.
* Set Maintainer field to Debian Java Team
* Add myself as Uploaders
* Switch to Quilt patch system:
  - Refresh all patchs
  - Remove B-D on dpatch, Add B-D on quilt
  - Include patchsys-quilt.mk in debian/rules
* Bump Standards-Version to 3.8.3:
  - Add a README.source to describe patch system
* Maven POMs:
  - Add a Build-Depends-Indep dependency on maven-repo-helper
  - Use mh_installpom and mh_installjar to install the POM and the jar to the
    Maven repository
* Use default-jdk/jre:
  - Depends on java5-runtime-headless
  - Build-Depends on default-jdk
  - Use /usr/lib/jvm/default-java as JAVA_HOME
* Move api documentation to /usr/share/doc/libcommons-math-java/api
* Build-Depends on junit4 instead of junit

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
  -->
19
19
  
20
20
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
21
 
<!-- $Revision: 480435 $ $Date: 2006-11-29 08:06:35 +0100 (mer., 29 nov. 2006) $ -->
 
21
<!-- $Revision: 799857 $ $Date: 2009-08-01 09:07:12 -0400 (Sat, 01 Aug 2009) $ -->
22
22
<document url="optimization.html">
23
23
 
24
24
  <properties>
26
26
  </properties>
27
27
 
28
28
  <body>
29
 
    <section name="13 Optimization">
30
 
      <subsection name="13.1 Overview" href="overview">
31
 
        <p>
32
 
          The optimization package provides simplex-based direct search optimization algorithms.
33
 
        </p>
34
 
        <p>
35
 
          The aim of this package is similar to the aim of the estimation package, but the
36
 
          algorithms are entirely differents as:
 
29
    <section name="12 Optimization">
 
30
      <subsection name="12.1 Overview" href="overview">
 
31
        <p>
 
32
          The optimization package provides algorithms to optimize (i.e. either minimize
 
33
          or maximize) some objective or cost function. The package is split in several
 
34
          sub-packages dedicated to different kind of functions or algorithms.
37
35
          <ul>
38
 
            <li>
39
 
              they do not need the partial derivatives of the measurements
40
 
              with respect to the free parameters
41
 
            </li>
42
 
            <li>
43
 
              they do not rely on residuals-based quadratic cost functions but
44
 
              handle any cost functions, including non-continuous ones! 
45
 
            </li>
 
36
            <li>the univariate package handles univariate scalar functions,</li>
 
37
            <li>the linear package handles multivariate vector linear functions
 
38
                with linear constraints,</li>
 
39
            <li>the direct package handles multivariate scalar functions
 
40
            using direct search methods (i.e. not using derivatives),</li>
 
41
            <li>the general package handles multivariate scalar or vector functions
 
42
            using derivatives.</li>
 
43
            <li>the fitting package handles curve fitting by univariate real functions</li>
46
44
          </ul>
47
45
        </p>
48
 
      </subsection>
49
 
      <subsection name="13.2 Direct Methods" href="direct">
 
46
        <p>
 
47
        The top level optimization package provides common interfaces for the optimization
 
48
        algorithms provided in sub-packages. The main interfaces defines defines optimizers
 
49
        and convergence checkers. The functions that are optimized by the algorithms provided
 
50
        by this package and its sub-packages are a subset of the one defined in the
 
51
        <code>analysis</code> package, namely the real and vector valued functions. These
 
52
        functions are called objective function here. When the goal is to minimize, the
 
53
        functions are often called cost function, this name is not used in this package.
 
54
        </p>
 
55
        <p>
 
56
        The type of goal, i.e. minimization or maximization, is defined by the enumerated
 
57
        <a href="../apidocs/org/apache/commons/math/optimization/GoalType.html">
 
58
        GoalType</a> which has only two values: <code>MAXIMIZE</code> and <code>MINIMIZE</code>.
 
59
        </p>
 
60
        <p>
 
61
        Optimizers are the algorithms that will either minimize or maximize, the objective
 
62
        function by changing its input variables set until an optimal set is found. There
 
63
        are only four interfaces defining the common behavior of optimizers, one for each
 
64
        supported type of objective function:
 
65
        <ul>
 
66
          <li><a href="../apidocs/org/apache/commons/math/optimization/UnivariateRealOptimizer.html">
 
67
              UnivariateRealOptimizer</a> for <a
 
68
              href="../apidocs/org/apache/commons/math/analysis/UnivariateRealFunction.html">
 
69
              univariate real functions</a></li>
 
70
          <li><a href="../apidocs/org/apache/commons/math/optimization/MultivariateRealOptimizer.html">
 
71
              MultivariateRealOptimizer</a> for <a
 
72
              href="../apidocs/org/apache/commons/math/analysis/MultivariateRealFunction.html">
 
73
              multivariate real functions</a></li>
 
74
          <li><a href="../apidocs/org/apache/commons/math/optimization/DifferentiableMultivariateRealOptimizer.html">
 
75
              DifferentiableMultivariateRealOptimizer</a> for <a
 
76
              href="../apidocs/org/apache/commons/math/analysis/DifferentiableMultivariateRealFunction.html">
 
77
              differentiable multivariate real functions</a></li>
 
78
          <li><a href="../apidocs/org/apache/commons/math/optimization/DifferentiableMultivariateVectorialOptimizer.html">
 
79
              DifferentiableMultivariateVectorialOptimizer</a> for <a
 
80
              href="../apidocs/org/apache/commons/math/analysis/DifferentiableMultivariateVectorialFunction.html">
 
81
              differentiable multivariate vectorial functions</a></li>
 
82
        </ul>
 
83
        </p>
 
84
 
 
85
        <p>
 
86
        Despite there are only four types of supported optimizers, it is possible to optimize
 
87
        a transform a <a
 
88
        href="../apidocs/org/apache/commons/math/analysis/MultivariateVectorialFunction.html">
 
89
        non-differentiable multivariate vectorial function</a> by converting it to a <a
 
90
        href="../apidocs/org/apache/commons/math/analysis/MultivariateRealFunction.html">
 
91
        non-differentiable multivariate real function</a> thanks to the <a
 
92
        href="../apidocs/org/apache/commons/math/optimization/LeastSquaresConverter.html">
 
93
        LeastSquaresConverter</a> helper class. The transformed function can be optimized using
 
94
        any implementation of the <a
 
95
        href="../apidocs/org/apache/commons/math/optimization/MultivariateRealOptimizer.html">
 
96
        MultivariateRealOptimizer</a> interface.
 
97
        </p>
 
98
 
 
99
        <p>
 
100
        For each of the four types of supported optimizers, there is a special implementation
 
101
        which wraps a classical optimizer in order to add it a multi-start feature. This feature
 
102
        call the underlying optimizer several times in sequence with different starting points
 
103
        and returns the best optimum found or all optima if desired. This is a classical way to
 
104
        prevent being trapped into a local extremum when looking for a global one.
 
105
        </p>
 
106
      </subsection>
 
107
      <subsection name="12.2 Univariate Functions" href="univariate">
 
108
        <p>
 
109
          A <a href="../apidocs/org/apache/commons/math/optimization/UnivariateRealOptimizer.html">
 
110
          UnivariateRealOptimizer</a> is used to find the minimal values of a univariate real-valued
 
111
          function <code>f</code>.
 
112
        </p>
 
113
        <p>
 
114
          These algorithms usage is very similar to root-finding algorithms usage explained
 
115
          in the analysis package. The main difference is that the <code>solve</code> methods in root
 
116
          finding algorithms is replaced by <code>optimize</code> methods.
 
117
        </p>
 
118
      </subsection>
 
119
      <subsection name="12.3 Linear Programming" href="linear">
 
120
        <p>
 
121
          This package provides an implementation of George Dantzig's simplex algorithm
 
122
          for solving linear optimization problems with linear equality and inequality
 
123
          constraints.
 
124
        </p>
 
125
      </subsection>
 
126
      <subsection name="12.4 Direct Methods" href="direct">
50
127
        <p>
51
128
          Direct search methods only use cost function values, they don't
52
129
          need derivatives and don't either try to compute approximation of
77
154
          already provided by the <code>minimizes</code> method).
78
155
        </p>
79
156
        <p>
80
 
          The package provides two solvers. The first one is the classical
81
 
          <a href="../apidocs/org/apache/commons/math/optimization/NelderMead.html">
 
157
          The <code>direct</code> package provides two solvers. The first one is the classical
 
158
          <a href="../apidocs/org/apache/commons/math/optimization/direct/NelderMead.html">
82
159
          Nelder-Mead</a> method. The second one is Virginia Torczon's
83
 
          <a href="../apidocs/org/apache/commons/math/optimization/MultiDirectional.html">
 
160
          <a href="../apidocs/org/apache/commons/math/optimization/direct/MultiDirectional.html">
84
161
          multi-directional</a> method.
85
162
        </p>
86
163
      </subsection>
 
164
      <subsection name="12.5 General Case" href="general">
 
165
        <p>
 
166
          The general package deals with non-linear vectorial optimization problems when
 
167
          the partial derivatives of the objective function are available.
 
168
        </p>
 
169
        <p>
 
170
          One important class of estimation problems is weighted least
 
171
          squares problems. They basically consist in finding the values
 
172
          for some parameters p<sub>k</sub> such that a cost function
 
173
          J = sum(w<sub>i</sub>(mes<sub>i</sub> - mod<sub>i</sub>)<sup>2</sup>) is
 
174
          minimized. The various (target<sub>i</sub> - model<sub>i</sub>(p<sub>k</sub>))
 
175
          terms are called residuals. They represent the deviation between a set of
 
176
          target values target<sub>i</sub> and theoretical values computed from
 
177
          models model<sub>i</sub> depending on free parameters p<sub>k</sub>.
 
178
          The w<sub>i</sub> factors are weights. One classical use case is when the
 
179
          target values are experimental observations or measurements.
 
180
        </p>
 
181
        <p>
 
182
          Solving a least-squares problem is finding the free parameters p<sub>k</sub>
 
183
          of the theoretical models such that they are close to the target values, i.e.
 
184
          when the residual are small.
 
185
        </p>
 
186
        <p>
 
187
          Two optimizers are available in the general package, both devoted to least-squares
 
188
          problems. The first one is based on the <a
 
189
          href="../apidocs/org/apache/commons/math/optimization/general/GaussNewtonOptimizer.html">
 
190
          Gauss-Newton</a> method. The second one is the <a
 
191
          href="../apidocs/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizer.html">
 
192
          Levenberg-Marquardt</a> method.
 
193
        </p>
 
194
        <p>
 
195
          In order to solve a vectorial optimization problem, the user must provide it as
 
196
          an object implementing the <a
 
197
          href="../apidocs/org/apache/commons/math/analysis/DifferentiableMultivariateVectorialFunction.html">
 
198
          DifferentiableMultivariateVectorialFunction</a> interface. The object will be provided to
 
199
          the <code>estimate</code> method of the optimizer, along with the target and weight arrays,
 
200
          thus allowing the optimizer to compute the residuals at will. The last parameter to the
 
201
          <code>estimate</code> method is the point from which the optimizer will start its
 
202
          search for the optimal point.
 
203
        </p>
 
204
        <p>
 
205
          In addition to least squares solving, the <a
 
206
          href="../apidocs/org/apache/commons/math/optimization/general/NonLinearConjugateGradientOptimizer.html">
 
207
          NonLinearConjugateGradientOptimizer</a> class provides a non-linear conjugate gradient algorithm
 
208
          to optimize <a
 
209
          href="../apidocs/org/apache/commons/math/optimization/DifferentiableMultivariateRealFunction.html">
 
210
          DifferentiableMultivariateRealFunction</a>. Both the Fletcher-Reeves and the Polak-Ribi&#232;re
 
211
          search direction update methods are supported. It is also possible to set up a preconditioner
 
212
          or to change the line-search algorithm of the inner loop if desired (the default one is a Brent
 
213
          solver).
 
214
        </p>
 
215
      </subsection>
 
216
      <subsection name="12.6 Curve Fitting" href="fitting">
 
217
        <p>
 
218
          The fitting package deals with curve fitting for univariate real functions.
 
219
          When a univariate real function y = f(x) does depend on some unknown parameters
 
220
          p<sub>0</sub>, p<sub>1</sub> ... p<sub>n-1</sub>, curve fitting can be used to
 
221
          find these parameters. It does this by <em>fitting</em> the curve so it remains
 
222
          very close to a set of observed points (x<sub>0</sub>, y<sub>0</sub>),
 
223
          (x<sub>1</sub>, y<sub>1</sub>) ... (x<sub>k-1</sub>, y<sub>k-1</sub>). This
 
224
          fitting is done by finding the parameters values that minimizes the objective
 
225
          function sum(y<sub>i</sub>-f(x<sub>i</sub>))<sup>2</sup>. This is really a least
 
226
          squares problem.
 
227
        </p>
 
228
        <p>
 
229
          For all provided curve fitters, the operating principle is the same. Users must first
 
230
          create an instance of the fitter, then add the observed points and once the complete
 
231
          sample of observed points has been added they must call the <code>fit</code> method
 
232
          which will compute the parameters that best fit the sample. A weight is associated
 
233
          with each observed point, this allows to take into account uncertainty on some points
 
234
          when they come from loosy measurements for example. If no such information exist and
 
235
          all points should be treated the same, it is safe to put 1.0 as the weight for all points.
 
236
        </p>
 
237
        <p>
 
238
          The <a
 
239
          href="../apidocs/org/apache/commons/math/optimization/fitting/CurveFitter.html">
 
240
          CurveFitter</a> class provides curve fitting for general curves. Users must
 
241
          provide their own implementation of the curve template as a class implementing
 
242
          the <a
 
243
          href="../apidocs/org/apache/commons/math/optimization/fitting/ParametricRealFunction.html">
 
244
          ParametricRealFunction</a> interface and they must provide the initial guess of the
 
245
          parameters. The more specialized <a
 
246
          href="../apidocs/org/apache/commons/math/optimization/fitting/PolynomialFitter.html">
 
247
          PolynomialFitter</a> and <a
 
248
          href="../apidocs/org/apache/commons/math/optimization/fitting/HarmonicFitter.html">
 
249
          HarmonicFitter</a> classes require neither an implementation of the parametric real function
 
250
          not an initial guess as they are able to compute them by themselves.
 
251
        </p>
 
252
        <p>
 
253
          An example of fitting a polynomial is given here:
 
254
        </p>
 
255
        <source>PolynomialFitter fitter = new PolynomialFitter(degree, new LevenbergMarquardtOptimizer());
 
256
fitter.addObservedPoint(-1.00,  2.021170021833143);
 
257
fitter.addObservedPoint(-0.99   2.221135431136975);
 
258
fitter.addObservedPoint(-0.98   2.09985277659314);
 
259
fitter.addObservedPoint(-0.97   2.0211192647627025);
 
260
// lots of lines ommitted
 
261
fitter.addObservedPoint( 0.99, -2.4345814727089854);
 
262
PolynomialFunction fitted = fitter.fit();
 
263
        </source>
 
264
      </subsection>
87
265
     </section>
88
266
  </body>
89
267
</document>