Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ public MultivariateFunctionMappingAdapter(final MultivariateFunction bounded,
if (!(upper[i] >= lower[i])) {
throw new NumberIsTooSmallException(upper[i], lower[i], true);
}
if (upper[i] == lower[i] && !Double.isInfinite(lower[i])) {
throw new NumberIsTooSmallException(upper[i], lower[i], false);
}
}

this.bounded = bounded;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.commons.math4.legacy.optim.nonlinear.scalar;

import org.apache.commons.math4.legacy.analysis.MultivariateFunction;
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
import org.apache.commons.math4.legacy.optim.InitialGuess;
import org.apache.commons.math4.legacy.optim.MaxEval;
import org.apache.commons.math4.legacy.optim.PointValuePair;
Expand All @@ -27,6 +28,28 @@
import org.junit.Test;

public class MultivariateFunctionMappingAdapterTest {
@Test(expected = NumberIsTooSmallException.class)
public void testEqualBoundsRejected() {
new MultivariateFunctionMappingAdapter(point -> 0.0,
new double[] { 2.0 },
new double[] { 2.0 });
}

@Test
public void testEqualInfiniteBoundsRemainUnbounded() {
final MultivariateFunctionMappingAdapter negative =
new MultivariateFunctionMappingAdapter(point -> point[0],
new double[] { Double.NEGATIVE_INFINITY },
new double[] { Double.NEGATIVE_INFINITY });
final MultivariateFunctionMappingAdapter positive =
new MultivariateFunctionMappingAdapter(point -> point[0],
new double[] { Double.POSITIVE_INFINITY },
new double[] { Double.POSITIVE_INFINITY });

Assert.assertEquals(3.0, negative.value(new double[] { 3.0 }), 0.0);
Assert.assertEquals(3.0, positive.value(new double[] { 3.0 }), 0.0);
}

@Test
public void testStartSimplexInsideRange() {
final BiQuadratic biQuadratic = new BiQuadratic(2.0, 2.5, 1.0, 3.0, 2.0, 3.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public void testStandardTransformReal() {
doTestTransformReal(8, 1e-13, 2 * EPSILON, norm[i], type);
doTestTransformReal(16, 1e-13, 2 * EPSILON, norm[i], type);
doTestTransformReal(32, 1e-12, 4 * EPSILON, norm[i], type);
doTestTransformReal(64, 1e-12, 4 * EPSILON, norm[i], type);
doTestTransformReal(64, 1e-12, 8 * EPSILON, norm[i], type);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not related to this PR. Please revert.

doTestTransformReal(128, 1e-11, 8 * EPSILON, norm[i], type);
}
}
Expand Down