Skip to content
Snippets Groups Projects
Commit 1c86873e authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

enclosed calls to alglib in try/catch

parent 8402ecd8
No related branches found
No related tags found
No related merge requests found
...@@ -265,6 +265,7 @@ void OptHOM::OptimPass(alglib::real_1d_array &x, ...@@ -265,6 +265,7 @@ void OptHOM::OptimPass(alglib::real_1d_array &x,
if (OPTMETHOD == 1) { if (OPTMETHOD == 1) {
alglib::mincgstate state; alglib::mincgstate state;
alglib::mincgreport rep; alglib::mincgreport rep;
try{
mincgcreate(x, state); mincgcreate(x, state);
mincgsetscale(state,scale); mincgsetscale(state,scale);
mincgsetprecscale(state); mincgsetprecscale(state);
...@@ -272,6 +273,10 @@ void OptHOM::OptimPass(alglib::real_1d_array &x, ...@@ -272,6 +273,10 @@ void OptHOM::OptimPass(alglib::real_1d_array &x,
mincgsetxrep(state, true); mincgsetxrep(state, true);
alglib::mincgoptimize(state, evalObjGradFunc, printProgressFunc, this); alglib::mincgoptimize(state, evalObjGradFunc, printProgressFunc, this);
mincgresults(state, x, rep); mincgresults(state, x, rep);
}
catch(alglib::ap_error e){
Msg::Error("%s", e.msg.c_str());
}
iterationscount = rep.iterationscount; iterationscount = rep.iterationscount;
nfev = rep.nfev; nfev = rep.nfev;
terminationtype = rep.terminationtype; terminationtype = rep.terminationtype;
...@@ -279,6 +284,7 @@ void OptHOM::OptimPass(alglib::real_1d_array &x, ...@@ -279,6 +284,7 @@ void OptHOM::OptimPass(alglib::real_1d_array &x,
else { else {
alglib::minlbfgsstate state; alglib::minlbfgsstate state;
alglib::minlbfgsreport rep; alglib::minlbfgsreport rep;
try{
minlbfgscreate(3, x, state); minlbfgscreate(3, x, state);
minlbfgssetscale(state,scale); minlbfgssetscale(state,scale);
minlbfgssetprecscale(state); minlbfgssetprecscale(state);
...@@ -286,6 +292,10 @@ void OptHOM::OptimPass(alglib::real_1d_array &x, ...@@ -286,6 +292,10 @@ void OptHOM::OptimPass(alglib::real_1d_array &x,
minlbfgssetxrep(state, true); minlbfgssetxrep(state, true);
alglib::minlbfgsoptimize(state, evalObjGradFunc, printProgressFunc, this); alglib::minlbfgsoptimize(state, evalObjGradFunc, printProgressFunc, this);
minlbfgsresults(state, x, rep); minlbfgsresults(state, x, rep);
}
catch(alglib::ap_error e){
Msg::Error("%s", e.msg.c_str());
}
iterationscount = rep.iterationscount; iterationscount = rep.iterationscount;
nfev = rep.nfev; nfev = rep.nfev;
terminationtype = rep.terminationtype; terminationtype = rep.terminationtype;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment