acado / acado

ACADO Toolkit is a software environment and algorithm collection for automatic control and dynamic optimization. It provides a general framework for using a great variety of algorithms for direct optimal control, including model predictive control, state and parameter estimation and robust optimization.
www.acadotoolkit.org
GNU Lesser General Public License v3.0
480 stars 243 forks source link

STLification #66

Open mvukov opened 10 years ago

mvukov commented 10 years ago

There is a new branch of ACADO, the one which should heavily use STL. Currently it is on my remote: https://github.com/mvukov/acado/tree/stlification. In the main CMakeLists.txt you can see what is compiling so far.

Some of the ideas behind this adventure:

Task list:

Organizational:

mvukov commented 10 years ago

So far I can compile what was called acado_integrators once upon the time... Moreover, I can compile compile all examples from basic_data_structures folder, and execute them without a problem. However, unit-testing should really check whether all results are correct.

rienq commented 10 years ago

I love this initiative ! good work ;-)

mvukov commented 10 years ago

Everything except CGT is compiling so far... Anyways, compiling code piece-by-piece was a nightmare...

jgillis commented 10 years ago

:+1:

mvukov commented 10 years ago

So far, as of 5e9d42b3bc940b555efc9ce873a9e4529348de13, "standard"/"offline" ACADO works -- I debugged a lot of things (mainly bugs which I introduced while refactoring :facepunch: ). Libs compile as well as examples. Tests, aka make test works fine.

mvukov commented 10 years ago

Some news...

I refactored CGT, completely. It does not work yet, though it compiles. I changed some API functions, so I had to comment some pieces of the code.

Major thing to make CGT working again will be to refactor Matrix class, add sparsity pattern functionality. ... and remove this responsibility from the ExportVariable class.

STL is awesome.

At the end, CGT is gonna be a like plugin to ACADO, really sitting on the top.

BTW, I refactored Options functionality a few days ago, using std::map, templates, shared pointers etc. And added std::string like options. We can later add whatever like options we want :yum:

ghorn commented 10 years ago

Wow!

rienq commented 10 years ago

That sounds really promising indeed ! I should check it out soon..

mvukov commented 10 years ago

I rebased all matrix/vector/linear algebra stuff to use the Eigen3 library, which is gonna be shipped with ACADO, licenses are compatible. I packed version 3.2.0.

The Matrix and Vector classes are now just wrappers around Eigen's classes.

During refactoring, I screwed up BDF integrator, and disabled it for now. Except this, everything works smoothly; I checked a few examples on OSX with valgrind, and they seen to work fine; make test works (except for examples that use BDF integrator). CGT is not being touched, yet.

CGT is the next step...

ghorn commented 10 years ago

:smile_cat:

jgillis commented 10 years ago

I'm wondering what kind of benefits you will see with Eigen. I made a proof-of-concept Eigen backend for casadi matrix arithmetic once ( casadi/casadi@8667ff697ad8e428290084f321ff5ba43c55bd1f ), but if i recall correctly, @joelandersson suspected it would not deliver much benefits.

ghorn commented 10 years ago

I'm wondering exactly the same thing. I'm especially curious about http://eigen.tuxfamily.org/dox/group__SparseQuickRefPage.html

mvukov commented 10 years ago

The main reason for the upgrade of m/v/la functionality is to have something rock-solid. I saw a lot of fishy things happening lately. IMO, Eigen is pretty mature piece of code to be used. So far, I am happy using it :)

Here are more things:

To conclude, from something that was not well maintained, I made an upgrade to a mature piece of code.

ghorn commented 10 years ago

I hope you didn't interpret my statement as criticism. I meant that I think it is a great move, and I'm excited to see exactly how great.

mvukov commented 10 years ago

Nope :) I just wanted to back up my decision :)

jaeandersson commented 10 years ago

Good job! I think this will improve the maintainability of the code a lot. I'm curious if it also improves speed, and if so for what operations.

mvukov commented 10 years ago

As of bc501fa2ec28f3cee00aa32283aebe4beae7e703, CGT should work on the level as before. I need to do further checks, so far examples/code_gen.../mpc_mhe/getting_started.cpp works -- here I also illustrated the new syntax to forward sparsity of the weighting matrices.

As more info will come later, here are some important things: matrix and vector classes are templated, and I typedefed a few data types:

Vector data types are named in a similar fashion. Yes, I stole names from CasADi :p.

As ExportVariable is not exposed any more to users (!), BMatrix is used to convey sparsity pattern of a matrix to the CGT. This is why I refactored half of ACADO, mainly...

From user point of view, this is more/less everything for this round. Now I am gonna work on internals, to make them more efficient and rock-solid.

BTW, BDF integrator is still not working.

All in all, after I test a bit this I will merge this to master.

jaeandersson commented 10 years ago

Yes, I stole names from CasADi :p.

See you in court.

mvukov commented 10 years ago

:smiley:

ghorn commented 10 years ago

FYI:

http://linalg.rubyforge.org/classes/Linalg/DMatrix.html

http://trilinos.sandia.gov/packages/docs/r7.0/packages/moocho/src/DenseLinAlgPack/doc/html/classDenseLinAlgPack_1_1DMatrix.html

http://www.iro.umontreal.ca/~simardr/ssj/doc/html/umontreal/iro/lecuyer/util/DMatrix.html

http://stat.ethz.ch/R-manual/R-devel/library/Matrix/html/dMatrix-class.html

http://patsy.readthedocs.org/en/v0.1.0/API-reference.html

http://aszt.inf.elte.hu/~gsd/pny2/html/eaC_stl/dmatrix.cpp.html

http://www.indiana.edu/~pavlab/software/gclgrid/html/dmatrix_8h_source.html

http://www.geom.uiuc.edu/java/Kali/DMatrix.html

http://digilander.libero.it/carmine.lia/jroboop/doc/javax/robotics/vecmath/DMatrix.html

http://nicta.github.io/scoobi/api/SCOOBI-0.7.0-cdh4/index.html#com.nicta.scoobi.lib.DMatrix

http://robotics.naist.jp/~akihiko-y/doxy/ode0.9/classdMatrix.html

http://www.stanford.edu/~boyd/l1_logreg/structdmatrix.html

http://www.brtt.com/w/index.php?title=Dmatrix(3)

http://www.stata.com/manuals13/m-5dmatrix.pdf

:neutral_face:

mvukov commented 10 years ago

@ghorn good job! :smile:

mvukov commented 10 years ago

As of a292e6c3c17fadd96d5eb641d067581aabab8fd5, there is a new symbolic data type OnlineData, which should replace functionality for which we use Parameter in the CGT.

So far I managed to add the new type to the symbolic core as well as to partially tunnel it to the CGT. Since we abused Parameter functionality a lot in past 2 years, it requires more time to update the whole infrastructure...

All in all, after this upgrade, we will use OnlineData instead of Parameter class for the same stuff. True parameter estimation should be the next step then.

mvukov commented 10 years ago

BTW, @ghorn made a comment that we are gonna use dense matrix type BMatrix for representing sparsity pattern. In case someone is not happy with that, (s)he can convert it to sparse: sparse = dense.sparseView(); ...

rienq commented 10 years ago

nice! :+1:

mvukov commented 10 years ago

With 36bc9e6 the BDF integrator is revived. Because of the dodgy memory management, I was not able to fix factorizations. So, the integrator is not reusing the factorization and the more complex fix should be developed.

mvukov commented 10 years ago

OK, the tests seem to work. They are included now to pass, mandatory (before it was allowed for them to fail executing).

mvukov commented 10 years ago