question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[C++] numerical issue

See original GitHub issue

Hi @hungpham2511

I encounter a numerical issue at this line: https://github.com/hungpham2511/toppra/blob/5ffa8e1b92c8151e837a2fd4253948860d9bbc38/cpp/src/toppra/solver/glpk-wrapper.cpp#L113

Function intersection(a, b, c) computes the intersection between interval a and interval b and stores it into c. At some point, I get a = [0.11138810763690521, 0.11138810763690521 ] and b = [ 0, 0.11138810763690514 ]. If you look carefully at the values, you will see that:

  • the intersection is empty and
  • the upper bound of b is very close to a.

I get this during the forward pass. In my scenario, I have only one linear velocity constraint (which gives b). When the fault happens, the a value is the x value passed to the solver (so the feasible set at the index i).

I can make a work around in this solver but I am wondering whether this should be addressed at a higher stage, like in the TOPPRA algorithm itself.

Any thoughts on this ?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
hungpham2511commented, May 28, 2020

Yes for qpOASES. I measured it. Also, the worst-case time-complexity of 2D LP is O(m^2), while 1D LP is O(m). So the speedup is quite minimal for fewer constraints. Nothing very major.

That said if we really want to get the best possible performance out of the algorithm, then each LP should also use information from the last, i.e., what constraints are active in the last step. Since we know for sure that there can be a fixed number of constraint-switching in the final trajectory, the time-complexity is actually ~ O(1) for a fine gridpoint. This is the main motivation for using qpOASES with its warmstart functionality.

0reactions
jmirabelcommented, May 28, 2020

Thanks for your insight. It is helpful.

Actually this is even better because the line search is much simpler to solve.

I agree the problem is simpler to solver but I expect the solver to actually do that simplification:

  • GPLK knows when a variable is fixed,
  • I am not sure for qpOASES but as equality constraints are built from inequalities, I would expect it to detect fixed variables.

Did you check that it is actually faster ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

floating point - Analyzing Numerical Error in C++ Function
I'm programming in C++. What is the typical way of programmatically measuring how much error is in the results? Assuming that I need...
Read more >
C++ Numerical truncation error - Stack Overflow
Yes, this is normal numeric representation floating point error. It has to do with the fact that the hardware must approximate most floating ......
Read more >
Common problems in numerical computation: from data ...
Common problems in numerical computation: from data overflow, rounding error, poor conditioning to memory leak. In many modern science and ...
Read more >
Introduction to Software Security - Chapter 3.2: Numeric Errors
Improper integer computation is a common cause of security issues that manifest in many ways. Unfortunately, due to limitations of hardware and historical ......
Read more >
Understanding and Tracing Numerical Errors in C++
Overview: Computer number representations have limited precision. Results of arithmetic operations are rounded to the nearest representable number.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found