* Learned a lot and a lot about C++. Implementation went on but at a slow pace
* learned that polymorphism can only be used, in essence, with pointers (probably with references too, have to check). This is also very important to note that containers are not mean to contain objects of different classes (to use with polymorphism). this is because a vector uses a constant amount of memory. If a container contains objects and not pointers, the objects will be sliced to the base class !! Which is of course a disaster at run time.
* learned about RTTI. There is a way to make dynamic downcast at runtime, if you absolutely can't use virtual functions (which is my case with the visitors for differentiating between a Factor graph and an MRF). For now I implemented that myself "poorly" (with a switch statement and integers).
* Since objects must generably be assignable in a container, using classes with const members is not a good choice if they must be stored in containers...
* Lots of other small C++ things learnt.
* As far as implementation goes:
* To support different types of Graphs on algorithms, there are basically two solutions: in the Graph containers, maintain pointers to the base class and use polymorphism. This is not ideal since in many case polymorphism can't really work and you have to do type checking yourself... The other solution is to use objects in the Graph, meaning you can't use polymorphism, and you have to explicitely specialize your visitor for the different types of Graph you can have. That seems cleaner... but maybe less generic in the long run...
* For now I have still chosen solution 1.
* Fixed an important bug in the initialization of a Potential (when adding variable). This should be ok now.
* Code for message passing on a MRF is again functional via polymorphism. Gibbs sampler is not ready
* I should really start to add typedefs in my code (and learn about it). Other question: can you get the type of something if you only have the type of the pointer?? For now there are ugly types (added by hand) throughout the Message Passing visitors...
-> continue towards the implementation of message passing for Factor Graphs (using the current chosen solution with pointers). Now we should be *really* close; only a little bit more of testing, implementation, and the implementation of routines to sum recursively over something is needed.
-> reimplement a generic Gibbs sampler.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment