Python memory management 101 July 12, 2010Posted by CK in Software.
Tags: Memory management, Python
add a comment
>>> a = 1
>>> b = a
>>> b += 1
>>> a = 
>>> b = a
Same for custom classes/objects.
Technically it makes sense, of course, to avoid deep-copying. On the other hand, it may be counter-intuitive in cases like this:
>>> a = 2 * []
It took me a minute to recover and realize, that statement
a = 2 * [] does not create 2 different lists within “a”, but rather 2 references to the same list.
PuLP modeler June 12, 2010Posted by CK in Research, Software.
Tags: CBC, COIN-OR, CPLEX, GLPK, Gurobi, MILP, Optimization, PuLP, Pyomo, Python, SCIP
add a comment
I have to solve some optimization models, and looked out there for relevant tools. Solvers is one thing, and there’s a number of options depending on the money you can(not) spend, your requirements, etc. Modelers is another game though, and it took me some time to decipher the various options. What output (i.e. solver input) they can produce, by which solvers this input can be used, if there are converters, etc.
Eventually I went with PuLP, and do not regret it so far. It supports GLPK, COIN-OR, Gurobi and CPLEX. That’s basically all the solvers I wanted to test my models with (except for SCIP, which however I had terrible problems installing and I skipped it).
PuLP installation on the MacOS was as easy as “easy_install pulp”, and then it just worked. From a modeling perspective, I don’t find it to be very intuitive, but it does the work nevertheless, so I can’t complain. The fact that modeling is done in Python code is of course the greatest advantage. As a PuLP rookie, I had the first model ready and running in less than two hours today (including fixing a nasty bug in my code). There’s one more open-source, python-based modeler, Pyomo, but it supports less solvers (although I understand they’re working on it).
Finally, since we’re at the topic of optimization problems and solvers, maybe you’re interested in some recent benchmarks I came across. I was mostly interested in COIN-OR’s CBC, Gurobi and CPLEX, all for (mixed) integer linear problems. You can find them here and here.
Clojure November 6, 2009Posted by CK in IT, Software.
Tags: Clojure, Jython, Languages, Programming, Python, Scala
1 comment so far
Even before I actually study it in detail, Clojure becomes my latest fixation. A Lisp-based functional, general-purpose language, which produces JVM bytecode and has access to Java libraries? Sounds like a dream come true. I never liked Java, and as a matter of fact, I consider myself a Java-dyslexic. No matter how much I tried in the past, I never got around learning enough of it to use further than “Hello, world”s. Its syntactic resemblance to C, with which I am (was?) quite proficient, didn’t help much. Nevertheless, the breadth and depth of libraries that exist in Java are mind-boggling, and the ability to use them with a different language is just great. I know there are other JVM-based languages, e.g. Scala, but somehow after reading introductory material they never enticed me enough. Also, I really don’t know how come, although a big fan of Python I never tried Jython. I assume I just preferred the real thing — Python also has an extensive and compelling set of libraries.
In any case, I’ll try to get a closer look at Clojure and come back with a more complete opinion.
Python is like cycling May 15, 2008Posted by CK in IT.
Tags: Google Translate, Languages, Python
add a comment
So I’m here in Dortmund for the third day now, and I can tell you that if I didn’t have the help from my local colleagues, it would be totally impossible to get by without speaking German — at least for this first batch of paperwork and house hunting. In the process of looking for a flat to rent, I have been searching in newspapers and web sites, all of which are in German. How to deal with that?
Enters Google Translate. Very efficient and quite correct, as it turns out. But then again, opening a browser and clicking on a bookmark etc all the time is a bit of a hassle.
Enters Python 🙂 My bias towards this language is well known to those who have been working with me in the recent years. I haven’t really written any real code for a long time now, more than 4 years actually, but in less than 30 minutes (also putting WebScarab in use, I managed to have a simple but fully functional command-line client for Google Translate in place.
Clearly, Python is like cycling; Once you learn it, you never forget it.