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

The compute of Hessian may be wrong #10

Closed
ZzhengP opened this issue Jul 18, 2018 · 6 comments
Closed

The compute of Hessian may be wrong #10

ZzhengP opened this issue Jul 18, 2018 · 6 comments
Labels

Comments

@ZzhengP
Copy link

ZzhengP commented Jul 18, 2018

Hessian_.noalias() = SelectionVector.asDiagonal() * Weight * A.transpose() * A ;
In orca, the Hessian matrix of qpOASES is computed like , the first term is the weight.
For qpOASES, the problem is formulated like
.
Finally, we have to multiply the Hessian matrix computed in ORCA by 2 for qpOASES.

@rlober
Copy link
Contributor

rlober commented Jul 18, 2018

The 1/2 won't affect the global optimum as long as it is missing (or present) for all objectives.

@ZzhengP
Copy link
Author

ZzhengP commented Jul 18, 2018

When I define a class of gravity regularization, I define E like a identity matrix and f equals to -g. But the simulation shows that the robot compensates too much gravity torque. By multiplying H by 2, I solved the problem. I think 1/2 affect regularization resolution.

@rlober
Copy link
Contributor

rlober commented Jul 19, 2018

It still shouldn't make any difference because the gradient is multiplied by 2 already :

Gradient_.noalias() = 2.0 * SelectionVector.asDiagonal() * Weight * A.transpose() * b ;

0.5 x'Hx +x'g = x'Hx + 2x'g

Can you post links to the relevant parts of your code? I think the problem is something more subtle.

@ZzhengP
Copy link
Author

ZzhengP commented Jul 20, 2018

(Ex+f)'(Ex+f) = (x'E'Ex + 2x'E'f) = x'Hx + x'g. Therefore, this factor 2 means 2E'f = g.
https://github.com/ZzhengP/Stage_M2/blob/b4b9c2b77ed5880b013df82be87038c462ffcbb6/rtt_orca_reg.hpp#L13

@ahoarau
Copy link
Member

ahoarau commented Jul 20, 2018

(Ex+f)'(Ex+f) = (x'E'Ex + 2x'E'f)
and
0.5 x'Hx +x'g = x'Hx + 2x'g

Means that
H = E'E
and
E'f = g

In the code it's 2E'f = g

Problem ! Thanks for reporting. This is a nasty one

@ahoarau ahoarau added the bug label Jul 20, 2018
ahoarau added a commit that referenced this issue Jul 22, 2018
@ahoarau
Copy link
Member

ahoarau commented Jul 22, 2018

Fixed in 64f5637
Thanks !

@ahoarau ahoarau closed this as completed Jul 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants