Skip to content

Commit

Permalink
Merge pull request #3238 from stan-dev/fix/optimize-log-error
Browse files Browse the repository at this point in the history
Log optimization errors on error channel
  • Loading branch information
WardBrian authored Nov 6, 2023
2 parents 07e86a8 + 5c4eb96 commit a6af397
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/stan/services/optimize/bfgs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,16 @@ int bfgs(Model& model, const stan::io::var_context& init,
}

int return_code;
auto error_string = bfgs.get_code_string(ret);
if (ret >= 0) {
logger.info("Optimization terminated normally: ");
logger.info(" " + error_string);
return_code = error_codes::OK;
} else {
logger.error("Optimization terminated with error: ");
logger.error(" " + error_string);
return_code = error_codes::SOFTWARE;
}
logger.info(" " + bfgs.get_code_string(ret));

return return_code;
}
Expand Down
5 changes: 4 additions & 1 deletion src/stan/services/optimize/lbfgs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,17 @@ int lbfgs(Model& model, const stan::io::var_context& init,
}

int return_code;
auto error_string = lbfgs.get_code_string(ret);

if (ret >= 0) {
logger.info("Optimization terminated normally: ");
logger.info(" " + error_string);
return_code = error_codes::OK;
} else {
logger.error("Optimization terminated with error: ");
logger.error(" " + error_string);
return_code = error_codes::SOFTWARE;
}
logger.info(" " + lbfgs.get_code_string(ret));

return return_code;
}
Expand Down

0 comments on commit a6af397

Please sign in to comment.