I am a fan of the Julia language. Tremendously powerful analytical environment, compiled, high performance, easy to understand and use, strongly typed, … there’s a long list of reasons why I like it. If you are doing analytics, modeling, computation in other languages, it is definitely worth a look. Think of it as python, compiled, with multiple dispatch and strong typing … and no indent-as-structure problem.
My Julia fanboi-ism aside, there was an interesting blog post about using JuMP, a linear programming environment for Julia. I’ve not done much work with linear programming, or mixed integer programming, so I read it hoping to learn about it.
As with articles like this, I learned new things about Julia in the process, specifically about a number of packages I’d not known about before, and capabilities that they add.
While I am always grateful for another opportunity to learn something, I found the presentation to be quite … well … humorous.
2353 grams Tea, regular, white, brewed from leaf or teabags, with cows milk not further defined
32011 grams Water, rainwater or tank water
148 grams Milk, almond, fluid
2848 grams Milk & water, skim cow’s milk & tap water
Firstly, it is suggesting dringking 32L of water in a day. Why is that? This is because water has basically no nutritional impact to our constraints, so it can take almost any value. To solve this, a simple trick is to add a small factor to out objective, saying ???All other things being equal, a diet with less total mass, is better???. This can be done by adding a term + 0.01sum(diet). The 0.001 is small enough that it shouldn???t impact the true objective much.
Secondly, it recommends drinking over 2 kg of tea, and 2 kg of watered milk. That is pretty boring, so lets add a constraint that one shouldn’t ever consume >500gram of the same item.
Yes, the solver suggests drinking 32kg of water, 2kg of tea, and almost 3kg of watered down milk.
For those who don’t quite remember, 1kg is about 2.2lbs, so 32kg is north of 65 lbs of water. Per day.
But wait … there’s more!
The author attempts some sanity constraints in addition to the nutritional guidelines, like reducing moisture. And then they get this:
500 grams Salt substitute, potassium chloride
1 grams Salt, flavoured
500 grams Cream of tartar, dry powder
2 grams Caffeine
13 grams Calcium
8 grams Fibre
500 grams Folic acid
9 grams Iodine
500 grams Thiamin
Oh dear …
It keeps going from there. The author did include a disclaimer about trying any of the diets … basically … don’t. Check with your Dr first for any diet. Especially if you think you need to eat 1/2 kg of KCl, or cream of tartar …
While it was funny to a degree, I did enjoy the tutorial on JuMP, and the capabilities of Julia.
Viewed 32884 times by 6087 viewers