mirror of
https://github.com/apache/commons-math.git
synced 2025-02-17 15:35:20 +00:00
Code simplifications (suggested by "sonarcloud").
This commit is contained in:
parent
df895da9be
commit
8f83827846
@ -123,27 +123,14 @@ public class SimplexOptimizer extends MultivariateOptimizer {
|
|||||||
|
|
||||||
// Indirect call to "computeObjectiveValue" in order to update the
|
// Indirect call to "computeObjectiveValue" in order to update the
|
||||||
// evaluations counter.
|
// evaluations counter.
|
||||||
final MultivariateFunction evalFunc
|
final MultivariateFunction evalFunc = (p) -> computeObjectiveValue(p);
|
||||||
= new MultivariateFunction() {
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public double value(double[] point) {
|
|
||||||
return computeObjectiveValue(point);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
final boolean isMinim = getGoalType() == GoalType.MINIMIZE;
|
final boolean isMinim = getGoalType() == GoalType.MINIMIZE;
|
||||||
final Comparator<PointValuePair> comparator
|
final Comparator<PointValuePair> comparator = (o1, o2) -> {
|
||||||
= new Comparator<PointValuePair>() {
|
final double v1 = o1.getValue();
|
||||||
/** {@inheritDoc} */
|
final double v2 = o2.getValue();
|
||||||
@Override
|
return isMinim ? Double.compare(v1, v2) : Double.compare(v2, v1);
|
||||||
public int compare(final PointValuePair o1,
|
};
|
||||||
final PointValuePair o2) {
|
|
||||||
final double v1 = o1.getValue();
|
|
||||||
final double v2 = o2.getValue();
|
|
||||||
return isMinim ? Double.compare(v1, v2) : Double.compare(v2, v1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
final UnaryOperator<Simplex> update = updateRule.apply(evalFunc, comparator);
|
final UnaryOperator<Simplex> update = updateRule.apply(evalFunc, comparator);
|
||||||
|
|
||||||
@ -202,12 +189,8 @@ public class SimplexOptimizer extends MultivariateOptimizer {
|
|||||||
for (OptimizationData data : optData) {
|
for (OptimizationData data : optData) {
|
||||||
if (data instanceof Simplex) {
|
if (data instanceof Simplex) {
|
||||||
simplex = (Simplex) data;
|
simplex = (Simplex) data;
|
||||||
continue;
|
} else if (data instanceof Simplex.TransformFactory) {
|
||||||
}
|
|
||||||
|
|
||||||
if (data instanceof Simplex.TransformFactory) {
|
|
||||||
updateRule = (Simplex.TransformFactory) data;
|
updateRule = (Simplex.TransformFactory) data;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user