Commit Graph

5504 Commits

Author SHA1 Message Date
Luc Maisonobe 3f0a000fef Prevent penalties to grow multiplicatively in CMAES.
Patch provided by Bruce A Johnson.

JIRA: MATH-1107

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1573506 13f79535-47bb-0310-9956-ffa450edef68
2014-03-03 09:58:29 +00:00
Luc Maisonobe 007a701755 Add SVD to GaussNewtonOptimizer
Allow using the SVD decomposition which has excellent stability and can
provide a "solution" for singular problems.

Figured out why one of the least squares tests did not check two of the
states. There was only one equation for the two states. The test now
verifies the states satisfy the constraint.

Patch provided by Evan Ward.

JIRA: MATH-1104

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1573351 13f79535-47bb-0310-9956-ffa450edef68
2014-03-02 19:54:43 +00:00
Gilles Sadowski 8068e84a33 MATH-1092
Javadoc.


git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1573341 13f79535-47bb-0310-9956-ffa450edef68
2014-03-02 19:38:47 +00:00
Gilles Sadowski b95cfc9b57 MATH-1092
Added parameter in "LineSearch" and "NonLinearConjugateGradientOptimizer".


git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1573316 13f79535-47bb-0310-9956-ffa450edef68
2014-03-02 14:54:37 +00:00
Luc Maisonobe e2dc384d7b Fix switched iterations and evaluations
In LevenbergMarquardtOptimizer the number of iterations and evaluations
was switched in two of the return statements.

Patch provided by Evan Ward.

JIRA: MATH-1106

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1573308 13f79535-47bb-0310-9956-ffa450edef68
2014-03-02 14:02:50 +00:00
Luc Maisonobe a6f9630666 Fix checker seeing not old point
ConvergenceCheckers always saw previous.getPoint() to equal
current.getPoint() because the optimizers used the same array and did
not make a copy of the previous point. Fixed by using a new array for
each model evaluation and LSP.evaluate() now makes its own copy of the
state vector as well.

Path provided by Evan Ward.

JIRA: MATH-1103

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1573307 13f79535-47bb-0310-9956-ffa450edef68
2014-03-02 14:02:21 +00:00
Thomas Neidhart 5a8eff6985 Fix typo.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1573271 13f79535-47bb-0310-9956-ffa450edef68
2014-03-02 08:31:30 +00:00
Gilles Sadowski f0ae42aa93 MATH-1092
Extracted class "LineSearch" from "PowellOptimizer".
Made method "computeObjectiveValue" public in "MultivariateOptimizer".
Modified "PowellOptimizer" to use the now public class.
"NonLinearConjugateGradientOptimizer" uses the new "LineSearch".
Added constructors to set the line search tolerances and deprecated
obsolete contructors and inner classes ("BracketingStep" and
"LineSearchFunction".
Removed method "findUpperBound".



git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1572988 13f79535-47bb-0310-9956-ffa450edef68
2014-02-28 16:23:26 +00:00
Phil Steitz ba70cfc5c9 Fixed comment.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1572341 13f79535-47bb-0310-9956-ffa450edef68
2014-02-26 23:24:21 +00:00
Phil Steitz 99189ff527 Added KolmogorovSmirnovTest, deprecated KolmogorovSmirnovDistributio. JIRA: MATH-437
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1572335 13f79535-47bb-0310-9956-ffa450edef68
2014-02-26 23:14:08 +00:00
Luc Maisonobe eb66fe4a1f Improved test coverage.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1571737 13f79535-47bb-0310-9956-ffa450edef68
2014-02-25 16:42:07 +00:00
Gilles Sadowski d3470c37ab Typo.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1571640 13f79535-47bb-0310-9956-ffa450edef68
2014-02-25 10:27:21 +00:00
Gilles Sadowski 1358d274db Fixed small inconsistency.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1571639 13f79535-47bb-0310-9956-ffa450edef68
2014-02-25 10:26:55 +00:00
Luc Maisonobe 856e3cf007 Javadoc.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1571627 13f79535-47bb-0310-9956-ffa450edef68
2014-02-25 09:21:32 +00:00
Luc Maisonobe b122db9eda Make AbstractEvaluation public
Allow custom implementations of LeastSquaresProblem to use the default
methods for computing the covariance, rms, etc.

JIRA: MATH-1102

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1571307 13f79535-47bb-0310-9956-ffa450edef68
2014-02-24 14:58:07 +00:00
Luc Maisonobe 9ac2b15e4a In LeastSquaresProblem.Evaluation removed the getValue() method.
- The residuals are the really the values of the objective function
  that is being minimized.
- Forcing the value to be a real vector and the residual computed
  through subtraction is an unnecessary constraint. For example
  Rotation.distance() will compute a better residual than
  subtracting the quaternion elements of two rotations.
- Method was not used by any optimizer.

JIRA: MATH-1102

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1571306 13f79535-47bb-0310-9956-ffa450edef68
2014-02-24 14:57:44 +00:00
Luc Maisonobe a573059d05 Moved OptimizationProblem interface to optim package.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1571015 13f79535-47bb-0310-9956-ffa450edef68
2014-02-23 14:00:48 +00:00
Luc Maisonobe dcdfd7ed9e Change private least square problem implementation to internal class.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1571014 13f79535-47bb-0310-9956-ffa450edef68
2014-02-23 14:00:20 +00:00
Luc Maisonobe f299ecf330 Improved documentation of QR decomposition handling of singular matrix.
JIRA: MATH-1101

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1570994 13f79535-47bb-0310-9956-ffa450edef68
2014-02-23 11:10:41 +00:00
Luc Maisonobe 927361d787 QR decomposition can compute pseudo-inverses for tall matrices.
Thanks to Sean Owen for the patch.

JIRA: MATH-1053

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1570566 13f79535-47bb-0310-9956-ffa450edef68
2014-02-21 13:18:35 +00:00
Luc Maisonobe ed7ac7cf74 Field vectors now implement the visitor pattern just like real vectors.
JIRA: MATH-820

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1570536 13f79535-47bb-0310-9956-ffa450edef68
2014-02-21 11:26:09 +00:00
Luc Maisonobe 5ea537df99 Un-deprecated RealVector.sparseIterator.
The documentation now explicitly states that entries not iterated above
are the zero ones.

This is part of Apache Commons Math reconsidering support for sparse
linear algebra.

JIRA: MATH-875

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1570510 13f79535-47bb-0310-9956-ffa450edef68
2014-02-21 10:16:52 +00:00
Luc Maisonobe a9d0cc42fe Relaxed specification for function mapping on vectors.
JIRA: MATH-821

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1570254 13f79535-47bb-0310-9956-ffa450edef68
2014-02-20 16:16:19 +00:00
Luc Maisonobe 1cd5a3229c Continue un-deprecation of sparse methods.
JIRA: MATH-870
JIRA: MATH-803

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1570246 13f79535-47bb-0310-9956-ffa450edef68
2014-02-20 15:56:37 +00:00
Luc Maisonobe 4332119866 Added a test showing the limitation of sparse matrices implementation.
JIRA:MATH-870.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1570209 13f79535-47bb-0310-9956-ffa450edef68
2014-02-20 14:52:13 +00:00
Luc Maisonobe fe0f518f50 computeXxx renamed getXxx in the Evaluation interface (leastsquares).
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1570206 13f79535-47bb-0310-9956-ffa450edef68
2014-02-20 14:35:14 +00:00
Luc Maisonobe d19b226c54 Make QR the default in GaussNewtonOptimizer
Theoretically QR offers the best blend of speed and numerical stability.
Empirically the QR implementation is slightly faster than the Cholesky
implementation.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1569907 13f79535-47bb-0310-9956-ffa450edef68
2014-02-19 20:32:43 +00:00
Luc Maisonobe 3c1bf79202 Add Cholesky option to GaussNewtonOptimizer
Since the normal matrix is symmetric positive (semi-)definite, the
Cholesky decomposition is theoretically faster.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1569906 13f79535-47bb-0310-9956-ffa450edef68
2014-02-19 20:32:20 +00:00
Luc Maisonobe 1a6879a002 Make QR in GaussNewton faster and more accurate
Re-factored the code in GaussNewtonOptimizer so that the decomposition
algorithm sees the Jacobian and residuals instead of the normal
equation. This lets the QR algorithm operate directly on the Jacobian
matrix, which is faster and less sensitive to numerical errors. As a
result, one test case that threw a singular matrix exception now passes
with the QR decomposition.

The refactoring also include a speed improvement when computing the
normal matrix for the LU decomposition. Since the normal matrix is
symmetric only half of is computed, which results in a factor of 2 speed
up in computing the normal matrix for problems with many more
measurements than states.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1569905 13f79535-47bb-0310-9956-ffa450edef68
2014-02-19 20:31:47 +00:00
Luc Maisonobe 499101c88c The sparse vector and matrix classes have been un-deprecated.
This is a reversal of a former decision, as we now think we should adopt
a generally accepted behavior which is ... to ignore the problems of
NaNs and infinities in sparse linear algebra entities.

JIRA: MATH-870 (which is therefore NOT fixed)

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1569825 13f79535-47bb-0310-9956-ffa450edef68
2014-02-19 17:19:59 +00:00
Luc Maisonobe 785ea269eb Javadoc.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1569380 13f79535-47bb-0310-9956-ffa450edef68
2014-02-18 15:11:46 +00:00
Luc Maisonobe b0521ef7e0 Removed interfaces in the fluent API that do not add any value.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1569363 13f79535-47bb-0310-9956-ffa450edef68
2014-02-18 14:33:57 +00:00
Luc Maisonobe 613a83c56a Fixed checkstyle and compiler warnings.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1569362 13f79535-47bb-0310-9956-ffa450edef68
2014-02-18 14:33:49 +00:00
Luc Maisonobe b01933b17f Expand Evaluation tests, use weighted values.
Added more test cases to EvaluationTest to test the other methods of
DenseWeightedEvaluation/UnweightedEvaluation.
    
Fixed a bug in DenseWeightedEvaluation.computeValue() where the the
weights were not applied to the return value.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1569361 13f79535-47bb-0310-9956-ffa450edef68
2014-02-18 14:33:41 +00:00
Luc Maisonobe 9a012f530e Qualify Evaluation in interfaces.
Use LeastSquaresProblem.Evaluation in the public interfaces for
readability.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1569360 13f79535-47bb-0310-9956-ffa450edef68
2014-02-18 14:33:33 +00:00
Luc Maisonobe 57096ad696 JUnit directly executes least squares tests
Previously JUnit would make the call to test a specific optimizer, and
then that method would call all of the individual test cases relevant to
that optimizer.,Now JUnit will directly call each individual test case.
    
The same test coverage is preserved. The GaussNewtonOptimizerTest is
split into two classes, one for each decomposition algorithm it can use.
There is a significant amount of duplicated code between
GaussNewtonOptimizerWithLUTest and GaussNewtonOptimizerWithQRTest.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1569359 13f79535-47bb-0310-9956-ffa450edef68
2014-02-18 14:33:28 +00:00
Luc Maisonobe c12ae52424 Fixed errors introduced by few previous API changes.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1569358 13f79535-47bb-0310-9956-ffa450edef68
2014-02-18 14:33:20 +00:00
Luc Maisonobe 46b2ce2ee0 Fix Javadoc and checkstyle errors.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1569357 13f79535-47bb-0310-9956-ffa450edef68
2014-02-18 14:33:14 +00:00
Luc Maisonobe 8916830e8a Clean up LeastSquaresBuilder
Provide methods for using old and new interfaces. Data is stored internally
using the new interfaces now.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1569356 13f79535-47bb-0310-9956-ffa450edef68
2014-02-18 14:33:08 +00:00
Luc Maisonobe 4dcae270e6 Clean up LeastSquaresFactory
* There are now 3 factory methods: one using the previous interfaces, one using
  the new interfaces with weights, and one using the new interfaces without
  weights.

* Make model(...) method public.

* Fix javadoc typo

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1569355 13f79535-47bb-0310-9956-ffa450edef68
2014-02-18 14:33:00 +00:00
Luc Maisonobe 0079828734 Use Real{Vector,Matrix} in LeastSquares interfaces
Covered all of the interfaces in the leastsquares package to use RealVector and
RealMatrix instead of double[] and double[][]. This reduced some duplicated code.
For example Evaluation.computeResiduals() was a complete duplication of
RealVector.subtract(). It also presents a consistent interface and allows data
encapsulation.

Lastly, this change enables [math] to "eat our own dog food." It enables the
linear package to be used in the implementation of the optimization algorithms.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1569354 13f79535-47bb-0310-9956-ffa450edef68
2014-02-18 14:32:54 +00:00
Luc Maisonobe a7a380f934 Use Evaluation instead of PointVectorValuePair
Use Evaluation instead of PointVectorValuePair in the ConvergenceChecker. This
gives the checkers access to more information, such as the rms and covariances.
The change also simplified the optimizer implementations since they no longer
have to keep track of the current function value.

A method was added to LeastSquaresFactory to convert between the two types of
checkers and a method added to LeastSquaresBuilder so that it can accept either
type. I would have prefered to do this through method overloading, but
overloading doesn't play well with generics.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1569353 13f79535-47bb-0310-9956-ffa450edef68
2014-02-18 14:32:44 +00:00
Luc Maisonobe 3e18e999c7 Use enum for LU or QR in GaussNewtonOptimizer
Changed the boolean useLu prarameter to an enum. This is benificial because:
1. user code is easier to read: new GNO(Decomposition.QR) instead of new GNO(false)
2. Allows other algorithms to be added in the future
3. developer code is easier to read. One less if statement in optimize()

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1569352 13f79535-47bb-0310-9956-ffa450edef68
2014-02-18 14:32:36 +00:00
Luc Maisonobe 49685c8bb4 Make infinite loop in GaussNewton explicit.
The main loop in GN could only be ended by convergence or exception. I made that
explicit with while(true) and removed an unreachable MathInternalError.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1569350 13f79535-47bb-0310-9956-ffa450edef68
2014-02-18 14:32:28 +00:00
Luc Maisonobe 8b697afded LevenbergMarquardtOptimizer is thread safe.
Converted the mutable fields to locals.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1569349 13f79535-47bb-0310-9956-ffa450edef68
2014-02-18 14:32:23 +00:00
Luc Maisonobe 4cdfc143ea Add Javadoc to LeastSquaresBuilder.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1569348 13f79535-47bb-0310-9956-ffa450edef68
2014-02-18 14:32:17 +00:00
Luc Maisonobe 9444e28967 Fixup javadoc in LeastSquaresProblem
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1569347 13f79535-47bb-0310-9956-ffa450edef68
2014-02-18 14:32:11 +00:00
Luc Maisonobe fc9cb0ce16 Value and Jacobian evaluated in a single method.
A new interface MultivariateJacobianFunction lets the function value and
Jacobian be evaluated at the same time. This saves the user from having to cache
the result between calls to get the value and the jacobian.

A factory method was added to create LeastSquaresProblems from the new interface.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1569346 13f79535-47bb-0310-9956-ffa450edef68
2014-02-18 14:32:06 +00:00
Luc Maisonobe 4158f97463 Clean up LeastSquaresProblemImpl
Reorder constructor parameters to match LeastSquaresFactory and remove an unused
method.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1569345 13f79535-47bb-0310-9956-ffa450edef68
2014-02-18 14:31:59 +00:00
Luc Maisonobe 06d490a4bd Implicit Weights
The weights are no longer implicit in LeastSquaresProblem.Evaluation. They are
already included in the computed residuals and Jacobian.

GN and LM multiplied the residuals by the weights immediately, so that was easy
to remove.

Created an AbstractEvaluation class which handles the derived quantitied (cost,
rms, covariance,...) and two implementations. UnweightedEvaluation uses the
straight forward formulas. DenseWeightedEvaluation delegates to an Evaluation
and multiples the residuals and Jacobian by the square root of the weight matrix
before returning them. Allowed me to remove the reference to the full weight
matrix.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1569344 13f79535-47bb-0310-9956-ffa450edef68
2014-02-18 14:31:53 +00:00