MATH-1594: Remove "Serializable".
This commit is contained in:
parent
94061dc566
commit
eab5cb3af1
|
@ -16,11 +16,6 @@
|
|||
*/
|
||||
package org.apache.commons.math4.legacy.optim.linear;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math4.legacy.linear.ArrayRealVector;
|
||||
import org.apache.commons.math4.legacy.linear.MatrixUtils;
|
||||
import org.apache.commons.math4.legacy.linear.RealVector;
|
||||
|
@ -45,9 +40,7 @@ import org.apache.commons.math4.legacy.linear.RealVector;
|
|||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public class LinearConstraint implements Serializable {
|
||||
/** Serializable version identifier. */
|
||||
private static final long serialVersionUID = -764632794033034092L;
|
||||
public class LinearConstraint {
|
||||
/** Coefficients of the constraint (left hand side). */
|
||||
private final transient RealVector coefficients;
|
||||
/** Relationship between left and right hand sides {@code (=, <=, >=)}. */
|
||||
|
@ -204,27 +197,4 @@ public class LinearConstraint implements Serializable {
|
|||
Double.valueOf(value).hashCode() ^
|
||||
coefficients.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the instance.
|
||||
* @param oos stream where object should be written
|
||||
* @throws IOException if object cannot be written to stream
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream oos)
|
||||
throws IOException {
|
||||
oos.defaultWriteObject();
|
||||
MatrixUtils.serializeRealVector(coefficients, oos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserialize the instance.
|
||||
* @param ois stream from which the object should be read
|
||||
* @throws ClassNotFoundException if a class in the stream cannot be found
|
||||
* @throws IOException if object cannot be read from the stream
|
||||
*/
|
||||
private void readObject(ObjectInputStream ois)
|
||||
throws ClassNotFoundException, IOException {
|
||||
ois.defaultReadObject();
|
||||
MatrixUtils.deserializeRealVector(this, "coefficients", ois);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,11 +16,6 @@
|
|||
*/
|
||||
package org.apache.commons.math4.legacy.optim.linear;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math4.legacy.analysis.MultivariateFunction;
|
||||
import org.apache.commons.math4.legacy.linear.ArrayRealVector;
|
||||
import org.apache.commons.math4.legacy.linear.MatrixUtils;
|
||||
|
@ -41,10 +36,7 @@ import org.apache.commons.math4.legacy.optim.OptimizationData;
|
|||
*/
|
||||
public class LinearObjectiveFunction
|
||||
implements MultivariateFunction,
|
||||
OptimizationData,
|
||||
Serializable {
|
||||
/** Serializable version identifier. */
|
||||
private static final long serialVersionUID = -4531815507568396090L;
|
||||
OptimizationData {
|
||||
/** Coefficients of the linear equation (c<sub>i</sub>). */
|
||||
private final transient RealVector coefficients;
|
||||
/** Constant term of the linear equation. */
|
||||
|
@ -125,27 +117,4 @@ public class LinearObjectiveFunction
|
|||
public int hashCode() {
|
||||
return Double.valueOf(constantTerm).hashCode() ^ coefficients.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the instance.
|
||||
* @param oos stream where object should be written
|
||||
* @throws IOException if object cannot be written to stream
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream oos)
|
||||
throws IOException {
|
||||
oos.defaultWriteObject();
|
||||
MatrixUtils.serializeRealVector(coefficients, oos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserialize the instance.
|
||||
* @param ois stream from which the object should be read
|
||||
* @throws ClassNotFoundException if a class in the stream cannot be found
|
||||
* @throws IOException if object cannot be read from the stream
|
||||
*/
|
||||
private void readObject(ObjectInputStream ois)
|
||||
throws ClassNotFoundException, IOException {
|
||||
ois.defaultReadObject();
|
||||
MatrixUtils.deserializeRealVector(this, "coefficients", ois);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,10 +16,6 @@
|
|||
*/
|
||||
package org.apache.commons.math4.legacy.optim.linear;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
@ -69,14 +65,10 @@ import org.apache.commons.numbers.core.Precision;
|
|||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
class SimplexTableau implements Serializable {
|
||||
class SimplexTableau {
|
||||
|
||||
/** Column label for negative vars. */
|
||||
private static final String NEGATIVE_VAR_COLUMN_LABEL = "x-";
|
||||
|
||||
/** Serializable version identifier. */
|
||||
private static final long serialVersionUID = -1369660067587938365L;
|
||||
|
||||
/** bit mask for IEEE double exponent. */
|
||||
private static final long EXPN = 0x7ff0000000000000L;
|
||||
/** bit mask for IEEE double mantissa and sign. */
|
||||
|
@ -889,27 +881,4 @@ class SimplexTableau implements Serializable {
|
|||
constraints.hashCode() ^
|
||||
tableau.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the instance.
|
||||
* @param oos stream where object should be written
|
||||
* @throws IOException if object cannot be written to stream
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream oos)
|
||||
throws IOException {
|
||||
oos.defaultWriteObject();
|
||||
MatrixUtils.serializeRealMatrix(tableau, oos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserialize the instance.
|
||||
* @param ois stream from which the object should be read
|
||||
* @throws ClassNotFoundException if a class in the stream cannot be found
|
||||
* @throws IOException if object cannot be read from the stream
|
||||
*/
|
||||
private void readObject(ObjectInputStream ois)
|
||||
throws ClassNotFoundException, IOException {
|
||||
ois.defaultReadObject();
|
||||
MatrixUtils.deserializeRealMatrix(this, "tableau", ois);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,15 +76,6 @@ public class SimplexTableauTest {
|
|||
assertMatrixEquals(initialTableau, tableau.getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSerial() {
|
||||
LinearObjectiveFunction f = createFunction();
|
||||
Collection<LinearConstraint> constraints = createConstraints();
|
||||
SimplexTableau tableau =
|
||||
new SimplexTableau(f, constraints, GoalType.MAXIMIZE, false, 1.0e-6);
|
||||
Assert.assertEquals(tableau, TestUtils.serializeAndRecover(tableau));
|
||||
}
|
||||
|
||||
private LinearObjectiveFunction createFunction() {
|
||||
return new LinearObjectiveFunction(new double[] {15, 10}, 0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue