Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SofaBaseLinearSolver] FIX breaking condition in CG at first step regarding threshold #556

Merged
merged 7 commits into from
Jan 12, 2018

Conversation

hugtalbot
Copy link
Contributor

@hugtalbot hugtalbot commented Jan 5, 2018

Fix bug introduced in #521

If threshold is met at first step with den=0, break but info msg
about the status of the linear system.

If threshold is met at first with den!=0, then continue one more iteration
and warning about threshold value too large.


This PR:

  • builds with SUCCESS for all platforms on the CI.
  • does not generate new warnings.
  • does not generate new unit test failures.
  • does not generate new scene test failures.
  • does not break API compatibility.
  • is more than 1 week old (or has fast-merge label).

Reviewers will merge only if all these checks are true.

If threshold is met at first step with den=0, break but info msg
about the status of the linear system.

If threshold is met at first with den!=0, then continue one more iteration
and warning about threshold value too large.
@hugtalbot hugtalbot added pr: fix Fix a bug pr: status to review To notify reviewers to review this pull-request labels Jan 5, 2018
@hugtalbot
Copy link
Contributor Author

[ci-build][with-scene-tests]

Copy link
Contributor

@IPeterlik IPeterlik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK to me. Basically, apart from issuing a warning, the code should not explicitly handle the case when the residual is below a threshold already in the first iteration, since numerically, it's a correct behavior even if it yields an unwanted result (e.g., an object is not moving despite applied forces). CG is an iterative solver and anyone using it should be well aware of its parameters and their impact on the simulation.

@damienmarchal
Copy link
Contributor

[ci-build][with-scene-tests]

@hugtalbot hugtalbot changed the title FIX breaking condition in CG at first step regarding threshold [SofaKernel] FIX breaking condition in CG at first step regarding threshold Jan 8, 2018
@hugtalbot
Copy link
Contributor Author

Your remarks are taken into account @IPeterlik :)
let's see if any further feedback

endcond = "threshold";
if( verbose )
{
sout<<"CGLinearSolver, den = "<<den<<", smallDenominatorThreshold = "<<f_smallDenominatorThreshold.getValue()<<sendl;
msg_info() << "CGLinearSolver, den = " << den <<", smallDenominatorThreshold = " << f_smallDenominatorThreshold.getValue();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for CGLinearSolver...msg_info add the prefix.

sout<<"den = "<<den<<", alpha = "<<alpha<<sendl;
sout<<"x : "<<x<<sendl;
sout<<"r : "<<r<<sendl;
msg_info() << "den = " << den << ", alpha = " << alpha;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No needs for three messages...one is better (and more efficient)

@@ -63,6 +63,29 @@ CGLinearSolver<TMatrix,TVector>::CGLinearSolver()
f_smallDenominatorThreshold.setRequired(true);
}

template<class TMatrix, class TVector>
void CGLinearSolver<TMatrix,TVector>::init()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For usability reason I would recommand to have something like

if(f_verbose.getValue()){
    f_printLog.setValue(true); 
}

@@ -109,7 +132,7 @@ void CGLinearSolver<TMatrix,TVector>::solve(Matrix& M, Vector& x, Vector& b)
double rho, rho_1=0, alpha, beta;


msg_info_when(verbose) <<" CGLinearSolver, b = "<< b ;
msg_info_when(verbose) << " CGLinearSolver, b = " << b ;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No needs for the 'CGLinearSolver' prefix

@damienmarchal damienmarchal added the pr: fast merge Minor change that can be merged without waiting for the 7 review days label Jan 9, 2018
@damienmarchal
Copy link
Contributor

Now it is fast merge :)

@hugtalbot
Copy link
Contributor Author

is this fine now ?

@damienmarchal
Copy link
Contributor

For me, when the CI will re-vive and says ok it may go.

@damienmarchal damienmarchal added this to the v17.12 milestone Jan 10, 2018
@bcarrez
Copy link
Contributor

bcarrez commented Jan 10, 2018

[ci-build]

@damienmarchal
Copy link
Contributor

[ci-build][with-scene-tests]

@hugtalbot
Copy link
Contributor Author

oh dear lord this PR looks fine !

@sofa-framework sofa-framework deleted a comment from damienmarchal Jan 11, 2018
@sofa-framework sofa-framework deleted a comment from damienmarchal Jan 11, 2018
@damienmarchal
Copy link
Contributor

[ci-build][with-scene-tests]

@damienmarchal
Copy link
Contributor

Ok the PR' works, I looked at each build on jenkins...no failure...but the formatter is not launched but I think we can ignore the formatting stuff to move forward the release. @guparan @bcarrez do you agree ?

PS: the sofa dashboard doesn't like PR with weird name & symbols :)

@guparan
Copy link
Contributor

guparan commented Jan 12, 2018

Agreed, let's merge!

@guparan guparan merged commit f83e858 into sofa-framework:master Jan 12, 2018
@hugtalbot
Copy link
Contributor Author

sorry again for the inconvenience of this sexy # in my PR branch name..

@guparan guparan changed the title [SofaKernel] FIX breaking condition in CG at first step regarding threshold [SofaBaseLinearSolver] FIX breaking condition in CG at first step regarding threshold Jan 25, 2018
@hugtalbot hugtalbot deleted the fix_CG_after_#521 branch September 21, 2018 16:36
@hugtalbot hugtalbot added pr: status ready Approved a pull-request, ready to be squashed and removed pr: status to review To notify reviewers to review this pull-request labels Feb 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: fast merge Minor change that can be merged without waiting for the 7 review days pr: fix Fix a bug pr: status ready Approved a pull-request, ready to be squashed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants