Commit Graph

5163 Commits

Author SHA1 Message Date
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
Luc Maisonobe 567127c109 Immutable Optimizer configuration.
The GN and LM optimizers now use an immutable fields for their configuration
parameters and a fluent api. LM still has some mutable fields it uses a scratch
space.

This commit is a backport of Evan Ward github commit
    https://github.com/wardev/commons-math/commit/157cdde
into the current development version.

Conflicts:
	src/main/java/org/apache/commons/math3/fitting/leastsquares/GaussNewtonOptimizer.java
	src/main/java/org/apache/commons/math3/fitting/leastsquares/LevenbergMarquardtOptimizer.java

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1569343 13f79535-47bb-0310-9956-ffa450edef68
2014-02-18 14:31:43 +00:00
Luc Maisonobe 7460c082a3 Separate least squares algorithm from problem.
The least squares package now has two main interfaces LeastSquaresOptimizer and
LeastSquaresProblem, where the optimizer can be applied to the problem.

In this commit all of the test cases pass with one change (annotated) to
LevenbergMarquardt.testControlParameters(). The tests for Gauss Newton were
expanded to cover using the QR decomposition, which revealed a QR default
tolerance discrepancy.

A factory and a mutable builder were create for LeastSquaresProblem.

This commit is a backport of Evan Ward github commit
 7e9a15efb5
into the current development version.

Conflicts:
	src/main/java/org/apache/commons/math3/fitting/leastsquares/AbstractLeastSquaresOptimizer.java
	src/main/java/org/apache/commons/math3/fitting/leastsquares/GaussNewtonOptimizer.java
	src/main/java/org/apache/commons/math3/optim/AbstractOptimizer.java
	src/test/java/org/apache/commons/math3/fitting/leastsquares/AbstractLeastSquaresOptimizerAbstractTest.java
	src/test/java/org/apache/commons/math3/fitting/leastsquares/GaussNewtonOptimizerTest.java
	src/test/java/org/apache/commons/math3/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1569342 13f79535-47bb-0310-9956-ffa450edef68
2014-02-18 14:31:34 +00:00
Thomas Neidhart 675d4c8fc8 Update test after adding new error message.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1568754 13f79535-47bb-0310-9956-ffa450edef68
2014-02-16 12:32:52 +00:00
Thomas Neidhart e8d0d4c1dd [MATH-749] Remove GrahamScan, GiftWrap, make MonotoneChain more robust wrt collinear points, add ConvergenceException in case the specified tolerance results in a non-convex hull.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1568752 13f79535-47bb-0310-9956-ffa450edef68
2014-02-16 12:19:51 +00:00
Luc Maisonobe 39430886ba Rewrote completely the enclosing spherical cap computation on 2-sphere.
The previous version was based on Welzl algorithm, but it appeared this
algorithm really need some properties that hold in Euclidean spaces and
not on the sphere.

The current version is not perfect in the sense that some times the
enclosing spherical cap returned is not the smallest possible. It is
documented in the Javadoc.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1567599 13f79535-47bb-0310-9956-ffa450edef68
2014-02-12 11:12:45 +00:00
Thomas Neidhart b9b73fbef5 Further improvements.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1567427 13f79535-47bb-0310-9956-ffa450edef68
2014-02-11 22:33:39 +00:00
Thomas Neidhart 7e6304ce63 Add zooming, center of enclosing ball.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1566774 13f79535-47bb-0310-9956-ffa450edef68
2014-02-10 22:35:10 +00:00
Thomas Neidhart 12ddf37f23 Simplify geometry examples by using piccolo2d.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1566450 13f79535-47bb-0310-9956-ffa450edef68
2014-02-09 22:10:04 +00:00
Luc Maisonobe 06e1ff5008 Configured rules for Clirr, as per discussion on the mailing list.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1566417 13f79535-47bb-0310-9956-ffa450edef68
2014-02-09 20:57:24 +00:00
Luc Maisonobe d41b96e58d Added a warning about interfaces not implementable by users.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1566416 13f79535-47bb-0310-9956-ffa450edef68
2014-02-09 20:56:55 +00:00
Thomas Neidhart 517ff8cbe3 Revert unneeded serializationUID field.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1566396 13f79535-47bb-0310-9956-ffa450edef68
2014-02-09 20:36:24 +00:00
Luc Maisonobe 5ae01f1f99 Added a getEnclosingCap method for spherical polygons.
In simple cases (small polygon, one piece only, no holes), the enclosing
cap will be the smallest one, but this is not guaranteed in the general
case.

The enclosing cap can be used to speed up inside/outside points when the
region is small with respect to the sphere as with only one check of an
angular separation, most points of the sphere can be safely identified
as outside. The more time-consuming checks involving the full boundary
are therefore done only for a small portion of the sphere.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1566358 13f79535-47bb-0310-9956-ffa450edef68
2014-02-09 19:17:55 +00:00
Thomas Neidhart 2535320878 [MATH-749] Add changelog entry.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1566342 13f79535-47bb-0310-9956-ffa450edef68
2014-02-09 18:24:27 +00:00
Thomas Neidhart 996c0c164a [MATH-1065] Fix EnumeratedRealDistribution.inverseCumulativeProbability. Thanks to matteodg and Phil.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1566274 13f79535-47bb-0310-9956-ffa450edef68
2014-02-09 11:21:28 +00:00
Thomas Neidhart 3f59a81a15 Add missing since tags.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1566092 13f79535-47bb-0310-9956-ffa450edef68
2014-02-08 18:48:29 +00:00
Thomas Neidhart b957ee1646 Add missing serialVersionUIDs.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1566088 13f79535-47bb-0310-9956-ffa450edef68
2014-02-08 18:36:30 +00:00
Thomas Neidhart 42dffede43 [MATH-1050] Added changelog entry.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1566074 13f79535-47bb-0310-9956-ffa450edef68
2014-02-08 18:14:37 +00:00
Thomas Neidhart 3c644cf87e [MATH-749] Change the way the line segments are computed as they can not be serialized. Use the array only as cache and create them as needed.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1566064 13f79535-47bb-0310-9956-ffa450edef68
2014-02-08 17:44:37 +00:00
Thomas Neidhart c92f7d0c8f [MATH-976] Add changelog entry.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1566047 13f79535-47bb-0310-9956-ffa450edef68
2014-02-08 16:54:45 +00:00
Thomas Neidhart 683a898d55 [MATH-976] Use placeholders and fix manifest for tools jar.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1566046 13f79535-47bb-0310-9956-ffa450edef68
2014-02-08 16:50:32 +00:00
Thomas Neidhart 8dae299004 [MATH-990] Added changelog entry.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1566021 13f79535-47bb-0310-9956-ffa450edef68
2014-02-08 14:33:03 +00:00
Thomas Neidhart 51a7ec0633 Fix typo.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1566020 13f79535-47bb-0310-9956-ffa450edef68
2014-02-08 14:28:20 +00:00
Thomas Neidhart d434c5d0cc [MATH-1044] Clarify javadoc of DecompositionSolver#getInverse and corresponding implementations. Thanks to Sean Owen.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1566017 13f79535-47bb-0310-9956-ffa450edef68
2014-02-08 14:13:34 +00:00
Thomas Neidhart b268dfbb82 Add missing AL header.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1565447 13f79535-47bb-0310-9956-ffa450edef68
2014-02-06 21:31:52 +00:00
Thomas Neidhart de21905859 [MATH-749] Rename method, add/improve javadoc, better handle degenerate cases, improve unit tests.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1565444 13f79535-47bb-0310-9956-ffa450edef68
2014-02-06 21:27:20 +00:00
Thomas Neidhart 6b43922648 [MATH-749] Handle case that all points are identical.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1564954 13f79535-47bb-0310-9956-ffa450edef68
2014-02-05 22:10:22 +00:00
Thomas Neidhart b353d07bcc [MATH-749] Add GiftWrap algorithm as precursor for Chan's algorithm.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1564951 13f79535-47bb-0310-9956-ffa450edef68
2014-02-05 21:54:10 +00:00
Thomas Neidhart e5dc3ad337 [MATH-749] Improve robustness for convex hull algorithms in case of identical / collinear points, added flag whether to include only extreme points or all points on the hull, improve unit tests.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1564934 13f79535-47bb-0310-9956-ffa450edef68
2014-02-05 21:21:31 +00:00
Luc Maisonobe e5002ce3f6 Removed unfinished method.
The method was added by error.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1564922 13f79535-47bb-0310-9956-ffa450edef68
2014-02-05 20:46:43 +00:00
Luc Maisonobe 739708f1af Added enclosing ball generator for 2-sphere.
On the 2-sphere, enclosing balls are sphericals caps.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1564921 13f79535-47bb-0310-9956-ffa450edef68
2014-02-05 20:42:58 +00:00
Luc Maisonobe 3d0e61ebe5 Fixed comments.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1564255 13f79535-47bb-0310-9956-ffa450edef68
2014-02-04 11:19:41 +00:00
Thomas Neidhart 3b50199358 Add missing Override tags.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1563714 13f79535-47bb-0310-9956-ffa450edef68
2014-02-02 20:55:14 +00:00
Luc Maisonobe 19c1c3bb9b Fixed sphere generation in degenerated cases.
In almost coplanar / almost colinear cases, sphere generation could
diverge in such a way the support points did not belong to the sphere
anymore! This new implementation uses exact arithmetic for the
computation. It is much slower, but since very few balls should be
generated during the Welzl algorithm execution, this is probably
acceptable.

JIRA: MATH-1096

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1563712 13f79535-47bb-0310-9956-ffa450edef68
2014-02-02 20:52:49 +00:00
Thomas Neidhart 7897aa6a83 [MATH-749] Use new method Vector2D.crossProduct, fix typos, return Segment instead of Line in ConvexHull2D.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1563687 13f79535-47bb-0310-9956-ffa450edef68
2014-02-02 17:56:13 +00:00
Thomas Neidhart 0fa8bcc008 [MATH-749] Added crossProduct method to Vector2D as a replacement for getLocation, using MathArrays.linearCombination to improve accuracy.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1563684 13f79535-47bb-0310-9956-ffa450edef68
2014-02-02 17:51:06 +00:00
Thomas Neidhart 2933e5773b Add EnclosingBall example, update convex hull.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1563409 13f79535-47bb-0310-9956-ffa450edef68
2014-02-01 12:50:41 +00:00
Thomas Neidhart 764f56955d Apply @Override rules for java 1.5
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1563402 13f79535-47bb-0310-9956-ffa450edef68
2014-02-01 12:00:21 +00:00
Thomas Neidhart 9dc30fddc1 Make constructor package private for now to simplify potential future changes.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1563288 13f79535-47bb-0310-9956-ffa450edef68
2014-01-31 22:07:35 +00:00
Thomas Neidhart bcba29320f Improve tests.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1563285 13f79535-47bb-0310-9956-ffa450edef68
2014-01-31 22:06:49 +00:00
Thomas Neidhart 8f7c59ce88 [MATH-749] Add MonotoneChain implementation.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1563284 13f79535-47bb-0310-9956-ffa450edef68
2014-01-31 22:06:31 +00:00
Thomas Neidhart ca22dac3f8 Rename to GrahamScan as the algorithm anyway is only defined for the 2D case.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1563246 13f79535-47bb-0310-9956-ffa450edef68
2014-01-31 20:24:02 +00:00