fixed functions names (minimizes -> minimize)
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@628000 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7f5355a3ea
commit
651cae8991
|
@ -58,12 +58,12 @@ import org.apache.commons.math.stat.descriptive.moment.VectorialMean;
|
|||
* multi-start mode. Multi-start is a traditional way to try to avoid
|
||||
* being trapped in a local minimum and miss the global minimum of a
|
||||
* function. It can also be used to verify the convergence of an
|
||||
* algorithm. The various multi-start-enabled <code>minimizes</code>
|
||||
* algorithm. The various multi-start-enabled <code>minimize</code>
|
||||
* methods return the best minimum found after all starts, and the
|
||||
* {@link #getMinima getMinima} method can be used to retrieve all
|
||||
* minima from all starts (including the one already provided by the
|
||||
* {@link #minimizes(CostFunction, int, ConvergenceChecker, double[],
|
||||
* double[]) minimizes} method).</p>
|
||||
* {@link #minimize(CostFunction, int, ConvergenceChecker, double[],
|
||||
* double[]) minimize} method).</p>
|
||||
*
|
||||
* <p>This class is the base class performing the boilerplate simplex
|
||||
* initialization and handling. The simplex update by itself is
|
||||
|
@ -107,7 +107,7 @@ public abstract class DirectSearchOptimizer {
|
|||
* @exception ConvergenceException if none of the starts did
|
||||
* converge (it is not thrown if at least one start did converge)
|
||||
*/
|
||||
public PointCostPair minimizes(CostFunction f, int maxEvaluations,
|
||||
public PointCostPair minimize(CostFunction f, int maxEvaluations,
|
||||
ConvergenceChecker checker,
|
||||
double[] vertexA, double[] vertexB)
|
||||
throws CostException, ConvergenceException {
|
||||
|
@ -117,7 +117,7 @@ public abstract class DirectSearchOptimizer {
|
|||
setSingleStart();
|
||||
|
||||
// compute minimum
|
||||
return minimizes(f, maxEvaluations, checker);
|
||||
return minimize(f, maxEvaluations, checker);
|
||||
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ public abstract class DirectSearchOptimizer {
|
|||
* @exception ConvergenceException if none of the starts did
|
||||
* converge (it is not thrown if at least one start did converge)
|
||||
*/
|
||||
public PointCostPair minimizes(CostFunction f, int maxEvaluations,
|
||||
public PointCostPair minimize(CostFunction f, int maxEvaluations,
|
||||
ConvergenceChecker checker,
|
||||
double[] vertexA, double[] vertexB,
|
||||
int starts, long seed)
|
||||
|
@ -176,7 +176,7 @@ public abstract class DirectSearchOptimizer {
|
|||
setMultiStart(starts, rvg);
|
||||
|
||||
// compute minimum
|
||||
return minimizes(f, maxEvaluations, checker);
|
||||
return minimize(f, maxEvaluations, checker);
|
||||
|
||||
}
|
||||
|
||||
|
@ -197,7 +197,7 @@ public abstract class DirectSearchOptimizer {
|
|||
* @exception ConvergenceException if none of the starts did
|
||||
* converge (it is not thrown if at least one start did converge)
|
||||
*/
|
||||
public PointCostPair minimizes(CostFunction f, int maxEvaluations,
|
||||
public PointCostPair minimize(CostFunction f, int maxEvaluations,
|
||||
ConvergenceChecker checker,
|
||||
double[][] vertices)
|
||||
throws CostException, ConvergenceException {
|
||||
|
@ -207,7 +207,7 @@ public abstract class DirectSearchOptimizer {
|
|||
setSingleStart();
|
||||
|
||||
// compute minimum
|
||||
return minimizes(f, maxEvaluations, checker);
|
||||
return minimize(f, maxEvaluations, checker);
|
||||
|
||||
}
|
||||
|
||||
|
@ -234,7 +234,7 @@ public abstract class DirectSearchOptimizer {
|
|||
* @exception ConvergenceException if none of the starts did
|
||||
* converge (it is not thrown if at least one start did converge)
|
||||
*/
|
||||
public PointCostPair minimizes(CostFunction f, int maxEvaluations,
|
||||
public PointCostPair minimize(CostFunction f, int maxEvaluations,
|
||||
ConvergenceChecker checker,
|
||||
double[][] vertices,
|
||||
int starts, long seed)
|
||||
|
@ -265,7 +265,7 @@ public abstract class DirectSearchOptimizer {
|
|||
setMultiStart(starts, rvg);
|
||||
|
||||
// compute minimum
|
||||
return minimizes(f, maxEvaluations, checker);
|
||||
return minimize(f, maxEvaluations, checker);
|
||||
|
||||
} catch (DimensionMismatchException dme) {
|
||||
// this should not happen
|
||||
|
@ -291,7 +291,7 @@ public abstract class DirectSearchOptimizer {
|
|||
* @exception ConvergenceException if none of the starts did
|
||||
* converge (it is not thrown if at least one start did converge)
|
||||
*/
|
||||
public PointCostPair minimizes(CostFunction f, int maxEvaluations,
|
||||
public PointCostPair minimize(CostFunction f, int maxEvaluations,
|
||||
ConvergenceChecker checker,
|
||||
RandomVectorGenerator generator)
|
||||
throws CostException, ConvergenceException {
|
||||
|
@ -301,7 +301,7 @@ public abstract class DirectSearchOptimizer {
|
|||
setSingleStart();
|
||||
|
||||
// compute minimum
|
||||
return minimizes(f, maxEvaluations, checker);
|
||||
return minimize(f, maxEvaluations, checker);
|
||||
|
||||
}
|
||||
|
||||
|
@ -325,7 +325,7 @@ public abstract class DirectSearchOptimizer {
|
|||
* @exception ConvergenceException if none of the starts did
|
||||
* converge (it is not thrown if at least one start did converge)
|
||||
*/
|
||||
public PointCostPair minimizes(CostFunction f, int maxEvaluations,
|
||||
public PointCostPair minimize(CostFunction f, int maxEvaluations,
|
||||
ConvergenceChecker checker,
|
||||
RandomVectorGenerator generator,
|
||||
int starts)
|
||||
|
@ -336,7 +336,7 @@ public abstract class DirectSearchOptimizer {
|
|||
setMultiStart(starts, generator);
|
||||
|
||||
// compute minimum
|
||||
return minimizes(f, maxEvaluations, checker);
|
||||
return minimize(f, maxEvaluations, checker);
|
||||
|
||||
}
|
||||
|
||||
|
@ -426,27 +426,27 @@ public abstract class DirectSearchOptimizer {
|
|||
}
|
||||
|
||||
/** Get all the minima found during the last call to {@link
|
||||
* #minimizes(CostFunction, int, ConvergenceChecker, double[], double[])
|
||||
* minimizes}.
|
||||
* #minimize(CostFunction, int, ConvergenceChecker, double[], double[])
|
||||
* minimize}.
|
||||
* <p>The optimizer stores all the minima found during a set of
|
||||
* restarts when multi-start mode is enabled. The {@link
|
||||
* #minimizes(CostFunction, int, ConvergenceChecker, double[], double[])
|
||||
* minimizes} method returns the best point only. This method
|
||||
* #minimize(CostFunction, int, ConvergenceChecker, double[], double[])
|
||||
* minimize} method returns the best point only. This method
|
||||
* returns all the points found at the end of each starts, including
|
||||
* the best one already returned by the {@link #minimizes(CostFunction,
|
||||
* int, ConvergenceChecker, double[], double[]) minimizes} method.
|
||||
* the best one already returned by the {@link #minimize(CostFunction,
|
||||
* int, ConvergenceChecker, double[], double[]) minimize} method.
|
||||
* The array as one element for each start as specified in the constructor
|
||||
* (it has one element only if optimizer has been set up for single-start).</p>
|
||||
* <p>The array containing the minima is ordered with the results
|
||||
* from the runs that did converge first, sorted from lowest to
|
||||
* highest minimum cost, and null elements corresponding to the runs
|
||||
* that did not converge (all elements will be null if the {@link
|
||||
* #minimizes(CostFunction, int, ConvergenceChecker, double[], double[])
|
||||
* minimizes} method did throw a {@link ConvergenceException
|
||||
* #minimize(CostFunction, int, ConvergenceChecker, double[], double[])
|
||||
* minimize} method did throw a {@link ConvergenceException
|
||||
* ConvergenceException}).</p>
|
||||
* @return array containing the minima, or null if {@link
|
||||
* #minimizes(CostFunction, int, ConvergenceChecker, double[], double[])
|
||||
* minimizes} has not been called
|
||||
* #minimize(CostFunction, int, ConvergenceChecker, double[], double[])
|
||||
* minimize} has not been called
|
||||
*/
|
||||
public PointCostPair[] getMinima() {
|
||||
return (PointCostPair[]) minima.clone();
|
||||
|
@ -466,7 +466,7 @@ public abstract class DirectSearchOptimizer {
|
|||
* @exception ConvergenceException if none of the starts did
|
||||
* converge (it is not thrown if at least one start did converge)
|
||||
*/
|
||||
private PointCostPair minimizes(CostFunction f, int maxEvaluations,
|
||||
private PointCostPair minimize(CostFunction f, int maxEvaluations,
|
||||
ConvergenceChecker checker)
|
||||
throws CostException, ConvergenceException {
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ public class MultiDirectionalTest
|
|||
}
|
||||
};
|
||||
try {
|
||||
new MultiDirectional(1.9, 0.4).minimizes(wrong, 10, new ValueChecker(1.0e-3),
|
||||
new MultiDirectional(1.9, 0.4).minimize(wrong, 10, new ValueChecker(1.0e-3),
|
||||
new double[] { -0.5 }, new double[] { 0.5 });
|
||||
fail("an exception should have been thrown");
|
||||
} catch (CostException ce) {
|
||||
|
@ -57,7 +57,7 @@ public class MultiDirectionalTest
|
|||
fail("wrong exception caught: " + e.getMessage());
|
||||
}
|
||||
try {
|
||||
new MultiDirectional(1.9, 0.4).minimizes(wrong, 10, new ValueChecker(1.0e-3),
|
||||
new MultiDirectional(1.9, 0.4).minimize(wrong, 10, new ValueChecker(1.0e-3),
|
||||
new double[] { 0.5 }, new double[] { 1.5 });
|
||||
fail("an exception should have been thrown");
|
||||
} catch (CostException ce) {
|
||||
|
@ -83,7 +83,7 @@ public class MultiDirectionalTest
|
|||
|
||||
count = 0;
|
||||
PointCostPair optimum =
|
||||
new MultiDirectional().minimizes(rosenbrock, 100, new ValueChecker(1.0e-3),
|
||||
new MultiDirectional().minimize(rosenbrock, 100, new ValueChecker(1.0e-3),
|
||||
new double[][] {
|
||||
{ -1.2, 1.0 }, { 0.9, 1.2 } , { 3.5, -2.3 }
|
||||
});
|
||||
|
@ -110,7 +110,7 @@ public class MultiDirectionalTest
|
|||
|
||||
count = 0;
|
||||
PointCostPair optimum =
|
||||
new MultiDirectional().minimizes(powell, 1000, new ValueChecker(1.0e-3),
|
||||
new MultiDirectional().minimize(powell, 1000, new ValueChecker(1.0e-3),
|
||||
new double[] { 3.0, -1.0, 0.0, 1.0 },
|
||||
new double[] { 4.0, 0.0, 1.0, 2.0 });
|
||||
assertTrue(count > 850);
|
||||
|
|
|
@ -53,7 +53,7 @@ public class NelderMeadTest
|
|||
}
|
||||
};
|
||||
try {
|
||||
new NelderMead(0.9, 1.9, 0.4, 0.6).minimizes(wrong, 10, new ValueChecker(1.0e-3),
|
||||
new NelderMead(0.9, 1.9, 0.4, 0.6).minimize(wrong, 10, new ValueChecker(1.0e-3),
|
||||
new double[] { -0.5 }, new double[] { 0.5 });
|
||||
fail("an exception should have been thrown");
|
||||
} catch (CostException ce) {
|
||||
|
@ -63,7 +63,7 @@ public class NelderMeadTest
|
|||
fail("wrong exception caught: " + e.getMessage());
|
||||
}
|
||||
try {
|
||||
new NelderMead(0.9, 1.9, 0.4, 0.6).minimizes(wrong, 10, new ValueChecker(1.0e-3),
|
||||
new NelderMead(0.9, 1.9, 0.4, 0.6).minimize(wrong, 10, new ValueChecker(1.0e-3),
|
||||
new double[] { 0.5 }, new double[] { 1.5 });
|
||||
fail("an exception should have been thrown");
|
||||
} catch (CostException ce) {
|
||||
|
@ -90,7 +90,7 @@ public class NelderMeadTest
|
|||
count = 0;
|
||||
NelderMead nm = new NelderMead();
|
||||
try {
|
||||
nm.minimizes(rosenbrock, 100, new ValueChecker(1.0e-3),
|
||||
nm.minimize(rosenbrock, 100, new ValueChecker(1.0e-3),
|
||||
new double[][] {
|
||||
{ -1.2, 1.0 }, { 3.5, -2.3 }, { 0.4, 1.5 }
|
||||
}, 1, 5384353l);
|
||||
|
@ -103,7 +103,7 @@ public class NelderMeadTest
|
|||
|
||||
count = 0;
|
||||
PointCostPair optimum =
|
||||
nm.minimizes(rosenbrock, 100, new ValueChecker(1.0e-3),
|
||||
nm.minimize(rosenbrock, 100, new ValueChecker(1.0e-3),
|
||||
new double[][] {
|
||||
{ -1.2, 1.0 }, { 0.9, 1.2 }, { 3.5, -2.3 }
|
||||
}, 10, 1642738l);
|
||||
|
@ -137,10 +137,10 @@ public class NelderMeadTest
|
|||
new double[] { 0.2, 0.2 },
|
||||
new UniformRandomGenerator(rg));
|
||||
optimum =
|
||||
nm.minimizes(rosenbrock, 100, new ValueChecker(1.0e-3), rvg);
|
||||
nm.minimize(rosenbrock, 100, new ValueChecker(1.0e-3), rvg);
|
||||
assertEquals(0.0, optimum.getCost(), 2.0e-4);
|
||||
optimum =
|
||||
nm.minimizes(rosenbrock, 100, new ValueChecker(1.0e-3), rvg, 3);
|
||||
nm.minimize(rosenbrock, 100, new ValueChecker(1.0e-3), rvg, 3);
|
||||
assertEquals(0.0, optimum.getCost(), 3.0e-5);
|
||||
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ public class NelderMeadTest
|
|||
count = 0;
|
||||
NelderMead nm = new NelderMead();
|
||||
PointCostPair optimum =
|
||||
nm.minimizes(powell, 200, new ValueChecker(1.0e-3),
|
||||
nm.minimize(powell, 200, new ValueChecker(1.0e-3),
|
||||
new double[] { 3.0, -1.0, 0.0, 1.0 },
|
||||
new double[] { 4.0, 0.0, 1.0, 2.0 },
|
||||
1, 1642738l);
|
||||
|
|
Loading…
Reference in New Issue