Thursday, May 18, 2006

Writing C/C++ with ACE

What is it about writing C/C++ code that turns us in cryptographers? I know that the language is inherently cryptic with its myriad of possible ways to shoot yourself in the foot, but shouldn't that make us want to write cleaner code? In an effort to break the cycle I've picked up a highly recommended book by Scott Meyers called "Effective C++". I love "Effective Java" by Joshua Bloch, and I'm fairly certain that Bloch got the idea for his book directly from Meyers's book. Looking forward to devouring its 55 nuggets of wisdom.

I recently have come into contact with the Adaptive Communication Environment (ACE) toolkit for C++. My first thought was "wow! this is incredible", followed shortly by "why on earth haven't I ever heard of this before?!?!" I felt a little cheated for it never to have been mentioned in any classes I took, particularly considering how long it's been around. I'm on a very steep learning curve with how to use it and will post in more depth when I'm further up that curve. But the initial report is still "wow".

Sunday, March 26, 2006

Posting from Seattle

Well the conference is over and I'm posting from Seattle airport. My flight has been delayed a little and I thought this a good time to try and summarize the trip a little.

I firstly want to apologies for my previous post "Good Morning Seattle", I was deliriously tired while writing that. I had thought about going back and changing it, but it's a little humorous to go back and read so I've left it up.

The trip has been a huge mixture of success and failure. Firstly, our presentation went wonderfully. I really feel that we hit the key points of Shoechicken to great effect, and skipped the uninteresting details. There were so many questions at the end that the session chair had to cut many off due to a lack of time. People seemed genuinely interested, now we just need to get something out there for people to download,

That's the up side of the conference, the down side is that the conference wasn't that great to say the least. There were at most 50-60 people and may of those didn't stay the whole time. Many of the talks were either barely intelligible, or downright awful. There were a few notable exceptions, but I have to say that I will certainly not be coming back next year.

On the up side of things, Seattle has been wonderful. It's reminded me of home a great deal. I got to see the space needle, pike market, the first starbucks, underground Seattle, and many more things. I cannot believe how many coffee shops there are here. It's almost unfathomable that there are that many, particularly the number of starbucks. Not that I'm complaining of course, as a coffee addict it's a big selling point for me. I really liked being able to walk from place to place. Living in Pensacola has pretty much abolished any daily walking I do; outside of downtown people just don't walk places. We've walked well in excess of 10 miles while being here and it's been lovely. The only bad comments I have about Seattle are the number of homeless, and the lack of police presence.

Overall I've enjoyed my trip. In a way more importantly I feel like it's been a huge learning experience. I have taken a great deal from presenting at this conference. Some of which is what to do and some being what not to do. The other side of it being general travel experience. I hadn't realized how inflexible travel packages from places like expedia are. We also ended up with a rental car that we barely used due to the convenience of walking everywhere here.

Well everyone, this is it from Seattle for me, ta ta for now.

Monday, March 20, 2006

Good Morning Seattle

Spent most of this evening working with Mike on our presentation for when we present our Shoechicken paper on Friday. It looks like we're going to have about 25 mins in total, but that will include setting up time and questions. We're aiming for the presentation to last 20 mins, perhaps with a few extra slides in there we can skip over if we're low on time. We're estimating that we'll need 23-24 slides; that gives us one per minute but with a few extra as backup incase we fly through them too quickly.

It turns out that we're not staying in the conference hotel. We are within walking distance though, and since UWF is picking up the tab I can't complain :)

Saturday, March 18, 2006

What's the deal with St. Petersburg?

While studying for a statistics test the other day, I came across an interesting statistical paradox (not of my own invention of course). The problem goes as follows. There's a game of chance that you have to pay a fixed amount to play. After paying your fixed amount, the person running the game, let's just call this the casino, flips a coin until the coin lands on tails (or heads, it doesn't really matter). When the coin lands on tails, the total number of coin tosses is used to determine your winnings of $2^n. E.g. if the coin was flipped the first time and it was heads, then heads on the second and third, but tails on the fourth toss then your winnings would be $2^4=$16.

All sounds good so far? Well here's where the funky part comes in. The probability of you winning $2^n is 1/(2^n). This means that when you calculate the expected value of the game, where the expected value tells you how much you are likely to win on average, the expected value is infinity!?! This can be seen as follows
# tosses (n)WinningsProbabilityExpected Payoff
1$21/2$1
2$41/4$1
3$81/8$1
4$161/16$1
5$321/32$1
............
n$2^n1/(2^n)$1

Now, if you consider that you could be lucky enough, or not, that the coin would keep coming up heads indefinitely you could win an indefinitely large sum of money. This means that to calculate the expected value of the game, we must sum the expected payoff from each possible outcome, namely sum(2^n * 1/(2^n)) where n=1,2,3,... As can be seen from the table this is sum(1) n=1,2,3,... which is infinity. This means that whatever fixed amount of money one has to pay to get in on this game, you should always do it.

Of course this isn't right, we know this intuitively as the odds on getting 5 heads in a row is pretty remote. There is a great website that simulates this game
http://www.mathematik.com/Petersburg/Petersburg.html

A few people have proposed solutions to the paradox. The first was Bernoulli who proposed that the value of money decreases logarithmically with how much you have. That the difference to between having one billion and two billion is realistically less than the difference between one billion and one million. This doesn't solve the problem however as the winnings can be altered to increase to cancel the logarithmic decrease in the value of money. The other proposed "solution" is that no casino has an infinite amount of money to give you, the game has a maximum winnings. Capping the winnings does fix the problem, but you almost get the sense that this is somehow cheating a little.

Here are some great links for a much more in depth (and prettier) analysis of the paradox:

http://plato.stanford.edu/entries/paradox-stpetersburg/

http://en.wikipedia.org/wiki/St._Petersburg_paradox

Tuesday, March 14, 2006

Appearances can be deceiving

I was thinking about the NP problem of Satisfiability today. I remember my first instinct with the problem being that it would seem impossible for this problem to be in P. How on earth could you know whether any truth assignments would satisfy the boolean expression without trying them all? But I remember having similar thoughts about problems such as the subset sum problem; and although it's still a mystery as to whether it's in P, techniques such as dynamic programming bring it pretty close.

I guess what I'm trying to say is that I've typically been a P != NP guy, but for a brief moment today I crossed the divide. I really started to believe that maybe all we're missing is some simple trick that'll change everything. Now that yesterday has become its tomorrow, I'm beginning to come out of my stupor. However, the doubt appears to have been sowed and the romantic in me is kind of glad.

Sunday, March 12, 2006

Murky waters

I heard an interview with a Palestinian on the Bush administration's halting non-humanitarian aid pending further review. The Palestinian felt that the Bush administration was being hypocritical by encouraging democracy in the middle east, but then not liking its result. His comment kept me thinking most of the way into work, I'm really quite torn on the issue. I understand the guys stance to a degree. The west wants democracy, Palestine has democratic elections and then we refuse existing aid because we don't like who the Palestinians' picked as leader. However, this seems to be an oversimplification. Yes it is wonderful that Palestine had free and democratic elections, but isn't that the point? It's not as though the Bush administration made a shock move by stopping the aid, it's part of US law not to fund terrorist groups. The Palestinian people should have, and if they didn't could have, known this and factored it into their decision. This could be thought of as a form of bribing the voters, but if Hamas is who the Palestinians think will lead them to prosperity then they must factor in that Hamas will be doing it without much foreign aid.

I feel an analogy can be drawn with the private sector funding research projects. Company X can offer a great deal of money to anyone who wants to do research in a particular area. Researchers can either work in that area knowing they'll be well funded, or if it's not what they want to research then they accept the funding risk and/or try to find funding elsewhere.

If Hamas wants to not accept Israel then that's their choice. If the Palestinian people agree with Hamas, then that's their choice. But, they also have to accept that it doesn't fit with a typically accepted world view and work with what they have.

Saturday, March 11, 2006

Falling in love

Falling in Love

Well I've fallen in love again (no not with another woman, very much in love with my wife!), and JUnit is the object of my desire. I remember being skeptical about using unit testing on a project. I had all the typical concerns about how much it would slow me up and whether it would be worth all the extra time. Ladies and gentlemen, it's been worth every ounce of effort.

I got to a point in developing where I was sick and tired of buggy code. Tired of doing a demo and something breaking, or changing a seemingly innocent isolated piece of code and then finding out much later on that I'd broken some obscure feature. I don't consider myself a bad programmer in the sense of writing typically unstable code, but something had to change. Enter unit testing.

I've been using my Shoechicken project (http://www.shoechicken.com), as my first testbed for unit testing. I decided that if it worked well for Shochicken, I'd start looking into using it elsewhere. Well I have to say that Shoechicken has benefited wonderfully from our ever growing set of tests. Not only do I feel much more confident about code I write, but I feel more confident in refactoring and improving older code as the unit tests provide a good indication of whether all is well with the chicken. I do feel that the unit tests slowed me down, there's no real way that doing extra typing isn't going to. Where I feel I've actually saved time is in code maintenance and bug tracking.

Bottom line is that I recommend unit testing to anyone who's interested (and those who aren't.)

Sunday, January 29, 2006

Busy busy busy

Been a busy period for me at the moment. Working full-time, taking three classes, repairing the house, and other family duties certainly isn't leaving much time for play! Luckily the light at the end of the tunnel is shining regarding UWF; although I'm really quite enjoying this semester's classes.

I've been delving into "Artificial Intelligence: Structures and Strategies for Complex Problem Solving" by George Luger. I'd previously been using "Artificial Intelligence: A Modern Approach" by Norvig but thought I'd check out logger's take on things. In particular I'm going over the machine learning section for Shoechicken (http://www.shoechicken.com & http://shoechicken.blogspot.com), and have thus far come up with some great ideas from the text. I hadn't thought about using a genetic algorithm for Shoechicken, but the more I think about it the more I like it. This will become a big source of interest over the next week or so.

At work we've been working hard to get a stable release of MAST (http://mast.ihmc.us) out. We've just switched to using InstallAnywhere and I have to say that I am suitably impressed! It's allowed us to package the software in a very professional looking manner. We'd previously had problems with licensing and using other software; in particular MySQL. Since MySQL is under GPL, although MAST is free to download and use, it's not GPL so were having the user download and install MySQL for the MAST Server. I suddenly had a brainstorm a couple of weeks ago, can't believe I didn't think about it before to be honest, why not switch to another db server????? We only need a lightweight SQL database and all database traffic goes through a proxy. We have now switched MAST over to use Hsqldb (http://www.hsqldb.org) and can report that life is gooooooood. We now have everything we need packaged with the installation, so it's just a single download.

We've also been testing, testing, testing, which of course means debugging, debugging, debugging. I think that this is the most testing we've done of MAST all at once. Matteo and I really have brought the product a long way in the last two weeks. The installation procedure has become quite robust, and MAST itself is looking much more stable. Our target is to have a final release out on the web that's been tested by a few different people, so watch this space to find out when it's ready for download!

Saturday, January 21, 2006

Starting on the rating agent and being under the weather

Well, to start with I'm under the weather. Colds are bad! But, through the cold I've managed to be fairly productive for both Shoechicken and my Complexity class. I finished up some loose ends on the Bufunkalo, mostly in reference to the unit tests but there was a little refactoring too. I'm really looking forward to working on the rating agent. I spent such a long time researching how we're going to implement it that it's very exciting to finally delve into the code.

I think I'm going to call it an early night and try and get some rest so ta ta for now.