signaflo / java-timeseries

Time series analysis in Java
MIT License
195 stars 49 forks source link

Loop in BFGS.java#127 can fall into infinite loop. #4

Open Ajk4 opened 6 years ago

Ajk4 commented 6 years ago

See discussion in PR https://github.com/signaflo/java-timeseries/pull/3

Code

while (!(Double.isFinite(functionValue) &&
                           functionValue < priorFunctionValue + C1 * stepSize * slopeAt0) && !stop) {

can fall into infinite loop.

signaflo commented 6 years ago

Release 0.4 includes the simplest solution of using a counter to keep track of the number of iterations and exiting the loop when the maximum is reached. It is far preferable to understand why the algorithm is falling into this state and taking steps to prevent that.