use of org.apache.commons.math3.optim.OptimizationData in project GDSC-SMLM by aherbert.
the class CustomPowellOptimizer method parseOptimizationData.
/**
* Scans the list of (required and optional) optimization data that
* characterize the problem.
*
* @param optData
* Optimization data.
* The following data will be looked for:
* <ul>
* <li>{@link PositionChecker}</li>
* <li>{@link BasisStep}</li>
* </ul>
*/
@Override
protected void parseOptimizationData(OptimizationData... optData) {
// Allow base class to register its own data.
super.parseOptimizationData(optData);
// not provided in the argument list.
for (OptimizationData data : optData) {
if (data instanceof PositionChecker) {
positionChecker = (PositionChecker) data;
continue;
}
if (data instanceof BasisStep) {
basis = ((BasisStep) data).getStep();
continue;
}
}
checkParameters();
}
use of org.apache.commons.math3.optim.OptimizationData in project GDSC-SMLM by aherbert.
the class BFGSOptimizer method parseOptimizationData.
/**
* Scans the list of (required and optional) optimization data that
* characterize the problem.
*
* @param optData
* Optimization data.
* The following data will be looked for:
* <ul>
* <li>{@link GradientChecker}</li>
* <li>{@link PositionChecker}</li>
* <li>{@link MaximumStepLength}</li>
* </ul>
*/
@Override
protected void parseOptimizationData(OptimizationData... optData) {
// Allow base class to register its own data.
super.parseOptimizationData(optData);
// not provided in the argument list.
for (OptimizationData data : optData) {
if (data instanceof PositionChecker) {
positionChecker = (PositionChecker) data;
} else if (data instanceof StepLength) {
maximumStepLength = ((StepLength) data).getStep();
} else if (data instanceof GradientTolerance) {
gradientTolerance = ((GradientTolerance) data).getTolerance();
} else if (data instanceof MaximumRestarts) {
restarts = ((MaximumRestarts) data).getRestarts();
} else if (data instanceof MaximumRoundoffRestarts) {
roundoffRestarts = ((MaximumRoundoffRestarts) data).getRestarts();
}
}
checkParameters();
}
use of org.apache.commons.math3.optim.OptimizationData in project GDSC-SMLM by aherbert.
the class BFGSOptimizer method checkParameters.
/**
* Checks if there are lower or upper bounds that are not -Infinity or +Infinity
*
* @throws MathUnsupportedOperationException
* if invalid bounds were passed to the {@link #optimize(OptimizationData[]) optimize} method.
*/
private void checkParameters() {
lower = getLowerBound();
upper = getUpperBound();
isLower = checkArray(lower, Double.NEGATIVE_INFINITY);
isUpper = checkArray(upper, Double.POSITIVE_INFINITY);
// Check that the upper bound is above the lower bound
if (isUpper && isLower) {
for (int i = 0; i < lower.length; i++) if (lower[i] > upper[i])
throw new MathUnsupportedOperationException(createError("Lower bound must be below upper bound"));
}
// Numerical Recipes set the position convergence very low
if (positionChecker == null)
positionChecker = new PositionChecker(4 * epsilon, 0);
// Ensure that the step length is strictly positive
if (maximumStepLength == null) {
for (int i = 0; i < maximumStepLength.length; i++) {
if (maximumStepLength[i] <= 0)
throw new MathUnsupportedOperationException(createError("Maximum step length must be strictly positive"));
}
}
// Set a tolerance? If not then the routine will iterate until position convergence
//if (gradientTolerance == 0)
// gradientTolerance = 1e-6;
}
use of org.apache.commons.math3.optim.OptimizationData in project GDSC-SMLM by aherbert.
the class BoundedNonLinearConjugateGradientOptimizer method parseOptimizationData.
/**
* Scans the list of (required and optional) optimization data that
* characterize the problem.
*
* @param optData
* Optimization data.
* The following data will be looked for:
* <ul>
* <li>{@link BracketingStep}</li>
* </ul>
*/
@Override
protected void parseOptimizationData(OptimizationData... optData) {
// Allow base class to register its own data.
super.parseOptimizationData(optData);
// not provided in the argument list.
for (OptimizationData data : optData) {
if (data instanceof BracketingStep) {
initialStep = ((BracketingStep) data).getBracketingStep();
// changed to "continue".
break;
}
}
checkParameters();
}
Aggregations