Thursday, March 31, 2005

Reading old Graph partition code

* Completed Gibbs sampler generic simple code; should be working

* Minor fixes throughout the code

* Detected a bug in the Message Passing code for FGs; specifically, when a Potential node sends a message. The product of the messages is wrong in the second phase (when messages come back from the root). This is because the whole product of messages is used, and we need to remove from that product the message of the Node we are sending to. Needs to be fixed (urgent)

* Read the old code partitioning a Graph into tree for Rao-Blackwellisation (code dating back to Summer 2004). Code base is very ugly (I really code better now, which is a good thing to see :-), but understandable. Basically, we are doing a partition based on choosing the node with the lowest connectivity (equals are resolved in favor of the latest node "selected"). We have a backtrack of depth 1, if we are going to encounter a "dead-end" (previously called a full-looping vertex, but the terminology needs to be changed). More on this algorithm soon...

* Started a code clean-up (cosmetic changes), on every file.

-> fix the MP bug;

-> continue the code clean up;

-> think about the possible implementation of the old Partitioning code

Wednesday, March 30, 2005

Starting on Gibbs sampler Generic work

* C++: if you declare a function virtual and don't provide a definition in one of the subclasses, then it will use the one from the main class. If the function is pure of course it won't work. Also, on this matter the hierarchy works as expected: it will try to use a function defined deep in the hierarchy.

* Tested generic implementation of Message Passing, seems fine now

* Worked on the Gibbs sampler, generic implementation. The same problems as for the MP algorithm were there. The same ugly solution was used (a switch on types), but to do it elegantly template specialization would really be needed.

* Problems with headers, and templates are getting worse and worse. Have to spend time on that...

* You need to propagate, in the Gibbs sampler, the value chosen by your variable to the Potentials.

-> test and finish Gibbs sampler

-> learn about typedefs, and if it is possible to obtain the base type from a pointer type

Tuesday, March 29, 2005

Implementation, continued

* Finished the implementation of Generic Message Passing. But the result is ugly, with a switch on type, etc... The implementation could be way better with a rewrite. For this we would need to do template specialization, mark Potential and Variable MessageNode as subclass of FacotrGraphMessageNode (for exemple). We could then rewrite a lot of stuff more nicely.

* Implemented a sum over a Potential. It is not general, but it is well implemented, I believe, for Discrete Potentials, RVs, and Factor Graph.It allows us to actually send the messages from the Potential Node.

-> test our implementation of Message Passing

-> write a generic version of the Gibbs Sampler (simple)

Saturday, March 26, 2005

Work on Generic Implementation of Message Passing...

* 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.

Friday, March 25, 2005

Factor Graphs, and message passing

* learned about template specialization (explicit). Seems useful, but not ideal. Note that this serves a different purpose than polymorphism, since it is done at compile-time vs. run-time.

* this template specialization can even be done with traits, and template arguments can have a default argument. (this is how nice things can be done)

* learned that virtual templated functions don't exist (CAN'T exist). However member templated functions are fine. Virtual functions inside templated class are also fine

* heard of the book "Modern C++ design"

* began work towards an implementation of message passing for Factor Graphs. The goal is to create an algorithm that will work independently of wether the is a Factor Graph or a MRF. For that I derived the base class Message Node; I use a virtual send_message. However due to problems much of the implementation is somehow ugly hacked into the visitor, which checks for the type of the node and then does the message passing accordingly.

* created new files "GraphAlgorithms.h" and "GraphAlgorithms.cc"

* some thinking about the implementation of Loopy Belief Propagation; seems not that easy with our current way of doing things

-> finish the implementation of Message passing for Factor graphs (compile; lots of work still)

-> run it, test

-> begin implementing Gibbs sampler for factor graphs.

Thursday, March 24, 2005

things to do

* send an email for the restaurant (Malek and al.)

* apply for tuition deferall

* do taxes 2005

* check taxes 2004 if check not received at end of April

* update my web site

* write letters to a lot of people

* write emails to a lot of people

* write Jean-Yves Defay about Marina