Speeding up Mosel code – the sum operator

For those of you who don’t know, Mosel is the programming and modelling language that ships with FICO’s Xpress math programming solver. And if you don’t already know what it is, the rest of this blog post won’t be of too much interest – I would advise a cup of coffee, a stretch and a good eye-relaxing look out the window instead. But, for those of you that do use mosel, keep reading.

At Optimeering, we don’t actually use mosel much any more – pretty much all our modelling work is now done in python, including all our math programming modelling. However, when we were using mosel, we noticed a few issues with speed – particularly, how you use the conditional operator has a big impact on execution speed. We first really experienced this in the early prototyping of the PUMA model – the model’s datasets can get pretty big, and issues like this were very critical to good model performance.

So, last year we published a working paper within the PUMA project, with code, that explains things in detail and makes some recommendations regarding how you should use the conditional operator. I thought it was about time I made it available here – download and disseminate away!

Leave a Reply

Your email address will not be published. Required fields are marked *