Commit Graph

260 Commits

Author SHA1 Message Date
Gilles Sadowski 3a5cf279bb MATH-1462: Extend workaround for bins that contain up to 3 values. 2021-09-27 01:02:54 +02:00
Maciej Kwidzinski d4de59a15a MATH-1462: Reproduce the infinite quantile bug 2021-09-18 12:20:35 +02:00
Gilles Sadowski b44c2610e0 Javadoc. 2021-09-18 03:05:51 +02:00
Gilles Sadowski b89f677c67 Relax tolerance (unit tests). 2021-09-01 13:34:56 +02:00
Gilles Sadowski 6e11126615 Spurious "throws" clauses. 2021-09-01 11:25:20 +02:00
Gilles Sadowski b222580737 Replace algorithm used in "best list" search.
Although efficient in terms of evaluations, "NelderMeadTransform" fails for
some higher-dimensional test functions.
2021-09-01 03:43:05 +02:00
Gilles Sadowski 1811eeaf37 Unused "import". 2021-08-27 20:58:27 +02:00
Gilles Sadowski bf1c2c214c Remove obsolete helper class for unit testing.
Retries are handled by the "surefire" plugin.
2021-08-27 19:16:03 +02:00
Gilles Sadowski dd0acaa9ff Relax expectations (unit test). 2021-08-27 19:15:17 +02:00
Gilles Sadowski 6f33d5f0a7 Fix incorrect usage of "ROSENBROCK" test function (unit tests). 2021-08-27 18:35:47 +02:00
Gilles Sadowski cc5ae51f98 Favouring the "expanded" simplex over the "reflected" one.
This modification decreases the number of function evaluations in several
test cases. Note however that the original description of the algorithm
uses the strict inequality...
2021-08-27 17:24:51 +02:00
Gilles Sadowski f1ad9d1b00 Simplex search in higher-dimensional cases (unit test). 2021-08-27 05:37:49 +02:00
Gilles Sadowski ca826ba76b Add (back) "POwELL" standard test function for optimizers. 2021-08-26 23:56:42 +02:00
Gilles Sadowski f58da4abf5 Use default SA setup in "SimplexOptimizerTest" (unit test).
A single additional search finds the optimum of the test functions.
2021-08-26 02:05:15 +02:00
Gilles Sadowski 06ec7ad0bc MATH-1622: Simulated annealing entails at least one additional search.
Also ensure that the "best list" contains at least two points.
2021-08-26 01:39:46 +02:00
Gilles Sadowski 677f5f7a3f Input files for "SimplexOptimizerTest" (unit tests). 2021-08-25 01:51:34 +02:00
Gilles Sadowski 2ccdf8d002 MATH-1622: Simulated annealing variant of "NelderMeadTransform". 2021-08-25 01:50:28 +02:00
Gilles Sadowski 80a7eb1832 Change how simulated annealing affects the transformed simplex (cf. MATH-1622).
Compared with commit 97462b1a1b, this commit is
more consistent with assumptions of the original (non-hybridized) algorithm.
2021-08-24 15:46:10 +02:00
Gilles Sadowski c21a810558 Useless local variable. 2021-08-24 04:09:42 +02:00
Gilles Sadowski f8d7476614 Input files for "SimplexOptimizerTest" (unit tests). 2021-08-24 01:28:43 +02:00
Gilles Sadowski 97462b1a1b MATH-1622: Simulated annealing variant of "MultiDirectionalTransform". 2021-08-24 01:18:16 +02:00
Alex Herbert 21f8008108 MATH-1627: Throw an exception when column or row sums are zero. 2021-08-22 21:43:52 +01:00
Alex Herbert 991314d461 Remove incorrect localization format for zero exception 2021-08-22 21:43:52 +01:00
Gilles Sadowski fb314ef3df Spurious "throws" clauses. 2021-08-22 03:46:25 +02:00
Gilles Sadowski 9bb5791906 Redundant inner class. 2021-08-22 03:28:37 +02:00
Gilles Sadowski 78fbc5f07c Update script for visual check of "SimplexOptimizerTest" debugging output.
Allow displaying negative values of the objective function.
2021-08-22 02:30:01 +02:00
Gilles Sadowski 1e7bce134f Adapt input files for "SimplexOptimizerTest" (unit tests).
The current tests are "baseline" (2D) cases.
Further work should check degradation with increased dimensionality.
2021-08-22 02:14:53 +02:00
Gilles Sadowski 14ebd93426 Relax expected number of evaluations (unit test).
Optimization is sensitive to the change from "AccurateMath" to "Math"
for computing the "pow" function used in "TestFunction.SUM_POW".
2021-08-22 01:10:04 +02:00
Alex Herbert bdb4160b00 Add variance tests for zero weights
Update javadoc for the behaviour when input weights are zero.

This issue was found when checking the sonar report for the variance
class which has a potential divide by zero if the weights sum to zero.
2021-08-21 14:37:13 +02:00
Alex Herbert 5245a685a0 sonar fix: Handle variance=0 in skewness computation for input array 2021-08-21 14:37:13 +02:00
Alex Herbert 30aa597f1e sonar fix: Ensure checkFeasableCount is not negative.
Change loop condition to 'i <= checkFeasableCount' from 'i <
checkFeasableCount + 1'

This ensures the loop to identify a new feasible column (RealMatrix
arxk) always executes at least once even with checkFeasibleCount at the
limit of 0 or Integer.MAX_VALUE.
2021-08-21 14:37:13 +02:00
Alex Herbert 228a832532 Javadoc typo 2021-08-21 14:37:13 +02:00
Alex Herbert 26e4a737f7 Javadoc typo 2021-08-21 14:37:13 +02:00
Gilles Sadowski 3ba0221c26 Simplify data format for "SimplexOptimizerTest" (randomized) input.
This commit also makes the following changes (unit tests):
 * Add/remove/rename/rewrite test functions.
2021-08-21 14:33:30 +02:00
Alex Herbert e97c3288a5 Sonar fix: Cast operands to double before assigning result to double 2021-08-18 16:41:10 +01:00
Alex Herbert 21a9aa4413 Sonar fix: use equals to compare Integers 2021-08-18 11:14:58 +01:00
Alex Herbert 0a42dc86cb Remove unused imports 2021-08-18 10:45:14 +01:00
Alex Herbert 58e0efc651 Sonarfix: Rename test for equality in markers
Use explicit equals method to check equality (not assertEquals)
2021-08-18 08:26:14 +01:00
Gilles Sadowski 9be74e3abd Nit: Display debug file name. 2021-08-16 02:03:08 +02:00
Gilles Sadowski 1d1fe2acc0 Make debugging parameters optional (unit test).
First optional parameter is the prefix of the output file's name.
Second optional parameter is the list of simplex vertices to save.
2021-08-15 18:55:49 +02:00
Gilles Sadowski a0cd950a7c Simplify null checks. 2021-08-14 16:18:36 +02:00
Gilles Sadowski 8804071ac7 Update copyright information. 2021-08-14 03:24:08 +02:00
Gilles Sadowski 070676d219 MATH-1625: Gnuplot script for visual debugging. 2021-08-14 02:42:28 +02:00
Gilles Sadowski 5f36bf970a MATH-1625: Add callback to generate debugging output (unit test).
Debugging output is activated through specifying a file prefix in the CSV input file.
2021-08-14 01:51:43 +02:00
Gilles Sadowski 310b21e4d7 MATH-1625: Enable callback in "SimplexOptimizer". 2021-08-14 01:51:43 +02:00
Gilles Sadowski e9d811daa3 Override "toString". 2021-08-14 01:51:43 +02:00
Gilles Sadowski e3b029d28a Javadoc. 2021-08-14 01:51:43 +02:00
Arturo Bernal 1e4662de5a
Simplify assertions with simpler equivalent. (#196) 2021-08-13 09:24:22 +01:00
Gilles Sadowski 872b655950 Javadoc. 2021-08-12 03:03:42 +02:00
Gilles Sadowski 9371883b2b Increase number of allowed failures (unit tests). 2021-08-12 02:04:15 +02:00
Gilles Sadowski 59e9604dd8 Consistency check to ensure that "TestFunction" implementations are correct.
Call is commented out (it is mostly intended for a one-time visual check).
2021-08-12 01:59:37 +02:00
Gilles Sadowski f29ebd2e13 More test functions. 2021-08-12 01:56:44 +02:00
Gilles Sadowski 6a7b4ccbe3 Drop repeated tests inside "SimplexOptimizerTest.Task" class.
Explicitly specify the initial simplex side (as test parameter).
2021-08-11 19:58:28 +02:00
Gilles Sadowski 9b7a2c8edc Delete spurious files.
Files were committed by mistake.
2021-08-11 13:30:44 +02:00
Gilles Sadowski aea043cffd Function optimum is rarely found: Disable (comment out) test. 2021-08-10 12:44:01 +02:00
Gilles Sadowski 59573134d8 Reduce build failure frequency. 2021-08-10 12:43:23 +02:00
Gilles Sadowski 04d1b46525 Unused "import". 2021-08-10 12:42:13 +02:00
Gilles Sadowski 1fb5411a81 Move tests for expected exceptions to "SimplexOptimizerTest" class. 2021-08-10 11:47:59 +02:00
Gilles Sadowski 9fd6725d51 MATH-1623: Add unit tests for "HedarFukushimaTransform".
Adapt input files for the "simulated annealing" option.

Class "SimplexOptimizerHedarFukushimaTest" superseded by input from CSV.
2021-08-10 11:06:14 +02:00
Gilles Sadowski bdd6bc4d13 Unused "import". 2021-08-10 10:56:17 +02:00
Gilles Sadowski 061c6d2c30 Unused field. 2021-08-10 10:22:12 +02:00
Gilles Sadowski 858ecda80f MATH-1623: Remove duplicate unit tests.
Standard test functions are now handled by class "SimplexOptimizerTest".
2021-08-10 01:07:31 +02:00
Gilles Sadowski fdbb8b98f5 MATH-1623: Add parameterized unit tests for simplex-based optimizers. 2021-08-09 18:27:00 +02:00
Gilles Sadowski c40a30678b Unused "import". 2021-08-09 18:22:39 +02:00
Gilles Sadowski 7ce320700a Web links to reference definitions of test functions.
Changed "TestFunction.DIFF_POW" to match the definition.
2021-08-09 17:56:52 +02:00
Gilles Sadowski a2491345b8 Remove duplicate function (unit tests). 2021-08-09 16:10:48 +02:00
Gilles Sadowski 43ac946382 Delete unused test data files. 2021-08-09 11:54:38 +02:00
Gilles Sadowski 970834f9b9 Delete unused test data files. 2021-08-09 11:40:21 +02:00
Gilles Sadowski 1bc6e8de25 "Simplex.TransformFactory" must extend "OptimizationData". 2021-08-09 10:31:07 +02:00
Gilles Sadowski c04dd79f0f Preserve RNG state integrity in case unit tests would be run concurrently. 2021-08-09 10:27:34 +02:00
Gilles Sadowski 1444d2d8d1 Replace deprecated calls. 2021-08-07 22:31:39 +02:00
Gilles Sadowski 26fc13cf66 Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-math 2021-08-07 15:34:48 +02:00
Gilles Sadowski 92a3b0c040 Replace calls to deprecated method. 2021-08-07 15:26:02 +02:00
Gilles Sadowski 50ca244b38 MATH-1622: Hybridation of simplex-based search with simulated annealing (SA).
Class "SimulatedAnnealing" provides user-defined input ("OptimizationData").
Behaviour of "SimplexOptimizer" depends on whether SA is activated (if yes,
each "iteration" is further split in "epoch" stages).
The "Simplex.TransformFactory" interface is changed to allow passing the SA
acceptance test ("Metropolis" rule).

The "SimplexOptimizer" is furter refactored (cf. MATH-1614) so that the
steps (in method "doOptimize") clearly stand out as
 1. Setup and iteration (optionally with simulated annealing).
 2. Simplex transformation rule.
 3. Convergence check.
 4. "Best list" search.

This commit also contains the following modifications:
 * "TestFunction": Override "toString" (for display in unit tests).
 * "Simplex"
   - Self-documenting names for factories.
   - Utility methods: "centroid", "asList", "replaceLast".
   - Unit tests.
 * "MultiDirectionalTransform":
   - Use common utility methods.
   - Fix missing sort in "transform" method.
   - Check validity of constructor parameters.
   - Parameter names to match the equivalent in "NelderMeadMeadTransform".
 * Adapt unit test classes to the updated API of class "Simplex".
 * "PointValuePair":
   - "final".
   - Implements "hashCode".
2021-08-07 14:38:46 +02:00
Gilles Sadowski d26470b139 Delete unused test data files.
The same data is still available in directory
  commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/fitting/leastsquares
2021-08-07 14:38:46 +02:00
Gilles Sadowski b167967767 Standard test functions defined in a dedicated factory ("TestFunction" enum). 2021-08-07 14:38:46 +02:00
Gilles Sadowski a791c576d5 Relax tolerance (unit test). 2021-08-07 14:38:46 +02:00
Gilles Sadowski 790ceb5ade Nit: Information message in unit test assertions. 2021-08-07 14:38:46 +02:00
Gilles Sadowski fd3313724e Move utility method "newPoint" to "Simplex" class.
Reduce visibility of utility methods to "package-private".
2021-08-07 14:38:46 +02:00
Gilles Sadowski de99fd0384 Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-math 2021-08-07 14:38:04 +02:00
Arturo Bernal 3aab631272 MATH-1573 - Redundant local variable 2021-08-07 13:37:21 +01:00
Arturo Bernal 1c8d8da63a MATH-1572: Simplify conditional expressions
* Simplify bitwise
* Simplify boolean expression
* Simplify conditional expression
* Redundant 'if' statement
2021-08-07 13:19:32 +01:00
Gilles Sadowski b5d21665ff MATH-1621: Override "equals" and "toString". 2021-08-04 06:47:27 +02:00
Gilles Sadowski 771a21815b Unused "import". 2021-08-03 16:20:11 +02:00
Gilles Sadowski 6bc63d4f3f Suppress obsolete unit test.
Class "ConstantContinuousDistribution" has been removed from "Commons Statistics".
2021-08-03 03:22:47 +02:00
Gilles Sadowski 3df6d879e7 Implement "ConstantContinuousDistribution" as a local workaround.
Corresponding code to be removed from "Commons Statistics" (no other known use case).
2021-08-02 02:31:37 +02:00
Gilles Sadowski 8e63d421bf Adapt to "Commons Statistics" API change. 2021-08-02 01:36:34 +02:00
Gilles Sadowski f49e77a806 Delete spurious file.
File was committed by mistake.
2021-07-28 13:01:18 +02:00
Gilles Sadowski 9dbceb0ed1 MATH-1616: Refactor "EmpiricalDistribution".
* No default bin count (cf. MATH-1462).
* No data loading from external sources (file, URL).
* No data abstraction layer.
* Return defensive copies of the internal state.
* Make class immutable.
* Allow user-defined within-bin kernel.
2021-07-20 18:07:12 +02:00
Gilles Sadowski 8968416790 MATH-1379: Fix "LoessInterpolator" in case of unevenly spaced samples.
Thanks to Richard Wilkinson.
2021-07-19 18:43:59 +02:00
Ng Tsz Sum 30a2593c2c MATH-1617: Ensure that "hashCode" is consistent with "equals". 2021-07-19 17:43:51 +02:00
Gilles Sadowski 8cd59b991e Replace deprecated calls. 2021-07-19 15:02:29 +02:00
Gilles Sadowski bf44f34862 "sonarcloud" suggestion. 2021-07-19 15:01:39 +02:00
Gilles Sadowski 0b56f2cf54 MATH-1617: Fix equality check.
Thanks to Ng Tsz Sum.
2021-07-18 17:28:04 +02:00
Gilles Sadowski 4f7ef762d7 Reduce visibility to package-private. 2021-07-18 01:06:00 +02:00
Gilles Sadowski b5fd55e6b9 Avoid usage of "clone" (suggested by "sonarcloud"). 2021-07-18 01:02:28 +02:00
Gilles Sadowski 84f15db1bb Javadoc. 2021-07-17 14:35:37 +02:00
Gilles Sadowski 7de72b3402 Javadoc. 2021-07-17 14:35:26 +02:00
Gilles Sadowski 2218194942 MATH-1611: Obsolete class.
Functionality moved to "Commons RNG" (cf. RNG-140).
2021-07-17 14:19:09 +02:00
Gilles Sadowski e6bc7a4d31 Use functionality from "Commons RNG". 2021-07-17 14:18:38 +02:00