Skip to content

Commit

Permalink
fixed files form Math #23
Browse files Browse the repository at this point in the history
  • Loading branch information
tdurieux committed Mar 7, 2017
1 parent e0ba336 commit 87d3022
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ protected UnivariatePointValuePair doOptimize() {
UnivariatePointValuePair current
= new UnivariatePointValuePair(x, isMinim ? fx : -fx);
// Best point encountered so far (which is the initial guess).
UnivariatePointValuePair best = current;

int iter = 0;
while (true) {
Expand Down Expand Up @@ -231,10 +232,15 @@ protected UnivariatePointValuePair doOptimize() {
// User-defined convergence checker.
previous = current;
current = new UnivariatePointValuePair(u, isMinim ? fu : -fu);
best = best(best,
best(current,
previous,
isMinim),
isMinim);

if (checker != null) {
if (checker.converged(iter, previous, current)) {
return best(current, previous, isMinim);
return best;
}
}

Expand Down Expand Up @@ -271,9 +277,10 @@ protected UnivariatePointValuePair doOptimize() {
}
}
} else { // Default termination (Brent's criterion).
return
return best(best,
best(current,
previous,
isMinim),
isMinim);
}
++iter;
Expand Down

0 comments on commit 87d3022

Please sign in to comment.