#RHoKSoton is going to rock!

In 30 minutes we have the #RHoKSoton pre-RHoK Event social gathering in a nearby pub. Tomorrow morning we will join 30 worldwide locations and 3000+ participants to work on a number of challenging problems for the good of humanity and the environment. This is the first time RHoK is organized in this part of the UK and we are the only event in the UK this round!

Its been a lot of work getting this organized and not everything will be perfect, but all I can say is….

Image

You can watch everything live on our ustream channel.  Many thanks to our sponsors for helping to make this happen:
 

 

 

–Dirk

Random Hacks of Kindness in Southampton!

The gist: RHoK is great, come present your problem, or come learn something new or come sponsor a prize. But above all, come have fun! (June 2-3).

Twitter hashtag: #RHoKSoton

In one of my previous posts I talked about bringing engineers and computer scientists  together who were interested in helping to solve problems related to humanity and international development.

Well, we haven’t even had our first meeting yet (its this Thursday, 3pm @ UoS, Highfield campus, staffclub, if you want to come along) but Im already very happy and proud to say that we will be having our first event in 3 weeks time: During the weekend of 2-3 June 2012, Southampton University will be one of the satellite cities as part of the global Random Hacks of Kindness Event!

Continue reading

Wallpaper and thoughts on higher education

Note: this post is a bit of a ramble and was stuck in my drafts folder for a month before I decided to just post it. So bear with me :) but I still welcome any comments or ideas.

A tweet from a few days ago alerted me of Sal Khan‘s appearance on the CBS show 60 minutes to talk about Khan Academy.  I first heard of Khan Academy almost two years ago and remember watching a few movies and being quite impressed.  I have a great respect for people who are able to explain a complex topic in a lucid manner, breaking it up into logical pieces and linking it to things the learner already knows about.  Its the challenge I enjoy most when teaching.

I also believe that education and critical thinking (or rather the lack thereof) lies at the root of many of the world’s perils. Just imagine a well educated mass with a good background in history and science (to name just two disciplines). The politicians, televangilists, and those selling homeopathic ailments would be shaking in their boots! Of course thats not to say knowing a few textbooks will solve all problems, motivation, social status, and other environmental factors all have major roles to play.  But I doubt many would argue with my belief that education is the most sustainable way to escape the poverty cycle and it would give authors of books such as How we know what isn’t so and Why people believe weird things less to write about.

Continue reading

Engineering and Hacking for Humanity at UoS

In my day job Im lucky and happy to be working on cool UAV technology for civilian applications, in particular our research focus is on search and rescue.  While Im still not totally clear about what I want to do beyond my current contract I have always had an interest in helping to tackle humanitarian problems through engineering and technology (e.g., my recent RHOK event attendances).  I was born in Burundi and grew up in various countries around East Africa.  Experiences that have definitely left their mark and part of the reason I am writing this post.

Continue reading

Another successful UAV flight test

One of the greatest things about this job is that a couple times every year we head out to the airfield and test if the aircraft (a UAV) we have been working on will fly.  Below two videos shot a couple of days ago. The civilian mission it will be used for is still hush-hush but it flew beautifully :)

Note the gimbal camera under the nose (orange dome) which can automatically lock onto a given object while flying.

–Dirk

The researcher programmer, a new species?

Update: There has been some good discussion on this post at the LinkedIn group on Scientific Software Development and Management.

Update 2: See also the papers by Victoria Stodden and the great complmentary article by Ilian Todorov.

Last week I attended the 2012 Collaborations Workshop at Queen’s College in Oxford. Organized by the Software Sustainability Institute its goal was to bring together software developers and researchers and relect upon how both groups interact and if anything needs to be changed.

I only found out about the two day workshop and the existence of the SSI a few weeks before but immediately signed up. It was the first time I attended a conference so relevant to my own position and work. There were about 50 attendees, all in a similar position: PhD degree, working in academia or research lab, strong computational/software skills and working closely with researchers from at least one other scientific field (with a strong representation from biology/chemistry).

The conference went very smoothly, expertly managed and organized by Simon Hettrick and Neil Chue Hong. There were hardly any conventional talks, rather lightning talks and a whole series of break-out sessions which resulted in a lot of interesting discussions. One of the fundamental problems that kept coming up was the problem of defining ourselves as a group. What kind of species were we?

Continue reading

TEAtime

A few months ago an email was sent out to all researchers here at the university to solicit volunteers to give lectures/workshops for visiting secondary schools, the TEAtime lectures.  As I always enjoy this kind of outreach I volunteered, went through some info sessions and did my lecture yesterday.  Basically I gave an overview of UAV technology and did a simplified walk through of the aircraft design process.  It was a bit ironic though, a computer scientist explaining airflow and aerodynamics :) .  No slides on slideshare as they’re too big to upload and Im to cheap to pay for PRO :) .

Continue reading

SMuRF and thoughts on multidisciplinary research

A few weeks ago I attended the Southampton Multidisciplinary Research Forum or SMuRF for short.  Graciously organized by a number of volunteers the aim of the two day conference was to bring together researchers from a wide range of disciplines and encourage multidisciplinary thinking and collaboration.

Continue reading

Bridging Python and Matlab: Passing callbacks and optimization

This blog post is about a bridge I created that allows you to pass callbacks to Python functions directly to Matlab code without having to resort to things like sockets or COM.

Background

Designing our UAVs involves a number of different codes that interact & must be coordinated to solve what is essentially a Multidisciplinary Design Optimization (MDO) problem.  One of those codes is written in Python and involves a constrained optimization problem of the following kind:

Find the minimum of a problem specified by

xbbeqlb, and ub are vectors, A and Aeq are matrices, c(x) and ceq(x) are functions that return vectors, and f(x) is a function that returns a scalar. f(x), c(x), and ceq(x) can be nonlinear functions.

In our case we have 10 variables (x has length 10), 28 nonlinear constraint functions c(x), 4 nonlinear equality constraint functions ceq(x) and box constraints on most variables.  The objective function f(x) and all constraint functions are pure python functions.

Thus to optimize f(x) you need an optimizer that can handle python functions, and for that there is the excellent openopt library.  This is what I did and after trying out the different NLP solvers I settled on the scipy_slsqp solver for most runs as it seemed to consistently give the best results.

However, as the optimization problem was tweaked and as we did more runs, we did run into cases where it would not solve and the aeronautical engineers I work with were not always happy with its robustness.  Also nobody had ever worked with the openopt library but everybody knew and trusted the various Matlab solvers.  Besides, us being part of the Computational Engineering Design Group, a number of powerful in-house Matlab solvers had been developed and were available to me.  Thus, the least I could do was to try to use those and see if that improved anything.

Python-Matlab bridge

So I started searching the web for tools / libraries that allowed me to bridge python/Matlab, specifically tools that supported passing callbacks between the two languages.  A promising project seemed mlabwrap but while it was great for evaluating Matlab expressions,  it does (at the time of writing) not support callbacks.

In the end I decided to see if I could scratch my own itch.  I really did not want to deal with sockets or any kind of network protocol and I also wanted the solution to be crossplatform, so no COM.  Since both Python and Matlab have well documented interfaces with C/C++ code, that seemed to be the way to go.

So I sat down with the ctypes & mex documentation and with a little help from Mathworks support was able to cobble together a simple example using fminsearch.  By the way, I had never done any Python – C work before, but ctypes is awesome and a joy to use.  The little trick to make it all work is that you just have to treat the function handle as an integer (it’s just a memory address after all).  Then all you are really doing is passing an integer around which is straightforward.

With fminsearch working the goal was to extend to fmincon since that would give us all the basic functionality needed.  This took a bit of debugging and deciphering Matlab crash dumps but I finally got it working.  The final flow of events looks like this:

You start off with writing a matlab file that wraps the optimizer you are interested in (in this case fmincon) and exposes its signature.  This m file forwards all function handle arguments to a mex file which converts the integer to a function pointer and calls it.  This is how we get the callback to a C function.  A simple bridge library is then needed which is loaded by ctypes and converts the arguments into something the Matlab shared library file understands.

From my initial tests I see it is finding the same optima as scipy_slsqp was using openopt. Now I just need to do more extensive testing to see if performance is any more robust. After that I can start looking into the other solvers provided by Matlabs optimization toolboxes as well as our own solvers.

Source code

All the code is available on github.  I hope it is useful to somebody and I’d be very happy to receive patches or improvements.  I guess this may even be of use to the mlabwrap / openopt projects.

–Dirk