-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmath_50.diff
52 lines (49 loc) · 3.42 KB
/
math_50.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
diff --git a/src/main/java/org/apache/commons/math/analysis/solvers/BaseSecantSolver.java b/src/main/java/org/apache/commons/math/analysis/solvers/BaseSecantSolver.java
index e47d98204..223dbc00d 100644
--- a/src/main/java/org/apache/commons/math/analysis/solvers/BaseSecantSolver.java
+++ b/src/main/java/org/apache/commons/math/analysis/solvers/BaseSecantSolver.java
@@ -56,7 +56,7 @@ public abstract class BaseSecantSolver
private AllowedSolution allowed;
/** The <em>Secant</em>-based root-finding method to use. */
- private final Method method;
+ private Method method; // defects4j.instrumentation
/**
* Construct a solver.
@@ -111,8 +111,36 @@ public abstract class BaseSecantSolver
/** {@inheritDoc} */
public double solve(final int maxEval, final UnivariateRealFunction f,
- final double min, final double max, final double startValue,
- final AllowedSolution allowedSolution) {
+ final double min, final double max, final double startValue, // defects4j.instrumentation
+ final AllowedSolution allowedSolution) { // defects4j.instrumentation
+ if (Boolean.parseBoolean(System.getProperty("defects4j.instrumentation.enabled"))) { // defects4j.instrumentation
+ if (method.equals(Method.REGULA_FALSI)) { // defects4j.instrumentation
+ try { // defects4j.instrumentation
+ return solve_original(maxEval, f, min, max, startValue, allowedSolution); // defects4j.instrumentation
+ } catch (org.apache.commons.math.exception.TooManyEvaluationsException e1) { // defects4j.instrumentation
+ boolean pegasusDidNotFail = true; // defects4j.instrumentation
+ method = Method.PEGASUS; // defects4j.instrumentation
+ try { // defects4j.instrumentation
+ solve_original(maxEval, f, min, max, startValue, allowedSolution); // defects4j.instrumentation
+ } catch (org.apache.commons.math.exception.TooManyEvaluationsException e2) { // defects4j.instrumentation
+ pegasusDidNotFail = false; // defects4j.instrumentation
+ } // defects4j.instrumentation
+ if (pegasusDidNotFail) { // defects4j.instrumentation
+ throw new RuntimeException("[Defects4J_BugReport_Violation]"); // defects4j.instrumentation
+ } else { // defects4j.instrumentation
+ throw e1; // defects4j.instrumentation
+ } // defects4j.instrumentation
+ } // defects4j.instrumentation
+ } else { // defects4j.instrumentation
+ return solve_original(maxEval, f, min, max, startValue, allowedSolution); // defects4j.instrumentation
+ } // defects4j.instrumentation
+ } else { // defects4j.instrumentation
+ return solve_original(maxEval, f, min, max, startValue, allowedSolution); // defects4j.instrumentation
+ } // defects4j.instrumentation
+ } // defects4j.instrumentation
+
+ public double solve_original(final int maxEval, final UnivariateRealFunction f, final double min, final double max, // defects4j.instrumentation
+ final double startValue, final AllowedSolution allowedSolution) { // defects4j.instrumentation
this.allowed = allowedSolution;
return super.solve(maxEval, f, min, max, startValue);
}