Commit 36dc4faf authored by Grand Francois's avatar Grand Francois
Browse files

dichotomie : ajout du nombre maxi d'iterations pour la recherche dichotomique

Showing with 19 additions and 0 deletions
+19 -0
......@@ -118,6 +118,13 @@ export class Dichotomie extends Debug {
*/
private _startIntervalMaxSteps = 100;
/**
* nombre d'itérations maxi pour la recherche dichotomique
*/
private _maxIterations: number = 100;
private _currentIterations: number;
/**
* nom du paramètre calculé analytiquement par Equation()
*/
......@@ -139,6 +146,10 @@ export class Dichotomie extends Debug {
}
}
public set maxIterations(n: number) {
this._maxIterations = Math.max(n, 1);
}
/**
* Valeur inconnue à rechercher
*/
......@@ -188,6 +199,7 @@ export class Dichotomie extends Debug {
const r = this.getStartInterval(rTarget, rInit);
if (r.ok) {
const interv: SearchInterval = r.intSearch;
this._currentIterations = 0;
// Dichotomie
return this.dichoSearch(rTarget, rTol, interv.min, interv.max, interv.targetLower, interv.targetUpper);
} else {
......@@ -371,6 +383,13 @@ export class Dichotomie extends Debug {
*/
// tslint:disable-next-line:variable-name
private dichoSearch(Ytarg: number, rTol: number, Xmin: number, Xmax: number, Ymin: number, Ymax: number): Result {
this._currentIterations++;
if (this._currentIterations > this._maxIterations) {
const r = new Result();
r.globalLog.add(new Message(MessageCode.ERROR_DICHO_CONVERGE));
return r;
}
this.debug("dichoSearch : yTarget " + Ytarg + " X " + Xmin + "->" + Xmax + " tol " + rTol);
// tslint:disable-next-line:variable-name
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment