Internal Modification of Linear System Solver

108 views
Skip to first unread message

Diego Coelho

unread,
Jun 2, 2016, 1:58:36 PM6/2/16
to Ceres Solver
Hi guys,

I am working on a project in linear system solvers. We derived a 'new method' for solving linear systems and we want to put it into ceres to compare/measure its performance on optimization problems in Computer Vision. I searched for documentation about ceres, and the only thing I could find was API documentation, but it is not what I want. I want to understand the internal structure in ceres code.

The question: Do you guys knows where I can find internal/developer ceres documentation (if there is any)?

At the end of the day, I want to modify (indeed add) a linear solver method, and I could not find which function/method should I change. I come to the point that there a method called Solve in class Solver, and this method calls another method named minimize from class Minimizer. But I could not go further.

Thanks in advance,
Diego.

Sameer Agarwal

unread,
Jun 2, 2016, 4:23:36 PM6/2/16
to Ceres Solver
Diego,
There are no docs targeting the internals. We have tried to make the code as self documenting as possible. If you have specific questions, I'd be happy to answer them. If you can share precisely what you are trying to do, I can make some educated suggestions as to best way to do that too.
Sameer


--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/b9e3e795-aff1-4496-918d-b32cf1e3efa8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sameer Agarwal

unread,
Jun 2, 2016, 4:25:05 PM6/2/16
to Ceres Solver
To answer your specific question about how the linear solver is called, the preprocessor determines the best linear solver for the problem, and creates it and associates it with the problem. The TrustRegionMinimizer then calls a TrustRegionStrategy which in turn calls the linear solver that was created by the Preprocessor.

Sameer

Diego Coelho

unread,
Jun 2, 2016, 4:51:08 PM6/2/16
to Ceres Solver
Hi Mr. Agarwal,

Many thanks for the reply here and suggestion at stackoverflow.

I am a grad student and me and my supervisor are working on methods for solving linear systems. We are developing a particular one that seems to be promising and I would like to insert them on ceres for test/comparison with other current methods. 

I noticed that ceres has quite a few methods such as conjugate gradient method, QR factorization, Cholesky and so on for dense and sparse matrices. I want to put my method in a 'side-by-side' fashion manner. For that I need to have access for the normal equations Hx=b (I mean the Hessian matrix H and the independent vector b). I could not find the exact place where to find it.

We are interested in use that in Computer Vision problems. Currently, we are using OpenMVG, that uses ceres for least-square minimization during Bundle Adjustment step (I am sure you understand very well this problem. I read your paper on that). In this particular case, ceres apparently uses Schur decomposition for solving the linear systems.

In my particular machine, I am using Ubuntu 16.04 with the latest ceres version. I know that the code is well commented, but I still could not figure it out what function really performs the linear system solution. Most likely are several functions/methods one for each linear system solution method. I would be very happy if you could tell me to which class they belong and how to access the Hessian matrix H and the independent vector b of normal equations Hx=b in each iteration.

Again, many thanks for the help and for making ceres open source. Definitely, it is an incredible contribution for the Computer Vision and Optimization communities and many others.

Diego.

Sameer Agarwal

unread,
Jun 2, 2016, 4:53:32 PM6/2/16
to Ceres Solver
does your system work on dense or sparse matrices?
My guess is sparse matrices, you should look into sparse_normal_cholesky_solver.cc which solves the sparse normal equations using, SuiteSparse, Eigen and CXSparse as indicated by the user.



Diego Coelho

unread,
Jun 2, 2016, 4:56:00 PM6/2/16
to Ceres Solver
Hi Mr. Agarwaal,

I forgot to mention. It works on sparse. I checked the libraries that it uses and it is CXSparse.

Sameer Agarwal

unread,
Jun 2, 2016, 5:07:09 PM6/2/16
to Ceres Solver
sparse_normal_cholesky_solver is the place to start. you can modify it in place and plug your algorithm in.


Diego Coelho

unread,
Jun 3, 2016, 1:53:30 PM6/3/16
to Ceres Solver
Hi Mr. Agarwaal,

By any reason ceres::Solver is not calling any function of sparse_normal_cholesky.cc. I put a piece of code in every method on sparse_normal_cholesky to create a txt file in my home/Desktop folder, but file is never created.

I made the same for ceres::Solver, and it creates the files and write on it nicely. I am just assuming ceres is not calling the methods/functions from sparse_normal_cholesky (I dont know why).

Let me ask you, is the method Minimize from class Minimizer implemented by TrustRegionMinimizer class?

Best,
D. 

Sameer Agarwal

unread,
Jun 3, 2016, 1:55:31 PM6/3/16
to Ceres Solver
Diego,

Are you asking the solver to actually solve using the SPARSE_NORMAL_CHOLESKY solver? 
The best way to see this is to look at the output of the Summary::FullReport. Also before you start modifying the solver, it would be a good idea to learn to use the solver a bit and get a sense of its control flow. It will make things considerably simpler.

Sameer


Diego Coelho

unread,
Jun 3, 2016, 2:01:42 PM6/3/16
to ceres-...@googlegroups.com
Hi Sameer,

Yes. I imagined that the my ceres (called by openMVG) was calling sparse_normal_cholesky to solve the linear system of normal equations, but apparently it is not happening. I will see the documentation to turn full report on.

Best,
D.



Sent with MailTrack

--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/E3C7QQYAgYQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/CABqdRUCnxLqzmfBY_edVxssqcw9V%2BksseSUk63Ff_8JTyvH0Hw%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



--
Atenciosamente,

Diego F. G. Coelho.

Diego Coelho

unread,
Jun 3, 2016, 2:02:16 PM6/3/16
to Ceres Solver
Hi Sameer,

Yes. I imagined that the my ceres (called by openMVG) was calling sparse_normal_cholesky to solve the linear system of normal equations, but apparently it is not happening. I will see the documentation to turn full report on.

Best,
D.

Diego Coelho

unread,
Jun 10, 2016, 4:50:46 PM6/10/16
to Ceres Solver
Hi Sameer,

Many thanks! Actually I discovered that OpenMVG was calling ceres with the linear solver option SPARSE_SCHUR, and that was why ceres was not calling the function at sparse_normal_cholesky.cc. I Changed OpenMVG code to call ceres with SPARSE_NORMAL_CHOLESKY. Now I fond what I was looking for.

Yuwei Jheng

unread,
Aug 18, 2019, 8:35:11 AM8/18/19
to Ceres Solver
Hi Diego,

How do you implement the trick of modifying the Hessian matrix H and the independent vector b?
I am trying to do the same without success.

Thanks in advance.
Yuwei
Reply all
Reply to author
Forward
0 new messages