tighten checkstyle rules for hidden fields
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@810238 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
de33e91191
commit
0283b0c935
|
@ -85,11 +85,13 @@
|
|||
<!-- Constant names should obey the traditional all uppercase naming convention -->
|
||||
<module name="ConstantName" />
|
||||
|
||||
<!--
|
||||
<!-- Method parameters and local variables should not hide fields, except in constructors and setters -->
|
||||
<module name="HiddenField">
|
||||
<property name="ignoreConstructorParameter" value="true" />
|
||||
<property name="ignoreSetter" value="true" />
|
||||
</module>
|
||||
|
||||
<!--
|
||||
<module name="DeclarationOrder" />
|
||||
<module name="IllegalCatch" />
|
||||
<module name="RedundantModifier" />
|
||||
|
|
|
@ -115,11 +115,11 @@ public abstract class UnivariateRealIntegratorImpl
|
|||
/**
|
||||
* Convenience function for implementations.
|
||||
*
|
||||
* @param result the result to set
|
||||
* @param newResult the result to set
|
||||
* @param iterationCount the iteration count to set
|
||||
*/
|
||||
protected final void setResult(double result, int iterationCount) {
|
||||
this.result = result;
|
||||
protected final void setResult(double newResult, int iterationCount) {
|
||||
this.result = newResult;
|
||||
this.iterationCount = iterationCount;
|
||||
this.resultComputed = true;
|
||||
}
|
||||
|
|
|
@ -134,11 +134,11 @@ public abstract class UnivariateRealSolverImpl
|
|||
/**
|
||||
* Convenience function for implementations.
|
||||
*
|
||||
* @param result the result to set
|
||||
* @param newResult the result to set
|
||||
* @param iterationCount the iteration count to set
|
||||
*/
|
||||
protected final void setResult(final double result, final int iterationCount) {
|
||||
this.result = result;
|
||||
protected final void setResult(final double newResult, final int iterationCount) {
|
||||
this.result = newResult;
|
||||
this.iterationCount = iterationCount;
|
||||
this.resultComputed = true;
|
||||
}
|
||||
|
@ -171,16 +171,16 @@ public abstract class UnivariateRealSolverImpl
|
|||
*
|
||||
* @param lower the lower endpoint
|
||||
* @param upper the upper endpoint
|
||||
* @param f the function
|
||||
* @param function the function
|
||||
* @return true if f(lower) * f(upper) < 0
|
||||
* @throws FunctionEvaluationException if an error occurs evaluating the
|
||||
* function at the endpoints
|
||||
*/
|
||||
protected boolean isBracketing(final double lower, final double upper,
|
||||
final UnivariateRealFunction f)
|
||||
final UnivariateRealFunction function)
|
||||
throws FunctionEvaluationException {
|
||||
final double f1 = f.value(lower);
|
||||
final double f2 = f.value(upper);
|
||||
final double f1 = function.value(lower);
|
||||
final double f2 = function.value(upper);
|
||||
return ((f1 > 0 && f2 < 0) || (f1 < 0 && f2 > 0));
|
||||
}
|
||||
|
||||
|
@ -235,21 +235,21 @@ public abstract class UnivariateRealSolverImpl
|
|||
*
|
||||
* @param lower lower endpoint
|
||||
* @param upper upper endpoint
|
||||
* @param f function
|
||||
* @param function function
|
||||
* @throws IllegalArgumentException
|
||||
* @throws FunctionEvaluationException if an error occurs evaluating the
|
||||
* function at the endpoints
|
||||
*/
|
||||
protected void verifyBracketing(final double lower, final double upper,
|
||||
final UnivariateRealFunction f)
|
||||
final UnivariateRealFunction function)
|
||||
throws FunctionEvaluationException {
|
||||
|
||||
verifyInterval(lower, upper);
|
||||
if (!isBracketing(lower, upper, f)) {
|
||||
if (!isBracketing(lower, upper, function)) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"function values at endpoints do not have different signs. " +
|
||||
"Endpoints: [{0}, {1}], Values: [{2}, {3}]",
|
||||
lower, upper, f.value(lower), f.value(upper));
|
||||
lower, upper, function.value(lower), function.value(upper));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1001,13 +1001,13 @@ public class Complex implements FieldElement<Complex>, Serializable {
|
|||
/**
|
||||
* Create a complex number given the real and imaginary parts.
|
||||
*
|
||||
* @param real the real part
|
||||
* @param imaginary the imaginary part
|
||||
* @param realPart the real part
|
||||
* @param imaginaryPart the imaginary part
|
||||
* @return a new complex number instance
|
||||
* @since 1.2
|
||||
*/
|
||||
protected Complex createComplex(double real, double imaginary) {
|
||||
return new Complex(real, imaginary);
|
||||
protected Complex createComplex(double realPart, double imaginaryPart) {
|
||||
return new Complex(realPart, imaginaryPart);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,10 +35,10 @@ public class WeibullDistributionImpl extends AbstractContinuousDistribution
|
|||
private static final long serialVersionUID = 8589540077390120676L;
|
||||
|
||||
/** The shape parameter. */
|
||||
private double alpha;
|
||||
private double shape;
|
||||
|
||||
/** The scale parameter. */
|
||||
private double beta;
|
||||
private double scale;
|
||||
|
||||
/**
|
||||
* Creates weibull distribution with the given shape and scale and a
|
||||
|
@ -72,7 +72,7 @@ public class WeibullDistributionImpl extends AbstractContinuousDistribution
|
|||
* @return the shape parameter.
|
||||
*/
|
||||
public double getShape() {
|
||||
return alpha;
|
||||
return shape;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,7 +80,7 @@ public class WeibullDistributionImpl extends AbstractContinuousDistribution
|
|||
* @return the scale parameter.
|
||||
*/
|
||||
public double getScale() {
|
||||
return beta;
|
||||
return scale;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -121,7 +121,7 @@ public class WeibullDistributionImpl extends AbstractContinuousDistribution
|
|||
"shape must be positive ({0})",
|
||||
alpha);
|
||||
}
|
||||
this.alpha = alpha;
|
||||
this.shape = alpha;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -134,7 +134,7 @@ public class WeibullDistributionImpl extends AbstractContinuousDistribution
|
|||
"scale must be positive ({0})",
|
||||
beta);
|
||||
}
|
||||
this.beta = beta;
|
||||
this.scale = beta;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -173,14 +173,14 @@ public abstract class AbstractEstimator implements Estimator {
|
|||
updateJacobian();
|
||||
|
||||
// compute transpose(J).J, avoiding building big intermediate matrices
|
||||
final int rows = problem.getMeasurements().length;
|
||||
final int cols = problem.getUnboundParameters().length;
|
||||
final int max = cols * rows;
|
||||
double[][] jTj = new double[cols][cols];
|
||||
for (int i = 0; i < cols; ++i) {
|
||||
for (int j = i; j < cols; ++j) {
|
||||
final int n = problem.getMeasurements().length;
|
||||
final int m = problem.getUnboundParameters().length;
|
||||
final int max = m * n;
|
||||
double[][] jTj = new double[m][m];
|
||||
for (int i = 0; i < m; ++i) {
|
||||
for (int j = i; j < m; ++j) {
|
||||
double sum = 0;
|
||||
for (int k = 0; k < max; k += cols) {
|
||||
for (int k = 0; k < max; k += m) {
|
||||
sum += jacobian[k + i] * jacobian[k + j];
|
||||
}
|
||||
jTj[i][j] = sum;
|
||||
|
|
|
@ -57,11 +57,11 @@ public abstract class AbstractListChromosome<T> extends Chromosome {
|
|||
/**
|
||||
*
|
||||
* Asserts that <code>representation</code> can represent a valid chromosome.
|
||||
* @param representation representation of the chromosome
|
||||
* @param chromosomeRepresentation representation of the chromosome
|
||||
* @throws InvalidRepresentationException iff the <code>representation</code> can not represent
|
||||
* a valid chromosome
|
||||
*/
|
||||
protected abstract void checkValidity(List<T> representation) throws InvalidRepresentationException;
|
||||
protected abstract void checkValidity(List<T> chromosomeRepresentation) throws InvalidRepresentationException;
|
||||
|
||||
/**
|
||||
* Returns the (immutable) inner representation of the chromosome.
|
||||
|
@ -87,12 +87,12 @@ public abstract class AbstractListChromosome<T> extends Chromosome {
|
|||
*
|
||||
* Usually, this method just calls a constructor of the class.
|
||||
*
|
||||
* @param representation
|
||||
* @param chromosomeRepresentation
|
||||
* the inner array representation of the new chromosome.
|
||||
* @return new instance extended from FixedLengthChromosome with the given
|
||||
* arrayRepresentation
|
||||
*/
|
||||
public abstract AbstractListChromosome<T> newFixedLengthChromosome(final List<T> representation);
|
||||
public abstract AbstractListChromosome<T> newFixedLengthChromosome(final List<T> chromosomeRepresentation);
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
|
|
|
@ -48,8 +48,8 @@ public abstract class BinaryChromosome extends AbstractListChromosome<Integer> {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void checkValidity(List<Integer> representation) throws InvalidRepresentationException {
|
||||
for (int i : representation) {
|
||||
protected void checkValidity(List<Integer> chromosomeRepresentation) throws InvalidRepresentationException {
|
||||
for (int i : chromosomeRepresentation) {
|
||||
if (i < 0 || i >1)
|
||||
throw new InvalidRepresentationException("Elements can be only 0 or 1.");
|
||||
}
|
||||
|
|
|
@ -172,8 +172,8 @@ public abstract class RandomKey<T> extends AbstractListChromosome<Double> implem
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void checkValidity(java.util.List<Double> representation) throws InvalidRepresentationException {
|
||||
for (double val : representation) {
|
||||
protected void checkValidity(java.util.List<Double> chromosomeRepresentation) throws InvalidRepresentationException {
|
||||
for (double val : chromosomeRepresentation) {
|
||||
if (val < 0 || val > 1) {
|
||||
throw new InvalidRepresentationException("Values of representation must be in [0,1] interval");
|
||||
}
|
||||
|
|
|
@ -851,27 +851,27 @@ public class EigenDecompositionImpl implements EigenDecomposition {
|
|||
sigmaLow = 0;
|
||||
|
||||
// find start of a new split segment to process
|
||||
double eMin = (i0 == n0) ? 0 : work[4 * n0 - 6];
|
||||
double eMax = 0;
|
||||
double qMax = work[4 * n0 - 4];
|
||||
double qMin = qMax;
|
||||
double offDiagMin = (i0 == n0) ? 0 : work[4 * n0 - 6];
|
||||
double offDiagMax = 0;
|
||||
double diagMax = work[4 * n0 - 4];
|
||||
double diagMin = diagMax;
|
||||
i0 = 0;
|
||||
for (int i = 4 * (n0 - 2); i >= 0; i -= 4) {
|
||||
if (work[i + 2] <= 0) {
|
||||
i0 = 1 + i / 4;
|
||||
break;
|
||||
}
|
||||
if (qMin >= 4 * eMax) {
|
||||
qMin = Math.min(qMin, work[i + 4]);
|
||||
eMax = Math.max(eMax, work[i + 2]);
|
||||
if (diagMin >= 4 * offDiagMax) {
|
||||
diagMin = Math.min(diagMin, work[i + 4]);
|
||||
offDiagMax = Math.max(offDiagMax, work[i + 2]);
|
||||
}
|
||||
qMax = Math.max(qMax, work[i] + work[i + 2]);
|
||||
eMin = Math.min(eMin, work[i + 2]);
|
||||
diagMax = Math.max(diagMax, work[i] + work[i + 2]);
|
||||
offDiagMin = Math.min(offDiagMin, work[i + 2]);
|
||||
}
|
||||
work[4 * n0 - 2] = eMin;
|
||||
work[4 * n0 - 2] = offDiagMin;
|
||||
|
||||
// lower bound of Gershgorin disk
|
||||
dMin = -Math.max(0, qMin - 2 * Math.sqrt(qMin * eMax));
|
||||
dMin = -Math.max(0, diagMin - 2 * Math.sqrt(diagMin * offDiagMax));
|
||||
|
||||
pingPong = 0;
|
||||
int maxIter = 30 * (n0 - i0);
|
||||
|
@ -887,11 +887,11 @@ public class EigenDecompositionImpl implements EigenDecomposition {
|
|||
// check for new splits after "ping" steps
|
||||
// when the last elements of qd array are very small
|
||||
if ((pingPong == 0) && (n0 - i0 > 3) &&
|
||||
(work[4 * n0 - 1] <= TOLERANCE_2 * qMax) &&
|
||||
(work[4 * n0 - 1] <= TOLERANCE_2 * diagMax) &&
|
||||
(work[4 * n0 - 2] <= TOLERANCE_2 * sigma)) {
|
||||
int split = i0 - 1;
|
||||
qMax = work[4 * i0];
|
||||
eMin = work[4 * i0 + 2];
|
||||
diagMax = work[4 * i0];
|
||||
offDiagMin = work[4 * i0 + 2];
|
||||
double previousEMin = work[4 * i0 + 3];
|
||||
for (int i = 4 * i0; i < 4 * n0 - 11; i += 4) {
|
||||
if ((work[i + 3] <= TOLERANCE_2 * work[i]) &&
|
||||
|
@ -899,16 +899,16 @@ public class EigenDecompositionImpl implements EigenDecomposition {
|
|||
// insert a split
|
||||
work[i + 2] = -sigma;
|
||||
split = i / 4;
|
||||
qMax = 0;
|
||||
eMin = work[i + 6];
|
||||
diagMax = 0;
|
||||
offDiagMin = work[i + 6];
|
||||
previousEMin = work[i + 7];
|
||||
} else {
|
||||
qMax = Math.max(qMax, work[i + 4]);
|
||||
eMin = Math.min(eMin, work[i + 2]);
|
||||
diagMax = Math.max(diagMax, work[i + 4]);
|
||||
offDiagMin = Math.min(offDiagMin, work[i + 2]);
|
||||
previousEMin = Math.min(previousEMin, work[i + 3]);
|
||||
}
|
||||
}
|
||||
work[4 * n0 - 2] = eMin;
|
||||
work[4 * n0 - 2] = offDiagMin;
|
||||
work[4 * n0 - 1] = previousEMin;
|
||||
i0 = split + 1;
|
||||
}
|
||||
|
@ -1662,20 +1662,20 @@ public class EigenDecompositionImpl implements EigenDecomposition {
|
|||
|
||||
/**
|
||||
* Update sigma.
|
||||
* @param tau shift to apply to sigma
|
||||
* @param shift shift to apply to sigma
|
||||
*/
|
||||
private void updateSigma(final double tau) {
|
||||
private void updateSigma(final double shift) {
|
||||
// BEWARE: do NOT attempt to simplify the following statements
|
||||
// the expressions below take care to accumulate the part of sigma
|
||||
// that does not fit within a double variable into sigmaLow
|
||||
if (tau < sigma) {
|
||||
sigmaLow += tau;
|
||||
if (shift < sigma) {
|
||||
sigmaLow += shift;
|
||||
final double t = sigma + sigmaLow;
|
||||
sigmaLow -= t - sigma;
|
||||
sigma = t;
|
||||
} else {
|
||||
final double t = sigma + tau;
|
||||
sigmaLow += sigma - (t - tau);
|
||||
final double t = sigma + shift;
|
||||
sigmaLow += sigma - (t - shift);
|
||||
sigma = t;
|
||||
}
|
||||
}
|
||||
|
@ -1731,8 +1731,7 @@ public class EigenDecompositionImpl implements EigenDecomposition {
|
|||
int r = m - 1;
|
||||
double minG = Math.abs(work[6 * r] + work[6 * r + 3] + eigenvalue);
|
||||
for (int i = 0, sixI = 0; i < m - 1; ++i, sixI += 6) {
|
||||
final double g = work[sixI] + d[i] * work[sixI + 9] / work[sixI + 10];
|
||||
final double absG = Math.abs(g);
|
||||
final double absG = Math.abs(work[sixI] + d[i] * work[sixI + 9] / work[sixI + 10]);
|
||||
if (absG < minG) {
|
||||
r = i;
|
||||
minG = absG;
|
||||
|
|
|
@ -33,10 +33,10 @@ public class OpenMapRealMatrix extends AbstractRealMatrix implements SparseRealM
|
|||
private static final long serialVersionUID = -5962461716457143437L;
|
||||
|
||||
/** Number of rows of the matrix. */
|
||||
private final int rowDimension;
|
||||
private final int rows;
|
||||
|
||||
/** Number of columns of the matrix. */
|
||||
private final int columnDimension;
|
||||
private final int columns;
|
||||
|
||||
/** Storage for (sparse) matrix elements. */
|
||||
private final OpenIntToDoubleHashMap entries;
|
||||
|
@ -48,8 +48,8 @@ public class OpenMapRealMatrix extends AbstractRealMatrix implements SparseRealM
|
|||
*/
|
||||
public OpenMapRealMatrix(int rowDimension, int columnDimension) {
|
||||
super(rowDimension, columnDimension);
|
||||
this.rowDimension = rowDimension;
|
||||
this.columnDimension = columnDimension;
|
||||
this.rows = rowDimension;
|
||||
this.columns = columnDimension;
|
||||
this.entries = new OpenIntToDoubleHashMap(0.0);
|
||||
}
|
||||
|
||||
|
@ -58,8 +58,8 @@ public class OpenMapRealMatrix extends AbstractRealMatrix implements SparseRealM
|
|||
* @param matrix matrix to copy
|
||||
*/
|
||||
public OpenMapRealMatrix(OpenMapRealMatrix matrix) {
|
||||
this.rowDimension = matrix.rowDimension;
|
||||
this.columnDimension = matrix.columnDimension;
|
||||
this.rows = matrix.rows;
|
||||
this.columns = matrix.columns;
|
||||
this.entries = new OpenIntToDoubleHashMap(matrix.entries);
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class OpenMapRealMatrix extends AbstractRealMatrix implements SparseRealM
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getColumnDimension() {
|
||||
return columnDimension;
|
||||
return columns;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -108,8 +108,8 @@ public class OpenMapRealMatrix extends AbstractRealMatrix implements SparseRealM
|
|||
final OpenMapRealMatrix out = new OpenMapRealMatrix(this);
|
||||
for (OpenIntToDoubleHashMap.Iterator iterator = m.entries.iterator(); iterator.hasNext();) {
|
||||
iterator.advance();
|
||||
final int row = iterator.key() / columnDimension;
|
||||
final int col = iterator.key() - row * columnDimension;
|
||||
final int row = iterator.key() / columns;
|
||||
final int col = iterator.key() - row * columns;
|
||||
out.setEntry(row, col, getEntry(row, col) + iterator.value());
|
||||
}
|
||||
|
||||
|
@ -143,8 +143,8 @@ public class OpenMapRealMatrix extends AbstractRealMatrix implements SparseRealM
|
|||
final OpenMapRealMatrix out = new OpenMapRealMatrix(this);
|
||||
for (OpenIntToDoubleHashMap.Iterator iterator = m.entries.iterator(); iterator.hasNext();) {
|
||||
iterator.advance();
|
||||
final int row = iterator.key() / columnDimension;
|
||||
final int col = iterator.key() - row * columnDimension;
|
||||
final int row = iterator.key() / columns;
|
||||
final int col = iterator.key() - row * columns;
|
||||
out.setEntry(row, col, getEntry(row, col) - iterator.value());
|
||||
}
|
||||
|
||||
|
@ -164,13 +164,13 @@ public class OpenMapRealMatrix extends AbstractRealMatrix implements SparseRealM
|
|||
MatrixUtils.checkMultiplicationCompatible(this, m);
|
||||
|
||||
final int outCols = m.getColumnDimension();
|
||||
final BlockRealMatrix out = new BlockRealMatrix(rowDimension, outCols);
|
||||
final BlockRealMatrix out = new BlockRealMatrix(rows, outCols);
|
||||
for (OpenIntToDoubleHashMap.Iterator iterator = entries.iterator(); iterator.hasNext();) {
|
||||
iterator.advance();
|
||||
final double value = iterator.value();
|
||||
final int key = iterator.key();
|
||||
final int i = key / columnDimension;
|
||||
final int k = key % columnDimension;
|
||||
final int i = key / columns;
|
||||
final int k = key % columns;
|
||||
for (int j = 0; j < outCols; ++j) {
|
||||
out.addToEntry(i, j, value * m.getEntry(k, j));
|
||||
}
|
||||
|
@ -195,13 +195,13 @@ public class OpenMapRealMatrix extends AbstractRealMatrix implements SparseRealM
|
|||
MatrixUtils.checkMultiplicationCompatible(this, m);
|
||||
|
||||
final int outCols = m.getColumnDimension();
|
||||
OpenMapRealMatrix out = new OpenMapRealMatrix(rowDimension, outCols);
|
||||
OpenMapRealMatrix out = new OpenMapRealMatrix(rows, outCols);
|
||||
for (OpenIntToDoubleHashMap.Iterator iterator = entries.iterator(); iterator.hasNext();) {
|
||||
iterator.advance();
|
||||
final double value = iterator.value();
|
||||
final int key = iterator.key();
|
||||
final int i = key / columnDimension;
|
||||
final int k = key % columnDimension;
|
||||
final int i = key / columns;
|
||||
final int k = key % columns;
|
||||
for (int j = 0; j < outCols; ++j) {
|
||||
final int rightKey = m.computeKey(k, j);
|
||||
if (m.entries.containsKey(rightKey)) {
|
||||
|
@ -232,7 +232,7 @@ public class OpenMapRealMatrix extends AbstractRealMatrix implements SparseRealM
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getRowDimension() {
|
||||
return rowDimension;
|
||||
return rows;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -285,7 +285,7 @@ public class OpenMapRealMatrix extends AbstractRealMatrix implements SparseRealM
|
|||
* @return key within the map to access the matrix element
|
||||
*/
|
||||
private int computeKey(int row, int column) {
|
||||
return row * columnDimension + column;
|
||||
return row * columns + column;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -37,11 +37,11 @@ public class SparseFieldMatrix<T extends FieldElement<T>> extends AbstractFieldM
|
|||
/**
|
||||
* row dimension
|
||||
*/
|
||||
private final int rowDimension;
|
||||
private final int rows;
|
||||
/**
|
||||
* column dimension
|
||||
*/
|
||||
private final int columnDimension;
|
||||
private final int columns;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -50,8 +50,8 @@ public class SparseFieldMatrix<T extends FieldElement<T>> extends AbstractFieldM
|
|||
*/
|
||||
public SparseFieldMatrix(final Field<T> field) {
|
||||
super(field);
|
||||
rowDimension = 0;
|
||||
columnDimension= 0;
|
||||
rows = 0;
|
||||
columns= 0;
|
||||
entries = new OpenIntToFieldHashMap<T>(field);
|
||||
}
|
||||
|
||||
|
@ -67,8 +67,8 @@ public class SparseFieldMatrix<T extends FieldElement<T>> extends AbstractFieldM
|
|||
final int rowDimension, final int columnDimension)
|
||||
throws IllegalArgumentException {
|
||||
super(field, rowDimension, columnDimension);
|
||||
this.rowDimension = rowDimension;
|
||||
this.columnDimension = columnDimension;
|
||||
this.rows = rowDimension;
|
||||
this.columns = columnDimension;
|
||||
entries = new OpenIntToFieldHashMap<T>(field);
|
||||
}
|
||||
|
||||
|
@ -78,8 +78,8 @@ public class SparseFieldMatrix<T extends FieldElement<T>> extends AbstractFieldM
|
|||
*/
|
||||
public SparseFieldMatrix(SparseFieldMatrix<T> other) {
|
||||
super(other.getField(), other.getRowDimension(), other.getColumnDimension());
|
||||
rowDimension = other.getRowDimension();
|
||||
columnDimension = other.getColumnDimension();
|
||||
rows = other.getRowDimension();
|
||||
columns = other.getColumnDimension();
|
||||
entries = new OpenIntToFieldHashMap<T>(other.entries);
|
||||
}
|
||||
|
||||
|
@ -89,11 +89,11 @@ public class SparseFieldMatrix<T extends FieldElement<T>> extends AbstractFieldM
|
|||
*/
|
||||
public SparseFieldMatrix(FieldMatrix<T> other){
|
||||
super(other.getField(), other.getRowDimension(), other.getColumnDimension());
|
||||
rowDimension = other.getRowDimension();
|
||||
columnDimension = other.getColumnDimension();
|
||||
rows = other.getRowDimension();
|
||||
columns = other.getColumnDimension();
|
||||
entries = new OpenIntToFieldHashMap<T>(getField());
|
||||
for (int i = 0; i < rowDimension; i++) {
|
||||
for (int j = 0; j < columnDimension; j++) {
|
||||
for (int i = 0; i < rows; i++) {
|
||||
for (int j = 0; j < columns; j++) {
|
||||
setEntry(i, j, other.getEntry(i, j));
|
||||
}
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ public class SparseFieldMatrix<T extends FieldElement<T>> extends AbstractFieldM
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getColumnDimension() {
|
||||
return columnDimension;
|
||||
return columns;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -145,7 +145,7 @@ public class SparseFieldMatrix<T extends FieldElement<T>> extends AbstractFieldM
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getRowDimension() {
|
||||
return rowDimension;
|
||||
return rows;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -184,7 +184,7 @@ public class SparseFieldMatrix<T extends FieldElement<T>> extends AbstractFieldM
|
|||
* @return key within the map to access the matrix element
|
||||
*/
|
||||
private int computeKey(int row, int column) {
|
||||
return row * columnDimension + column;
|
||||
return row * columns + column;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -184,30 +184,30 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
|
|||
}
|
||||
|
||||
/** Perform some sanity checks on the integration parameters.
|
||||
* @param equations differential equations set
|
||||
* @param ode differential equations set
|
||||
* @param t0 start time
|
||||
* @param y0 state vector at t0
|
||||
* @param t target time for the integration
|
||||
* @param y placeholder where to put the state vector
|
||||
* @exception IntegratorException if some inconsistency is detected
|
||||
*/
|
||||
protected void sanityChecks(final FirstOrderDifferentialEquations equations,
|
||||
protected void sanityChecks(final FirstOrderDifferentialEquations ode,
|
||||
final double t0, final double[] y0,
|
||||
final double t, final double[] y)
|
||||
throws IntegratorException {
|
||||
|
||||
if (equations.getDimension() != y0.length) {
|
||||
if (ode.getDimension() != y0.length) {
|
||||
throw new IntegratorException(
|
||||
"dimensions mismatch: ODE problem has dimension {0}," +
|
||||
" initial state vector has dimension {1}",
|
||||
equations.getDimension(), y0.length);
|
||||
ode.getDimension(), y0.length);
|
||||
}
|
||||
|
||||
if (equations.getDimension() != y.length) {
|
||||
if (ode.getDimension() != y.length) {
|
||||
throw new IntegratorException(
|
||||
"dimensions mismatch: ODE problem has dimension {0}," +
|
||||
" final state vector has dimension {1}",
|
||||
equations.getDimension(), y.length);
|
||||
ode.getDimension(), y.length);
|
||||
}
|
||||
|
||||
if (Math.abs(t - t0) <= 1.0e-12 * Math.max(Math.abs(t0), Math.abs(t))) {
|
||||
|
|
|
@ -183,10 +183,10 @@ public abstract class MultistepIntegrator extends AdaptiveStepsizeIntegrator {
|
|||
* <p>The various step and event handlers for this starter integrator
|
||||
* will be managed automatically by the multi-step integrator. Any
|
||||
* user configuration for these elements will be cleared before use.</p>
|
||||
* @param starter starter integrator
|
||||
* @param starterIntegrator starter integrator
|
||||
*/
|
||||
public void setStarterIntegrator(FirstOrderIntegrator starter) {
|
||||
this.starter = starter;
|
||||
public void setStarterIntegrator(FirstOrderIntegrator starterIntegrator) {
|
||||
this.starter = starterIntegrator;
|
||||
}
|
||||
|
||||
/** Start the integration.
|
||||
|
|
|
@ -138,17 +138,17 @@ public class EventState {
|
|||
}
|
||||
|
||||
/** Reinitialize the beginning of the step.
|
||||
* @param t0 value of the independent <i>time</i> variable at the
|
||||
* @param tStart value of the independent <i>time</i> variable at the
|
||||
* beginning of the step
|
||||
* @param y0 array containing the current value of the state vector
|
||||
* @param yStart array containing the current value of the state vector
|
||||
* at the beginning of the step
|
||||
* @exception EventException if the event handler
|
||||
* value cannot be evaluated at the beginning of the step
|
||||
*/
|
||||
public void reinitializeBegin(final double t0, final double[] y0)
|
||||
public void reinitializeBegin(final double tStart, final double[] yStart)
|
||||
throws EventException {
|
||||
this.t0 = t0;
|
||||
g0 = handler.g(t0, y0);
|
||||
t0 = tStart;
|
||||
g0 = handler.g(tStart, yStart);
|
||||
g0Positive = (g0 >= 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -150,29 +150,29 @@ public class GraggBulirschStoerIntegrator extends AdaptiveStepsizeIntegrator {
|
|||
* <p>By default, the test is performed, at most during two
|
||||
* iterations at each step, and at most once for each of these
|
||||
* iterations. The default stepsize reduction factor is 0.5.</p>
|
||||
* @param performTest if true, stability check will be performed,
|
||||
* @param performStabilityCheck if true, stability check will be performed,
|
||||
if false, the check will be skipped
|
||||
* @param maxIter maximal number of iterations for which checks are
|
||||
* @param maxNumIter maximal number of iterations for which checks are
|
||||
* performed (the number of iterations is reset to default if negative
|
||||
* or null)
|
||||
* @param maxChecks maximal number of checks for each iteration
|
||||
* @param maxNumChecks maximal number of checks for each iteration
|
||||
* (the number of checks is reset to default if negative or null)
|
||||
* @param stabilityReduction stepsize reduction factor in case of
|
||||
* @param stepsizeReductionFactor stepsize reduction factor in case of
|
||||
* failure (the factor is reset to default if lower than 0.0001 or
|
||||
* greater than 0.9999)
|
||||
*/
|
||||
public void setStabilityCheck(final boolean performTest,
|
||||
final int maxIter, final int maxChecks,
|
||||
final double stabilityReduction) {
|
||||
public void setStabilityCheck(final boolean performStabilityCheck,
|
||||
final int maxNumIter, final int maxNumChecks,
|
||||
final double stepsizeReductionFactor) {
|
||||
|
||||
this.performTest = performTest;
|
||||
this.maxIter = (maxIter <= 0) ? 2 : maxIter;
|
||||
this.maxChecks = (maxChecks <= 0) ? 1 : maxChecks;
|
||||
this.performTest = performStabilityCheck;
|
||||
this.maxIter = (maxNumIter <= 0) ? 2 : maxNumIter;
|
||||
this.maxChecks = (maxNumChecks <= 0) ? 1 : maxNumChecks;
|
||||
|
||||
if ((stabilityReduction < 0.0001) || (stabilityReduction > 0.9999)) {
|
||||
if ((stepsizeReductionFactor < 0.0001) || (stepsizeReductionFactor > 0.9999)) {
|
||||
this.stabilityReduction = 0.5;
|
||||
} else {
|
||||
this.stabilityReduction = stabilityReduction;
|
||||
this.stabilityReduction = stepsizeReductionFactor;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -192,40 +192,40 @@ public class GraggBulirschStoerIntegrator extends AdaptiveStepsizeIntegrator {
|
|||
* </pre>
|
||||
* The default values are 0.02 for stepControl3 and 4.0 for
|
||||
* stepControl4.</p>
|
||||
* @param stepControl1 first stepsize control factor (the factor is
|
||||
* @param control1 first stepsize control factor (the factor is
|
||||
* reset to default if lower than 0.0001 or greater than 0.9999)
|
||||
* @param stepControl2 second stepsize control factor (the factor
|
||||
* @param control2 second stepsize control factor (the factor
|
||||
* is reset to default if lower than 0.0001 or greater than 0.9999)
|
||||
* @param stepControl3 third stepsize control factor (the factor is
|
||||
* @param control3 third stepsize control factor (the factor is
|
||||
* reset to default if lower than 0.0001 or greater than 0.9999)
|
||||
* @param stepControl4 fourth stepsize control factor (the factor
|
||||
* @param control4 fourth stepsize control factor (the factor
|
||||
* is reset to default if lower than 1.0001 or greater than 999.9)
|
||||
*/
|
||||
public void setStepsizeControl(final double stepControl1, final double stepControl2,
|
||||
final double stepControl3, final double stepControl4) {
|
||||
public void setStepsizeControl(final double control1, final double control2,
|
||||
final double control3, final double control4) {
|
||||
|
||||
if ((stepControl1 < 0.0001) || (stepControl1 > 0.9999)) {
|
||||
if ((control1 < 0.0001) || (control1 > 0.9999)) {
|
||||
this.stepControl1 = 0.65;
|
||||
} else {
|
||||
this.stepControl1 = stepControl1;
|
||||
this.stepControl1 = control1;
|
||||
}
|
||||
|
||||
if ((stepControl2 < 0.0001) || (stepControl2 > 0.9999)) {
|
||||
if ((control2 < 0.0001) || (control2 > 0.9999)) {
|
||||
this.stepControl2 = 0.94;
|
||||
} else {
|
||||
this.stepControl2 = stepControl2;
|
||||
this.stepControl2 = control2;
|
||||
}
|
||||
|
||||
if ((stepControl3 < 0.0001) || (stepControl3 > 0.9999)) {
|
||||
if ((control3 < 0.0001) || (control3 > 0.9999)) {
|
||||
this.stepControl3 = 0.02;
|
||||
} else {
|
||||
this.stepControl3 = stepControl3;
|
||||
this.stepControl3 = control3;
|
||||
}
|
||||
|
||||
if ((stepControl4 < 1.0001) || (stepControl4 > 999.9)) {
|
||||
if ((control4 < 1.0001) || (control4 > 999.9)) {
|
||||
this.stepControl4 = 4.0;
|
||||
} else {
|
||||
this.stepControl4 = stepControl4;
|
||||
this.stepControl4 = control4;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -246,30 +246,30 @@ public class GraggBulirschStoerIntegrator extends AdaptiveStepsizeIntegrator {
|
|||
* <p>The default maximal order after construction is 18 (i.e. the
|
||||
* maximal number of columns is 9). The default values are 0.8 for
|
||||
* orderControl1 and 0.9 for orderControl2.</p>
|
||||
* @param maxOrder maximal order in the extrapolation table (the
|
||||
* @param maximalOrder maximal order in the extrapolation table (the
|
||||
* maximal order is reset to default if order <= 6 or odd)
|
||||
* @param orderControl1 first order control factor (the factor is
|
||||
* @param control1 first order control factor (the factor is
|
||||
* reset to default if lower than 0.0001 or greater than 0.9999)
|
||||
* @param orderControl2 second order control factor (the factor
|
||||
* @param control2 second order control factor (the factor
|
||||
* is reset to default if lower than 0.0001 or greater than 0.9999)
|
||||
*/
|
||||
public void setOrderControl(final int maxOrder,
|
||||
final double orderControl1, final double orderControl2) {
|
||||
public void setOrderControl(final int maximalOrder,
|
||||
final double control1, final double control2) {
|
||||
|
||||
if ((maxOrder <= 6) || (maxOrder % 2 != 0)) {
|
||||
if ((maximalOrder <= 6) || (maximalOrder % 2 != 0)) {
|
||||
this.maxOrder = 18;
|
||||
}
|
||||
|
||||
if ((orderControl1 < 0.0001) || (orderControl1 > 0.9999)) {
|
||||
if ((control1 < 0.0001) || (control1 > 0.9999)) {
|
||||
this.orderControl1 = 0.8;
|
||||
} else {
|
||||
this.orderControl1 = orderControl1;
|
||||
this.orderControl1 = control1;
|
||||
}
|
||||
|
||||
if ((orderControl2 < 0.0001) || (orderControl2 > 0.9999)) {
|
||||
if ((control2 < 0.0001) || (control2 > 0.9999)) {
|
||||
this.orderControl2 = 0.9;
|
||||
} else {
|
||||
this.orderControl2 = orderControl2;
|
||||
this.orderControl2 = control2;
|
||||
}
|
||||
|
||||
// reinitialize the arrays
|
||||
|
@ -352,20 +352,20 @@ public class GraggBulirschStoerIntegrator extends AdaptiveStepsizeIntegrator {
|
|||
* default value for mudif is 4 and the interpolation error is used
|
||||
* in stepsize control by default.
|
||||
|
||||
* @param useInterpolationError if true, interpolation error is used
|
||||
* @param useInterpolationErrorForControl if true, interpolation error is used
|
||||
* for stepsize control
|
||||
* @param mudif interpolation order control parameter (the parameter
|
||||
* @param mudifControlParameter interpolation order control parameter (the parameter
|
||||
* is reset to default if <= 0 or >= 7)
|
||||
*/
|
||||
public void setInterpolationControl(final boolean useInterpolationError,
|
||||
final int mudif) {
|
||||
public void setInterpolationControl(final boolean useInterpolationErrorForControl,
|
||||
final int mudifControlParameter) {
|
||||
|
||||
this.useInterpolationError = useInterpolationError;
|
||||
this.useInterpolationError = useInterpolationErrorForControl;
|
||||
|
||||
if ((mudif <= 0) || (mudif >= 7)) {
|
||||
if ((mudifControlParameter <= 0) || (mudifControlParameter >= 7)) {
|
||||
this.mudif = 4;
|
||||
} else {
|
||||
this.mudif = mudif;
|
||||
this.mudif = mudifControlParameter;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -108,18 +108,18 @@ abstract class RungeKuttaStepInterpolator
|
|||
* {@link AbstractStepInterpolator#getInterpolatedState
|
||||
* getInterpolatedState} method (for an interpolator which needs a
|
||||
* finalization) or if it clones the step interpolator.</p>
|
||||
* @param integrator integrator being used
|
||||
* @param rkIntegrator integrator being used
|
||||
* @param y reference to the integrator array holding the state at
|
||||
* the end of the step
|
||||
* @param yDotK reference to the integrator array holding all the
|
||||
* @param yDotArray reference to the integrator array holding all the
|
||||
* intermediate slopes
|
||||
* @param forward integration direction indicator
|
||||
*/
|
||||
public void reinitialize(final AbstractIntegrator integrator,
|
||||
final double[] y, final double[][] yDotK, final boolean forward) {
|
||||
public void reinitialize(final AbstractIntegrator rkIntegrator,
|
||||
final double[] y, final double[][] yDotArray, final boolean forward) {
|
||||
reinitialize(y, forward);
|
||||
this.yDotK = yDotK;
|
||||
this.integrator = integrator;
|
||||
this.yDotK = yDotArray;
|
||||
this.integrator = rkIntegrator;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
|
|
@ -164,9 +164,9 @@ public abstract class AbstractStepInterpolator
|
|||
/** Reinitialize the instance
|
||||
* @param y reference to the integrator array holding the state at
|
||||
* the end of the step
|
||||
* @param forward integration direction indicator
|
||||
* @param isForward integration direction indicator
|
||||
*/
|
||||
protected void reinitialize(final double[] y, final boolean forward) {
|
||||
protected void reinitialize(final double[] y, final boolean isForward) {
|
||||
|
||||
previousTime = Double.NaN;
|
||||
currentTime = Double.NaN;
|
||||
|
@ -178,7 +178,7 @@ public abstract class AbstractStepInterpolator
|
|||
interpolatedDerivatives = new double[y.length];
|
||||
|
||||
finalized = false;
|
||||
this.forward = forward;
|
||||
this.forward = isForward;
|
||||
this.dirtyState = true;
|
||||
|
||||
}
|
||||
|
|
|
@ -114,19 +114,20 @@ public class NordsieckStepInterpolator extends AbstractStepInterpolator {
|
|||
/** Reinitialize the instance.
|
||||
* <p>Beware that all arrays <em>must</em> be references to integrator
|
||||
* arrays, in order to ensure proper update without copy.</p>
|
||||
* @param referenceTime time at which all arrays are defined
|
||||
* @param scalingH step size used in the scaled and nordsieck arrays
|
||||
* @param scaled reference to the integrator array holding the first
|
||||
* @param time time at which all arrays are defined
|
||||
* @param stepSize step size used in the scaled and nordsieck arrays
|
||||
* @param scaledDerivative reference to the integrator array holding the first
|
||||
* scaled derivative
|
||||
* @param nordsieck reference to the integrator matrix holding the
|
||||
* @param nordsieckVector reference to the integrator matrix holding the
|
||||
* nordsieck vector
|
||||
*/
|
||||
public void reinitialize(final double referenceTime, final double scalingH,
|
||||
final double[] scaled, final Array2DRowRealMatrix nordsieck) {
|
||||
this.referenceTime = referenceTime;
|
||||
this.scalingH = scalingH;
|
||||
this.scaled = scaled;
|
||||
this.nordsieck = nordsieck;
|
||||
public void reinitialize(final double time, final double stepSize,
|
||||
final double[] scaledDerivative,
|
||||
final Array2DRowRealMatrix nordsieckVector) {
|
||||
this.referenceTime = time;
|
||||
this.scalingH = stepSize;
|
||||
this.scaled = scaledDerivative;
|
||||
this.nordsieck = nordsieckVector;
|
||||
|
||||
// make sure the state and derivatives will depend on the new arrays
|
||||
setInterpolatedTime(getInterpolatedTime());
|
||||
|
@ -136,11 +137,11 @@ public class NordsieckStepInterpolator extends AbstractStepInterpolator {
|
|||
/** Rescale the instance.
|
||||
* <p>Since the scaled and Nordiseck arrays are shared with the caller,
|
||||
* this method has the side effect of rescaling this arrays in the caller too.</p>
|
||||
* @param scalingH new step size to use in the scaled and nordsieck arrays
|
||||
* @param stepSize new step size to use in the scaled and nordsieck arrays
|
||||
*/
|
||||
public void rescale(final double scalingH) {
|
||||
public void rescale(final double stepSize) {
|
||||
|
||||
final double ratio = scalingH / this.scalingH;
|
||||
final double ratio = stepSize / scalingH;
|
||||
for (int i = 0; i < scaled.length; ++i) {
|
||||
scaled[i] *= ratio;
|
||||
}
|
||||
|
@ -155,7 +156,7 @@ public class NordsieckStepInterpolator extends AbstractStepInterpolator {
|
|||
}
|
||||
}
|
||||
|
||||
this.scalingH = scalingH;
|
||||
scalingH = stepSize;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -246,8 +246,8 @@ public abstract class DirectSearchOptimizer implements MultivariateRealOptimizer
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void setConvergenceChecker(RealConvergenceChecker checker) {
|
||||
this.checker = checker;
|
||||
public void setConvergenceChecker(RealConvergenceChecker convergenceChecker) {
|
||||
this.checker = convergenceChecker;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -256,7 +256,7 @@ public abstract class DirectSearchOptimizer implements MultivariateRealOptimizer
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public RealPointValuePair optimize(final MultivariateRealFunction f,
|
||||
public RealPointValuePair optimize(final MultivariateRealFunction function,
|
||||
final GoalType goalType,
|
||||
final double[] startPoint)
|
||||
throws FunctionEvaluationException, OptimizationException,
|
||||
|
@ -270,7 +270,7 @@ public abstract class DirectSearchOptimizer implements MultivariateRealOptimizer
|
|||
setStartConfiguration(unit);
|
||||
}
|
||||
|
||||
this.f = f;
|
||||
this.f = function;
|
||||
final Comparator<RealPointValuePair> comparator =
|
||||
new Comparator<RealPointValuePair>() {
|
||||
public int compare(final RealPointValuePair o1,
|
||||
|
|
|
@ -79,16 +79,16 @@ public abstract class AbstractLeastSquaresOptimizer implements DifferentiableMul
|
|||
protected int rows;
|
||||
|
||||
/** Objective function. */
|
||||
private DifferentiableMultivariateVectorialFunction f;
|
||||
private DifferentiableMultivariateVectorialFunction function;
|
||||
|
||||
/** Objective function derivatives. */
|
||||
private MultivariateMatrixFunction jF;
|
||||
|
||||
/** Target value for the objective functions at optimum. */
|
||||
protected double[] target;
|
||||
protected double[] targetValues;
|
||||
|
||||
/** Weight for the least squares cost computation. */
|
||||
protected double[] weights;
|
||||
protected double[] residualsWeights;
|
||||
|
||||
/** Current point. */
|
||||
protected double[] point;
|
||||
|
@ -148,8 +148,8 @@ public abstract class AbstractLeastSquaresOptimizer implements DifferentiableMul
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void setConvergenceChecker(VectorialConvergenceChecker checker) {
|
||||
this.checker = checker;
|
||||
public void setConvergenceChecker(VectorialConvergenceChecker convergenceChecker) {
|
||||
this.checker = convergenceChecker;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -182,7 +182,7 @@ public abstract class AbstractLeastSquaresOptimizer implements DifferentiableMul
|
|||
}
|
||||
for (int i = 0; i < rows; i++) {
|
||||
final double[] ji = jacobian[i];
|
||||
final double factor = -Math.sqrt(weights[i]);
|
||||
final double factor = -Math.sqrt(residualsWeights[i]);
|
||||
for (int j = 0; j < cols; ++j) {
|
||||
ji[j] *= factor;
|
||||
}
|
||||
|
@ -202,16 +202,16 @@ public abstract class AbstractLeastSquaresOptimizer implements DifferentiableMul
|
|||
throw new FunctionEvaluationException(new MaxEvaluationsExceededException(maxEvaluations),
|
||||
point);
|
||||
}
|
||||
objective = f.value(point);
|
||||
objective = function.value(point);
|
||||
if (objective.length != rows) {
|
||||
throw new FunctionEvaluationException(point, "dimension mismatch {0} != {1}",
|
||||
objective.length, rows);
|
||||
}
|
||||
cost = 0;
|
||||
for (int i = 0, index = 0; i < rows; i++, index += cols) {
|
||||
final double residual = target[i] - objective[i];
|
||||
final double residual = targetValues[i] - objective[i];
|
||||
residuals[i] = residual;
|
||||
cost += weights[i] * residual * residual;
|
||||
cost += residualsWeights[i] * residual * residual;
|
||||
}
|
||||
cost = Math.sqrt(cost);
|
||||
|
||||
|
@ -231,7 +231,7 @@ public abstract class AbstractLeastSquaresOptimizer implements DifferentiableMul
|
|||
double criterion = 0;
|
||||
for (int i = 0; i < rows; ++i) {
|
||||
final double residual = residuals[i];
|
||||
criterion += weights[i] * residual * residual;
|
||||
criterion += residualsWeights[i] * residual * residual;
|
||||
}
|
||||
return Math.sqrt(criterion / rows);
|
||||
}
|
||||
|
@ -244,7 +244,7 @@ public abstract class AbstractLeastSquaresOptimizer implements DifferentiableMul
|
|||
double chiSquare = 0;
|
||||
for (int i = 0; i < rows; ++i) {
|
||||
final double residual = residuals[i];
|
||||
chiSquare += residual * residual / weights[i];
|
||||
chiSquare += residual * residual / residualsWeights[i];
|
||||
}
|
||||
return chiSquare;
|
||||
}
|
||||
|
@ -329,10 +329,10 @@ public abstract class AbstractLeastSquaresOptimizer implements DifferentiableMul
|
|||
jacobianEvaluations = 0;
|
||||
|
||||
// store least squares problem characteristics
|
||||
this.f = f;
|
||||
function = f;
|
||||
jF = f.jacobian();
|
||||
this.target = target.clone();
|
||||
this.weights = weights.clone();
|
||||
targetValues = target.clone();
|
||||
residualsWeights = weights.clone();
|
||||
this.point = startPoint.clone();
|
||||
this.residuals = new double[target.length];
|
||||
|
||||
|
|
|
@ -61,13 +61,13 @@ public abstract class AbstractScalarDifferentiableOptimizer
|
|||
protected RealConvergenceChecker checker;
|
||||
|
||||
/** Objective function. */
|
||||
private DifferentiableMultivariateRealFunction f;
|
||||
private DifferentiableMultivariateRealFunction function;
|
||||
|
||||
/** Objective function gradient. */
|
||||
private MultivariateVectorialFunction gradient;
|
||||
|
||||
/** Type of optimization. */
|
||||
protected GoalType goalType;
|
||||
protected GoalType goal;
|
||||
|
||||
/** Current point set. */
|
||||
protected double[] point;
|
||||
|
@ -118,8 +118,8 @@ public abstract class AbstractScalarDifferentiableOptimizer
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void setConvergenceChecker(RealConvergenceChecker checker) {
|
||||
this.checker = checker;
|
||||
public void setConvergenceChecker(RealConvergenceChecker convergenceChecker) {
|
||||
this.checker = convergenceChecker;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -140,31 +140,31 @@ public abstract class AbstractScalarDifferentiableOptimizer
|
|||
|
||||
/**
|
||||
* Compute the gradient vector.
|
||||
* @param point point at which the gradient must be evaluated
|
||||
* @param evaluationPoint point at which the gradient must be evaluated
|
||||
* @return gradient at the specified point
|
||||
* @exception FunctionEvaluationException if the function gradient
|
||||
*/
|
||||
protected double[] computeObjectiveGradient(final double[] point)
|
||||
protected double[] computeObjectiveGradient(final double[] evaluationPoint)
|
||||
throws FunctionEvaluationException {
|
||||
++gradientEvaluations;
|
||||
return gradient.value(point);
|
||||
return gradient.value(evaluationPoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the objective function value.
|
||||
* @param point point at which the objective function must be evaluated
|
||||
* @param evaluationPoint point at which the objective function must be evaluated
|
||||
* @return objective function value at specified point
|
||||
* @exception FunctionEvaluationException if the function cannot be evaluated
|
||||
* or its dimension doesn't match problem dimension or the maximal number
|
||||
* of iterations is exceeded
|
||||
*/
|
||||
protected double computeObjectiveValue(final double[] point)
|
||||
protected double computeObjectiveValue(final double[] evaluationPoint)
|
||||
throws FunctionEvaluationException {
|
||||
if (++evaluations > maxEvaluations) {
|
||||
throw new FunctionEvaluationException(new MaxEvaluationsExceededException(maxEvaluations),
|
||||
point);
|
||||
evaluationPoint);
|
||||
}
|
||||
return f.value(point);
|
||||
return function.value(evaluationPoint);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -179,9 +179,9 @@ public abstract class AbstractScalarDifferentiableOptimizer
|
|||
gradientEvaluations = 0;
|
||||
|
||||
// store optimization problem characteristics
|
||||
this.f = f;
|
||||
function = f;
|
||||
gradient = f.gradient();
|
||||
this.goalType = goalType;
|
||||
goal = goalType;
|
||||
point = startPoint.clone();
|
||||
|
||||
return doOptimize();
|
||||
|
|
|
@ -81,8 +81,8 @@ public class GaussNewtonOptimizer extends AbstractLeastSquaresOptimizer {
|
|||
for (int i = 0; i < rows; ++i) {
|
||||
|
||||
final double[] grad = jacobian[i];
|
||||
final double weight = weights[i];
|
||||
final double residual = objective[i] - target[i];
|
||||
final double weight = residualsWeights[i];
|
||||
final double residual = objective[i] - targetValues[i];
|
||||
|
||||
// compute the normal equation
|
||||
final double wr = weight * residual;
|
||||
|
|
|
@ -83,12 +83,12 @@ public class NonLinearConjugateGradientOptimizer
|
|||
|
||||
/**
|
||||
* Set the solver to use during line search.
|
||||
* @param solver solver to use during line search, may be null
|
||||
* @param lineSearchSolver solver to use during line search, may be null
|
||||
* to remove an already registered solver and fall back to the
|
||||
* default {@link BrentSolver Brent solver}.
|
||||
*/
|
||||
public void setLineSearchSolver(final UnivariateRealSolver solver) {
|
||||
this.solver = solver;
|
||||
public void setLineSearchSolver(final UnivariateRealSolver lineSearchSolver) {
|
||||
this.solver = lineSearchSolver;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -124,7 +124,7 @@ public class NonLinearConjugateGradientOptimizer
|
|||
}
|
||||
final int n = point.length;
|
||||
double[] r = computeObjectiveGradient(point);
|
||||
if (goalType == GoalType.MINIMIZE) {
|
||||
if (goal == GoalType.MINIMIZE) {
|
||||
for (int i = 0; i < n; ++i) {
|
||||
r[i] = -r[i];
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ public class NonLinearConjugateGradientOptimizer
|
|||
point[i] += step * searchDirection[i];
|
||||
}
|
||||
r = computeObjectiveGradient(point);
|
||||
if (goalType == GoalType.MINIMIZE) {
|
||||
if (goal == GoalType.MINIMIZE) {
|
||||
for (int i = 0; i < n; ++i) {
|
||||
r[i] = -r[i];
|
||||
}
|
||||
|
|
|
@ -44,16 +44,16 @@ public abstract class AbstractLinearOptimizer implements LinearOptimizer {
|
|||
private int iterations;
|
||||
|
||||
/** Linear objective function. */
|
||||
protected LinearObjectiveFunction f;
|
||||
protected LinearObjectiveFunction function;
|
||||
|
||||
/** Linear constraints. */
|
||||
protected Collection<LinearConstraint> constraints;
|
||||
protected Collection<LinearConstraint> linearConstraints;
|
||||
|
||||
/** Type of optimization goal: either {@link GoalType#MAXIMIZE} or {@link GoalType#MINIMIZE}. */
|
||||
protected GoalType goalType;
|
||||
protected GoalType goal;
|
||||
|
||||
/** Whether to restrict the variables to non-negative values. */
|
||||
protected boolean restrictToNonNegative;
|
||||
protected boolean nonNegative;
|
||||
|
||||
/** Simple constructor with default settings.
|
||||
* <p>The maximal number of evaluation is set to its default value.</p>
|
||||
|
@ -95,10 +95,10 @@ public abstract class AbstractLinearOptimizer implements LinearOptimizer {
|
|||
throws OptimizationException {
|
||||
|
||||
// store linear problem characteristics
|
||||
this.f = f;
|
||||
this.constraints = constraints;
|
||||
this.goalType = goalType;
|
||||
this.restrictToNonNegative = restrictToNonNegative;
|
||||
this.function = f;
|
||||
this.linearConstraints = constraints;
|
||||
this.goal = goalType;
|
||||
this.nonNegative = restrictToNonNegative;
|
||||
|
||||
iterations = 0;
|
||||
|
||||
|
|
|
@ -184,7 +184,7 @@ public class SimplexSolver extends AbstractLinearOptimizer {
|
|||
public RealPointValuePair doOptimize()
|
||||
throws OptimizationException {
|
||||
final SimplexTableau tableau =
|
||||
new SimplexTableau(f, constraints, goalType, restrictToNonNegative, epsilon);
|
||||
new SimplexTableau(function, linearConstraints, goal, nonNegative, epsilon);
|
||||
solvePhase1(tableau);
|
||||
tableau.discardArtificialVariables();
|
||||
while (!isOptimal(tableau)) {
|
||||
|
|
|
@ -192,12 +192,12 @@ class SimplexTableau implements Serializable {
|
|||
|
||||
/**
|
||||
* Get new versions of the constraints which have positive right hand sides.
|
||||
* @param constraints original (not normalized) constraints
|
||||
* @param originalConstraints original (not normalized) constraints
|
||||
* @return new versions of the constraints
|
||||
*/
|
||||
public List<LinearConstraint> normalizeConstraints(Collection<LinearConstraint> constraints) {
|
||||
public List<LinearConstraint> normalizeConstraints(Collection<LinearConstraint> originalConstraints) {
|
||||
List<LinearConstraint> normalized = new ArrayList<LinearConstraint>();
|
||||
for (LinearConstraint constraint : constraints) {
|
||||
for (LinearConstraint constraint : originalConstraints) {
|
||||
normalized.add(normalize(constraint));
|
||||
}
|
||||
return normalized;
|
||||
|
|
|
@ -183,8 +183,7 @@ public class RandomDataImpl implements RandomData, Serializable {
|
|||
"upper bound ({0}) must be greater than lower bound ({1})",
|
||||
upper, lower);
|
||||
}
|
||||
RandomGenerator rand = getRan();
|
||||
double r = rand.nextDouble();
|
||||
double r = getRan().nextDouble();
|
||||
return (int) ((r * upper) + ((1.0 - r) * lower) + r);
|
||||
}
|
||||
|
||||
|
@ -204,8 +203,7 @@ public class RandomDataImpl implements RandomData, Serializable {
|
|||
"upper bound ({0}) must be greater than lower bound ({1})",
|
||||
upper, lower);
|
||||
}
|
||||
RandomGenerator rand = getRan();
|
||||
double r = rand.nextDouble();
|
||||
double r = getRan().nextDouble();
|
||||
return (long) ((r * upper) + ((1.0 - r) * lower) + r);
|
||||
}
|
||||
|
||||
|
@ -356,7 +354,7 @@ public class RandomDataImpl implements RandomData, Serializable {
|
|||
"the Poisson mean must be positive ({0})", mean);
|
||||
}
|
||||
|
||||
RandomGenerator rand = getRan();
|
||||
final RandomGenerator generator = getRan();
|
||||
|
||||
double pivot = 6.0;
|
||||
if (mean < pivot) {
|
||||
|
@ -366,7 +364,7 @@ public class RandomDataImpl implements RandomData, Serializable {
|
|||
double rnd = 1.0d;
|
||||
|
||||
while (n < 1000 * mean) {
|
||||
rnd = rand.nextDouble();
|
||||
rnd = generator.nextDouble();
|
||||
r = r * rnd;
|
||||
if (r >= p) {
|
||||
n++;
|
||||
|
@ -458,8 +456,7 @@ public class RandomDataImpl implements RandomData, Serializable {
|
|||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"standard deviation must be positive ({0})", sigma);
|
||||
}
|
||||
RandomGenerator rand = getRan();
|
||||
return sigma * rand.nextGaussian() + mu;
|
||||
return sigma * getRan().nextGaussian() + mu;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -481,10 +478,10 @@ public class RandomDataImpl implements RandomData, Serializable {
|
|||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"mean must be positive ({0})", mean);
|
||||
}
|
||||
RandomGenerator rand = getRan();
|
||||
double unif = rand.nextDouble();
|
||||
final RandomGenerator generator = getRan();
|
||||
double unif = generator.nextDouble();
|
||||
while (unif == 0.0d) {
|
||||
unif = rand.nextDouble();
|
||||
unif = generator.nextDouble();
|
||||
}
|
||||
return -mean * Math.log(unif);
|
||||
}
|
||||
|
@ -511,12 +508,12 @@ public class RandomDataImpl implements RandomData, Serializable {
|
|||
"upper bound ({0}) must be greater than lower bound ({1})",
|
||||
upper, lower);
|
||||
}
|
||||
RandomGenerator rand = getRan();
|
||||
final RandomGenerator generator = getRan();
|
||||
|
||||
// ensure nextDouble() isn't 0.0
|
||||
double u = rand.nextDouble();
|
||||
double u = generator.nextDouble();
|
||||
while (u <= 0.0) {
|
||||
u = rand.nextDouble();
|
||||
u = generator.nextDouble();
|
||||
}
|
||||
|
||||
return lower + u * (upper - lower);
|
||||
|
|
|
@ -124,11 +124,11 @@ public class SpearmansCorrelation {
|
|||
* input rectangular array. The columns of the array represent values
|
||||
* of variables to be correlated.
|
||||
*
|
||||
* @param data matrix with columns representing variables to correlate
|
||||
* @param matrix matrix with columns representing variables to correlate
|
||||
* @return correlation matrix
|
||||
*/
|
||||
public RealMatrix computeCorrelationMatrix(double[][] data) {
|
||||
return computeCorrelationMatrix(new BlockRealMatrix(data));
|
||||
public RealMatrix computeCorrelationMatrix(double[][] matrix) {
|
||||
return computeCorrelationMatrix(new BlockRealMatrix(matrix));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -481,10 +481,10 @@ public class Variance extends AbstractStorelessUnivariateStatistic implements Se
|
|||
}
|
||||
|
||||
/**
|
||||
* @param isBiasCorrected The isBiasCorrected to set.
|
||||
* @param biasCorrected The isBiasCorrected to set.
|
||||
*/
|
||||
public void setBiasCorrected(boolean isBiasCorrected) {
|
||||
this.isBiasCorrected = isBiasCorrected;
|
||||
public void setBiasCorrected(boolean biasCorrected) {
|
||||
this.isBiasCorrected = biasCorrected;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -53,11 +53,11 @@ public class TestUtils {
|
|||
/**
|
||||
* Set the (singleton) TTest instance.
|
||||
*
|
||||
* @param tTest the new instance to use
|
||||
* @param chiSquareTest the new instance to use
|
||||
* @since 1.2
|
||||
*/
|
||||
public static void setChiSquareTest(TTest tTest) {
|
||||
TestUtils.tTest = tTest;
|
||||
public static void setChiSquareTest(TTest chiSquareTest) {
|
||||
TestUtils.tTest = chiSquareTest;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -337,35 +337,33 @@ public class ResizableDoubleArray implements DoubleArray, Serializable {
|
|||
* IllegalArgumentException if the contractionCriteria is less than the
|
||||
* expansionCriteria
|
||||
*
|
||||
* @param expansionFactor factor to be checked
|
||||
* @param contractionCriteria criteria to be checked
|
||||
* @param expansion factor to be checked
|
||||
* @param contraction criteria to be checked
|
||||
* @throws IllegalArgumentException if the contractionCriteria is less than
|
||||
* the expansionCriteria.
|
||||
*/
|
||||
protected void checkContractExpand(
|
||||
float contractionCriteria,
|
||||
float expansionFactor) {
|
||||
protected void checkContractExpand(float contraction, float expansion) {
|
||||
|
||||
if (contractionCriteria < expansionFactor) {
|
||||
if (contraction < expansion) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"contraction criteria ({0}) smaller than the expansion factor ({1}). This would " +
|
||||
"lead to a never ending loop of expansion and contraction as a newly expanded " +
|
||||
"internal storage array would immediately satisfy the criteria for contraction",
|
||||
contractionCriteria, expansionFactor);
|
||||
contraction, expansion);
|
||||
}
|
||||
|
||||
if (contractionCriteria <= 1.0) {
|
||||
if (contraction <= 1.0) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"contraction criteria smaller than one ({0}). This would lead to a never ending " +
|
||||
"loop of expansion and contraction as an internal storage array length equal " +
|
||||
"to the number of elements would satisfy the contraction criteria.",
|
||||
contractionCriteria);
|
||||
contraction);
|
||||
}
|
||||
|
||||
if (expansionFactor <= 1.0) {
|
||||
if (expansion <= 1.0) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"expansion factor smaller than one ({0})",
|
||||
expansionFactor);
|
||||
expansion);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@ public class DummyBinaryChromosome extends BinaryChromosome {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractListChromosome<Integer> newFixedLengthChromosome(List<Integer> representation) {
|
||||
return new DummyBinaryChromosome(representation);
|
||||
public AbstractListChromosome<Integer> newFixedLengthChromosome(List<Integer> chromosomeRepresentation) {
|
||||
return new DummyBinaryChromosome(chromosomeRepresentation);
|
||||
}
|
||||
|
||||
public double fitness() {
|
||||
|
|
|
@ -32,8 +32,8 @@ public class DummyRandomKey extends RandomKey<String> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractListChromosome<Double> newFixedLengthChromosome(List<Double> representation) {
|
||||
return new DummyRandomKey(representation);
|
||||
public AbstractListChromosome<Double> newFixedLengthChromosome(List<Double> chromosomeRepresentation) {
|
||||
return new DummyRandomKey(chromosomeRepresentation);
|
||||
}
|
||||
|
||||
public double fitness() {
|
||||
|
|
|
@ -113,8 +113,8 @@ public class GeneticAlgorithmTestBinary {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractListChromosome<Integer> newFixedLengthChromosome(List<Integer> representation) {
|
||||
return new FindOnes(representation);
|
||||
public AbstractListChromosome<Integer> newFixedLengthChromosome(List<Integer> chromosomeRepresentation) {
|
||||
return new FindOnes(chromosomeRepresentation);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -124,8 +124,8 @@ public class GeneticAlgorithmTestPermutations {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractListChromosome<Double> newFixedLengthChromosome(List<Double> representation) {
|
||||
return new MinPermutations(representation);
|
||||
public AbstractListChromosome<Double> newFixedLengthChromosome(List<Double> chromosomeRepresentation) {
|
||||
return new MinPermutations(chromosomeRepresentation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue