Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Monday, 31 August 2009

Reflections on software desing

Last week I spent lots of time tweaking the user user interface of my other project according to Cooper's principles. Interaction design is fun if you are a designer and NOT fun if you are a programmer, so it is useful in the sense that it helps you get away from the “this will take ages to implement” way of thinking. It is amazing how tempting it is to ignore what the user needs and do it your way, the way it is easy to code. Here is a simple example: to go back to the main menu, you have to click File> Back to main menu. Makes sense, doesn't it? Well, apparently not- I had three different people telling me on three different occasions that they would very much like to see a Back button on the screen at all times!!! Funny thing is, those modern GUI builders let me do this minor change it less than a minute, and I still resisted it until my boss came over and “commanded” me to do it. And this is just the tip of the iceberg- the whole program makes perfect sense to me, since I designed it and implemented it. But to anyone else, it is just an comprehensible collection of buttons. This is what Cooper calls “the dancing bear” paradox. Imagine you want to go to a dance festival. But then you see one of those dancing bear. Do you just walk past and go to a proper dancing event, or do you start giggling and watch the bear's performance? If the bear is a computer program, the average user would just walk past- yes, it is cool that it can move in such an unusual way, but this is not what I wanted in the first place! And then there is that group of enthusiasts, who will stick with the most horrible product simply because it allows them to do something new, no matter how hard it is to use. The third group consist of those who are already more or less skilled computer users, who are too used to the crappy software to simply switch to another product. This is clearly not the way things are supposed to be. Computers are tools, a means to a goal, not a limitation. The problems we all tackle on a daily are hard enough even without software getting in the way. That is why developers should resist the temptation to do it “the convenient way”, to re-use code (despite all the benefits of that) and forger the famous “If it ain't broke, don't fix it” principle.

Next time, an extension to the Cooper model of computer users.

Thursday, 27 August 2009

Science is cool- part 2

I am beginning to enjoy this even more and moreeeee! Got around the generation problem, wrote another couple of pretty standard procedures (e.g. finding the size of the largest connected component) and now to the pen-and-paper job. After two whole days of “hm, how do you describe love with an equation” I finally got to an answer, and we all believe it is correct! It is a system of 6 non-linear simultaneous equations, which , unfortunately, proved to be analytically intractable. Again, I went to consult a specialist, and he recommended the Broyden method, which supposedly generalises the secant method for N-dimentional space. Without going into too much detail, it is supposed to find a solution relatively quickly. However, with some manual work the system is easily reduced to 2 equations, and given the limited domain of the variables ( [0;1], since they are probabilities ), made me think GUESSING is the best option. Even if I had to linearly iterate over all possible combinations of value, it would still take only a million steps (for accuracy of three decimal places), which on a modern computer is...well, insignificant! Of course, being an AI-engineer-to-be, this is not a satisfactory approach, so I went for a technique called simulated annealing. In a nutshell, this is a very basic genetic algorithm inspired by metallurgy and chemistry(look it up yourselves, it takes less time to code than to explain how and why it works).

Next time- a programmer's reflections on software design.

Monday, 24 August 2009

Graph theory and chaos on an extraordinary Friday

It has been such an ordinary Monday it is not worth talking about. On the other hand, Friday, oh we all love Fridays! Nobody really bothers- it is doughnut day, for heaven's sake! So I go with the flow- got to work a little bit late than usual, that is 11 am, and spend half an hour making tea and contemplating on how to improve on a already perfect algorithm. When I finally got to the point where I look at my experimental results, I realized I couldn't be more wrong about it. Thing is, the meaningless combination of numbers I got was supposed to represent a simple graph. Well, almost... it was a graph of some sort, but not a single metric was within 50% of the desired, let alone be a precise match. Here is a bit for the technically oriented among you (please feel free to skip the next paragraph if you are not into graph theory of Java):
~~~~~~ TECHNICAL ~~~~~~
The task is to generate a simple undirected graph with a given degree distribution- initially uniform, Gaussian and exponential, with a potential for easy extension. Also, we should be able to control different graph metrics (mean geodesic path length, clustering coefficient and degree correlation) at least to some extent. My original idea was to generate the degree sequence and construct a graph that corresponds to it. The Erdos-Gallai theorem comes handy here- it provides a necessary and sufficient condition that a sequence of number is a graphic, i.e. the degree distribution of a graph. Problem with that is, I was trying to generate a sequence which precisely describes the degree distribution, and you get stuck somewhere between order and chaos. On one hand, the graph still has to be random, but on the other if you give it “hard” numbers and do not allow fluctuation it is really hard to get anything. Cool, huh? No need to reinvent the wheel though, a quick search and you get your hands on a number of clever AI-inspired algorithms to do the job for you.
Unfortunately, I could not make any further progress on this project, since I accidentally discovered requirements mismatch in my previous project (the programming one). I (very conveniently) ignored the bit that said “let the user play around and interact with the program to see what happens if...” and replaced it with a textual description of the process. Still does the job, but not very educational :D. A bit later on, I realized my listener uses the rather simple SwingUtilities.isRightClick() to decide whether to show the context-sensitive menu or not, BUT there is no such thing as a right click on the Mac. The pop-up trigger is left click with a CTRL_DOWN_MASK bitmask. Well done, Apple, elegant, but don't you think that is convenient to have a normal right click like everyone else does? So right now I have no idea how to get around this little complication, especially given that ctrl+click is already mapped to an action.
~~~~~~END OF TECHNICAL BIT~~~~~~
Apart from that, life is not going bad at all, given that I've been away from my precious girl for six weeks now. Missing her gives me that extra motivation when training, and I particularly need it when I do it on my own. By the way , running is going quite good, I did a total of about 6 kilometres over the weekend and I can feel my getting stronger with every meter. If only English weather didn't have that annoying habit to get in my way all the time!

Thursday, 20 August 2009

Hey, have I ever mentioned how cool it is to be a researcher? Well, it is extremely cool!
So far the project I work on has been all about programming. We were developing an educational tool to help teach maths (more specifically, network theory) to biologists, i.e. people who are supposed to hate it. As you might expect, it's not the easiest job in the world, especially when you work with a team of zero and the schedule is tight. Fortunately, I managed to get my hands on an incredible piece of software, very well thought through, and relatively easy to use and it that save me a lot of time. However, what I did was still a programming job, and as you might imagine, it is not the most fascinating of activities. At this point I ought to make an important clarification-it is quite a pleasurable experience to work (i.e. program) in a team of talented people. Just imagine it: the relentless pace at which ideas are thrown around, the pressure of all those bright minds sitting around you working at full capacity, the devastating feeling you get if your idea is not so great. You have not other choice but to keep up, and it seems like everyone else is doing their best to prevent you from that! If you are the least bit competitive, you will come to love great teams, simply because they are...well... great!

And since I did not get a lot of this, I'm glad the job is done and I can move on to some even more amazing interdisciplinary stuff. The paper is still in preparation, so I'm not allowed to say an awful lot yet, but it is simply great! We are designing a computer model of a complex biological system, which is meant to improve on a previous model. I feels rather good to know that you “correcting” the work of someone who has been around for 40 years longer than you and has published more papers than you can read in a month! Besides, as one of my colleagues said today, change is better than a break. Over the last couple of days I had to go over an awful lot of biological literature, gather ideas, identify other people's assumptions and figure out how to get rid of the biases they've introduced. In the process I got to talk to some very, very interesting and knowledgeable people. For example, did you know that fish shoals have designated “scouts”, who are supposed to swim toward predators and challenge them to give the shoal time to escape? And did you know, that those scouts tend to “hang around” (to the extent a fish can hang around with another fish) with the cowardly fish, but their “real friends” are other bold scouts? So, is science not cool?