Skip to content

Commit

Permalink
Fix verify_jacobian param reset to use untransformed value
Browse files Browse the repository at this point in the history
  • Loading branch information
taranu committed Nov 7, 2023
1 parent 53818ab commit 0435f58
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions include/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,7 @@ class Model : public ParametricModel {
const size_t idx_param = _offsets_params.find(param_ref)->second;
const auto& grad = grads[idx_param];

const double value_init = param.get_value();
const double value = param.get_value_transformed();
double diff = value * findiff_frac;
if (std::abs(diff) < findiff_add) diff = findiff_add;
Expand All @@ -1443,10 +1444,12 @@ class Model : public ParametricModel {
}
}

param.set_value_transformed(value);
if (param.get_value_transformed() != value) {
param.set_value(value_init);
const double value_new = param.get_value();
if (value_new != value_init) {
throw std::logic_error("Could not return param=" + param.str()
+ " to original value=" + std::to_string(value));
+ to_string_float(value_new) + "; diff="
+ to_string_float(value_new - value_init) + "); check limits");
}
if (n_failed > 0) {
std::sort(ratios.begin(), ratios.end());
Expand Down

0 comments on commit 0435f58

Please sign in to comment.