Serialization changes for optimization.

Still need to add junit test, but for this it doesn't look like a blocker.


git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@782468 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
William Barker 2009-06-07 21:24:18 +00:00
parent aaf87073b5
commit d088734d25
12 changed files with 18 additions and 27 deletions

View File

@ -17,8 +17,6 @@
package org.apache.commons.math.optimization;
import java.io.Serializable;
import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.analysis.DifferentiableMultivariateRealFunction;
@ -32,7 +30,7 @@ import org.apache.commons.math.analysis.DifferentiableMultivariateRealFunction;
* @version $Revision$ $Date$
* @since 2.0
*/
public interface DifferentiableMultivariateRealOptimizer extends Serializable {
public interface DifferentiableMultivariateRealOptimizer {
/** Set the maximal number of iterations of the algorithm.
* @param maxIterations maximal number of function calls

View File

@ -17,8 +17,6 @@
package org.apache.commons.math.optimization;
import java.io.Serializable;
import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.analysis.DifferentiableMultivariateVectorialFunction;
@ -32,7 +30,7 @@ import org.apache.commons.math.analysis.DifferentiableMultivariateVectorialFunct
* @version $Revision$ $Date$
* @since 2.0
*/
public interface DifferentiableMultivariateVectorialOptimizer extends Serializable {
public interface DifferentiableMultivariateVectorialOptimizer {
/** Set the maximal number of iterations of the algorithm.
* @param maxIterations maximal number of function calls

View File

@ -17,6 +17,7 @@
package org.apache.commons.math.optimization;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Comparator;
@ -38,7 +39,7 @@ import org.apache.commons.math.random.RandomVectorGenerator;
* @since 2.0
*/
public class MultiStartDifferentiableMultivariateRealOptimizer
implements DifferentiableMultivariateRealOptimizer {
implements DifferentiableMultivariateRealOptimizer, Serializable {
/** Serializable version identifier. */
private static final long serialVersionUID = -3220364832729994537L;

View File

@ -86,12 +86,7 @@ import org.apache.commons.math.optimization.SimpleScalarValueChecker;
* @version $Revision$ $Date$
* @since 1.2
*/
public abstract class DirectSearchOptimizer implements MultivariateRealOptimizer, Serializable {
// TODO: Add Serializable documentation
// TODO: Check Serializable implementation
/** Serializable version identifier. */
private static final long serialVersionUID = 4299910390345933369L;
public abstract class DirectSearchOptimizer implements MultivariateRealOptimizer {
/** Simplex. */
protected RealPointValuePair[] simplex;

View File

@ -41,9 +41,6 @@ import org.apache.commons.math.optimization.VectorialPointValuePair;
*/
public abstract class AbstractLeastSquaresOptimizer implements DifferentiableMultivariateVectorialOptimizer {
/** Serializable version identifier */
private static final long serialVersionUID = 5413193243329026789L;
/** Default maximal number of iterations allowed. */
public static final int DEFAULT_MAX_ITERATIONS = 100;

View File

@ -41,9 +41,6 @@ public abstract class AbstractScalarDifferentiableOptimizer
/** Default maximal number of iterations allowed. */
public static final int DEFAULT_MAX_ITERATIONS = 100;
/** Serializable version identifier. */
private static final long serialVersionUID = 1357126012308766636L;
/** Maximal number of iterations allowed. */
private int maxIterations;

View File

@ -17,6 +17,8 @@
package org.apache.commons.math.optimization.general;
import java.io.Serializable;
import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.linear.DecompositionSolver;
import org.apache.commons.math.linear.DenseRealMatrix;
@ -42,7 +44,7 @@ import org.apache.commons.math.optimization.VectorialPointValuePair;
*
*/
public class GaussNewtonOptimizer extends AbstractLeastSquaresOptimizer {
public class GaussNewtonOptimizer extends AbstractLeastSquaresOptimizer implements Serializable {
/** Serializable version identifier */
private static final long serialVersionUID = 7011643996279553223L;

View File

@ -16,6 +16,7 @@
*/
package org.apache.commons.math.optimization.general;
import java.io.Serializable;
import java.util.Arrays;
import org.apache.commons.math.FunctionEvaluationException;
@ -99,7 +100,7 @@ import org.apache.commons.math.optimization.VectorialPointValuePair;
* @since 2.0
*
*/
public class LevenbergMarquardtOptimizer extends AbstractLeastSquaresOptimizer {
public class LevenbergMarquardtOptimizer extends AbstractLeastSquaresOptimizer implements Serializable {
/** Serializable version identifier */
private static final long serialVersionUID = 8851282236194244323L;

View File

@ -45,7 +45,7 @@ import org.apache.commons.math.optimization.SimpleVectorialValueChecker;
public class NonLinearConjugateGradientOptimizer
extends AbstractScalarDifferentiableOptimizer
implements DifferentiableMultivariateRealOptimizer {
implements DifferentiableMultivariateRealOptimizer, Serializable {
/** Serializable version identifier. */
private static final long serialVersionUID = -6545223926568155458L;
@ -242,7 +242,7 @@ public class NonLinearConjugateGradientOptimizer
}
/** Default identity preconditioner. */
private static class IdentityPreconditioner implements Preconditioner {
private static class IdentityPreconditioner implements Preconditioner, Serializable {
/** Serializable version identifier. */
private static final long serialVersionUID = 1868235977809734023L;

View File

@ -17,8 +17,6 @@
package org.apache.commons.math.optimization.general;
import java.io.Serializable;
import org.apache.commons.math.FunctionEvaluationException;
/**
@ -27,7 +25,7 @@ import org.apache.commons.math.FunctionEvaluationException;
* @version $Revision$ $Date$
* @since 2.0
*/
public interface Preconditioner extends Serializable {
public interface Preconditioner {
/**
* Precondition a search direction.

View File

@ -191,7 +191,6 @@ extends TestCase {
new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE);
optimizer.setMaxIterations(100);
optimizer.setPreconditioner(new Preconditioner() {
private static final long serialVersionUID = -2935127802358453014L;
public double[] precondition(double[] point, double[] r) {
double[] d = r.clone();
d[0] /= 72.0;

View File

@ -21,6 +21,7 @@ import junit.framework.TestSuite;
import java.util.HashSet;
import org.apache.commons.math.RetryTestCase;
import org.apache.commons.math.TestUtils;
import org.apache.commons.math.stat.Frequency;
import org.apache.commons.math.stat.inference.ChiSquareTestImpl;
import org.apache.commons.math.stat.descriptive.SummaryStatistics;
@ -607,6 +608,10 @@ public class RandomDataTest extends RetryTestCase {
}
}
// Disable until we have equals
//public void testSerial() {
// assertEquals(randomData, TestUtils.serializeAndRecover(randomData));
//}
private int findPerm(int[][] p, int[] samp) {
for (int i = 0; i < p.length; i++) {