Skip to content

Commit

Permalink
Fix for bug in linear constraint gradient. (#161)
Browse files Browse the repository at this point in the history
Summary:

It turned out we were missing a weight, which I noticed when I changed the weight to be something other than 1.

Reviewed By: jeongseok-meta

Differential Revision: D66893638
  • Loading branch information
cdtwigg authored and facebook-github-bot committed Dec 9, 2024
1 parent 15d2a51 commit bf77bad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions momentum/character_solver/limit_error_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,10 @@ double LimitErrorFunctionT<T>::getGradient(
error += residual * residual * limit.weight * tWeight;

if (this->enabledParameters_.test(data.targetIndex)) {
gradient[data.targetIndex] += T(2) * residual * data.scale * tWeight;
gradient[data.targetIndex] += T(2) * residual * data.scale * limit.weight * tWeight;
}
if (this->enabledParameters_.test(data.referenceIndex)) {
gradient[data.referenceIndex] -= T(2) * residual * tWeight;
gradient[data.referenceIndex] -= T(2) * residual * limit.weight * tWeight;
}
}
break;
Expand Down
4 changes: 2 additions & 2 deletions momentum/test/character_solver/error_functions_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ TYPED_TEST(Momentum_ErrorFunctionsTest, LimitError_GradientsAndJacobians) {
SCOPED_TRACE("Limit LinearTest");
ParameterLimit limit;
limit.type = Linear;
limit.weight = 1.0;
limit.weight = 1.5;
limit.data.linear.referenceIndex = 0;
limit.data.linear.targetIndex = 5;
limit.data.linear.scale = 0.25;
Expand Down Expand Up @@ -134,7 +134,7 @@ TYPED_TEST(Momentum_ErrorFunctionsTest, LimitError_GradientsAndJacobians) {
limit.type = LimitType::Linear;
limit.data.linear.referenceIndex = 0;
limit.data.linear.targetIndex = 5;
limit.weight = 1.0f;
limit.weight = 0.5f;

{
ParameterLimit cur = limit;
Expand Down

0 comments on commit bf77bad

Please sign in to comment.