Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Huangzizhou committed Dec 1, 2023
1 parent 04cf01e commit c5eac6c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion non-linear-solver-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@
},
{
"pointer": "/f_delta",
"default": -1,
"default": 0,
"min": 0,
"type": "float",
"doc": "Dangerous Option: Quit the optimization if the solver reduces the energy by less than f_delta for consecutive f_delta_step_tol steps."
},
Expand Down
18 changes: 9 additions & 9 deletions src/polysolve/nonlinear/Solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,26 +106,26 @@ namespace polysolve::nonlinear
: m_logger(logger), m_name(name), characteristic_length(characteristic_length)
{
TCriteria criteria = TCriteria::defaults();
criteria.xDelta = solver_params["x_delta"].get<double>();
criteria.fDelta = solver_params["f_delta"].get<double>();
criteria.gradNorm = solver_params["grad_norm"].get<double>();
criteria.xDelta = solver_params["x_delta"];
criteria.fDelta = solver_params["f_delta"];
criteria.gradNorm = solver_params["grad_norm"];

criteria.xDelta *= characteristic_length;
criteria.fDelta *= characteristic_length;
criteria.gradNorm *= characteristic_length;

criteria.iterations = solver_params["max_iterations"].get<int>();
criteria.iterations = solver_params["max_iterations"];
// criteria.condition = solver_params["condition"];
this->setStopCriteria(criteria);

use_grad_norm_tol = solver_params["line_search"]["use_grad_norm_tol"].get<double>();
use_grad_norm_tol = solver_params["line_search"]["use_grad_norm_tol"];

first_grad_norm_tol = solver_params["first_grad_norm_tol"].get<double>();
first_grad_norm_tol = solver_params["first_grad_norm_tol"];

use_grad_norm_tol *= characteristic_length;
first_grad_norm_tol *= characteristic_length;

f_delta_step_tol = solver_params["f_delta_step_tol"].get<int>();
f_delta_step_tol = solver_params["f_delta_step_tol"];

set_line_search(solver_params);
}
Expand Down Expand Up @@ -224,7 +224,7 @@ namespace polysolve::nonlinear

f_delta = std::abs(old_energy - energy);
// stop based on f_delta only if the solver has taken over f_delta_step_tol steps with small f_delta
this->m_current.fDelta = (f_delta_step_cnt > f_delta_step_tol) ? f_delta : NaN;
this->m_current.fDelta = (f_delta_step_cnt == f_delta_step_tol) ? f_delta : NaN;

///////////// gradient
{
Expand Down Expand Up @@ -335,7 +335,7 @@ namespace polysolve::nonlinear
s->reset(x.size());

m_logger.debug(
"[{}][{}] {} was successful for {} iterations; attempting {}",
"[{}][{}] {} was successful for {} iterations; resetting to {}",
name(), m_line_search->name(), prev_strategy_name, current_strategy_iter, descent_strategy_name());
}

Expand Down

0 comments on commit c5eac6c

Please sign in to comment.