Commit 317d623f authored by Andrey Filippov's avatar Andrey Filippov

fixing stopRequested interceipt

parent d9ef3617
...@@ -4435,6 +4435,10 @@ public boolean LevenbergMarquardt( ...@@ -4435,6 +4435,10 @@ public boolean LevenbergMarquardt(
// while (this.fittingStrategy.isSeriesValid(this.seriesNumber)){ // TODO: Add "stop" tag to series // while (this.fittingStrategy.isSeriesValid(this.seriesNumber)){ // TODO: Add "stop" tag to series
this.currentVector=null; // invalidate for the new series this.currentVector=null; // invalidate for the new series
// boolean wasLastSeries=false; // boolean wasLastSeries=false;
int saveStopRequested=this.stopRequested.get(); // preserve from caller stop requested (like temp. scan)
this.stopRequested.set(0); // remove caller stop request
while (true) { // loop for the same series while (true) { // loop for the same series
boolean [] state=stepLevenbergMarquardtFirst(debugLevel); boolean [] state=stepLevenbergMarquardtFirst(debugLevel);
...@@ -4444,6 +4448,7 @@ public boolean LevenbergMarquardt( ...@@ -4444,6 +4448,7 @@ public boolean LevenbergMarquardt(
System.out.println(msg); System.out.println(msg);
commitParameterVector(this.savedVector); commitParameterVector(this.savedVector);
this.lambda=savedLambda; this.lambda=savedLambda;
this.stopRequested.set(saveStopRequested); // restore caller stop request
return false; return false;
} }
...@@ -4461,6 +4466,7 @@ public boolean LevenbergMarquardt( ...@@ -4461,6 +4466,7 @@ public boolean LevenbergMarquardt(
(this.stopEachSeries && state[1]) || (this.stopEachSeries && state[1]) ||
(this.stopOnFailure && state[1] && !state[0])){ (this.stopOnFailure && state[1] && !state[0])){
if (state[1] && !state[0] && !calibrate){ if (state[1] && !state[0] && !calibrate){
this.stopRequested.set(saveStopRequested); // restore caller stop request
return false; return false;
} }
...@@ -4499,6 +4505,7 @@ public boolean LevenbergMarquardt( ...@@ -4499,6 +4505,7 @@ public boolean LevenbergMarquardt(
// if RMS was decreased. this.saveSeries==false after dialogLMAStep(state) only if "cancel" was pressed // if RMS was decreased. this.saveSeries==false after dialogLMAStep(state) only if "cancel" was pressed
commitParameterVector(this.savedVector); // either new or original commitParameterVector(this.savedVector); // either new or original
this.lambda=savedLambda; this.lambda=savedLambda;
this.stopRequested.set(saveStopRequested); // restore caller stop request
return this.saveSeries; // TODO: Maybe change result? return this.saveSeries; // TODO: Maybe change result?
} }
//stepLevenbergMarquardtAction(); //stepLevenbergMarquardtAction();
...@@ -4506,6 +4513,7 @@ public boolean LevenbergMarquardt( ...@@ -4506,6 +4513,7 @@ public boolean LevenbergMarquardt(
if (!state[0]) { if (!state[0]) {
commitParameterVector(this.savedVector); commitParameterVector(this.savedVector);
this.lambda=savedLambda; this.lambda=savedLambda;
this.stopRequested.set(saveStopRequested); // restore caller stop request
return false; // sequence failed return false; // sequence failed
} }
this.savedVector=this.currentVector.clone(); this.savedVector=this.currentVector.clone();
...@@ -4516,6 +4524,7 @@ public boolean LevenbergMarquardt( ...@@ -4516,6 +4524,7 @@ public boolean LevenbergMarquardt(
// this.seriesNumber++; // this.seriesNumber++;
break; // while (true), proceed to the next series break; // while (true), proceed to the next series
} }
this.stopRequested.set(saveStopRequested); // restore caller stop request
} // while true - same series } // while true - same series
// if (wasLastSeries) break; // if (wasLastSeries) break;
// } // while (this.fittingStrategy.isSeriesValid(this.seriesNumber)){ // TODO: Add "stop" tag to series // } // while (this.fittingStrategy.isSeriesValid(this.seriesNumber)){ // TODO: Add "stop" tag to series
...@@ -9565,6 +9574,8 @@ f_corr: d_fcorr/d_zcorr=0, other: a, reff, kx -> ar[1], ar[2], ar[3], ar[4] ...@@ -9565,6 +9574,8 @@ f_corr: d_fcorr/d_zcorr=0, other: a, reff, kx -> ar[1], ar[2], ar[3], ar[4]
qCompareDrDerivatives(this.qSavedVector); qCompareDrDerivatives(this.qSavedVector);
} }
this.qCurrentVector=null; // invalidate for the new series this.qCurrentVector=null; // invalidate for the new series
int saveStopRequested=stopRequested.get(); // preserve from caller stop requested (like temp. scan)
stopRequested.set(0); // remove caller stop request
while (true) { // loop for the same series while (true) { // loop for the same series
boolean [] state=stepQLevenbergMarquardtFirst(debugLevel); boolean [] state=stepQLevenbergMarquardtFirst(debugLevel);
if (state==null) { if (state==null) {
...@@ -9574,6 +9585,7 @@ f_corr: d_fcorr/d_zcorr=0, other: a, reff, kx -> ar[1], ar[2], ar[3], ar[4] ...@@ -9574,6 +9585,7 @@ f_corr: d_fcorr/d_zcorr=0, other: a, reff, kx -> ar[1], ar[2], ar[3], ar[4]
restoreQPars(); restoreQPars();
// commitParameterVector(this.savedVector); // commitParameterVector(this.savedVector);
this.qLambda=savedLambda; this.qLambda=savedLambda;
stopRequested.set(saveStopRequested); // restore caller stop request
return false; return false;
} }
...@@ -9623,6 +9635,7 @@ f_corr: d_fcorr/d_zcorr=0, other: a, reff, kx -> ar[1], ar[2], ar[3], ar[4] ...@@ -9623,6 +9635,7 @@ f_corr: d_fcorr/d_zcorr=0, other: a, reff, kx -> ar[1], ar[2], ar[3], ar[4]
// commitParameterVector(this.savedVector); // either new or original // commitParameterVector(this.savedVector); // either new or original
commitQPars(this.qSavedVector); commitQPars(this.qSavedVector);
this.qLambda=savedLambda; this.qLambda=savedLambda;
stopRequested.set(saveStopRequested); // restore caller stop request
return this.qSaveSeries; // TODO: Maybe change result? return this.qSaveSeries; // TODO: Maybe change result?
} }
//stepLevenbergMarquardtAction(); //stepLevenbergMarquardtAction();
...@@ -9631,6 +9644,7 @@ f_corr: d_fcorr/d_zcorr=0, other: a, reff, kx -> ar[1], ar[2], ar[3], ar[4] ...@@ -9631,6 +9644,7 @@ f_corr: d_fcorr/d_zcorr=0, other: a, reff, kx -> ar[1], ar[2], ar[3], ar[4]
// commitParameterVector(this.savedVector); // commitParameterVector(this.savedVector);
commitQPars(this.qSavedVector); commitQPars(this.qSavedVector);
this.qLambda=savedLambda; this.qLambda=savedLambda;
stopRequested.set(saveStopRequested); // restore caller stop request
return false; // sequence failed return false; // sequence failed
} }
// this.savedVector=this.currentVector.clone(); // this.savedVector=this.currentVector.clone();
...@@ -9653,6 +9667,7 @@ f_corr: d_fcorr/d_zcorr=0, other: a, reff, kx -> ar[1], ar[2], ar[3], ar[4] ...@@ -9653,6 +9667,7 @@ f_corr: d_fcorr/d_zcorr=0, other: a, reff, kx -> ar[1], ar[2], ar[3], ar[4]
// commitParameterVector(this.savedVector); // commitParameterVector(this.savedVector);
saveQPars(); saveQPars();
commitQPars(this.qSavedVector); commitQPars(this.qSavedVector);
stopRequested.set(saveStopRequested); // restore caller stop request
return true; // all series done return true; // all series done
} }
public void qCompareDrDerivatives(double [] vector){ public void qCompareDrDerivatives(double [] vector){
......
Markdown is supported
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