Monday, June 21, 2010

Exploring Optimization routines in Python: OpenOpt

Scipy comes with a built-in optimization tools in its optimize module but we will sbe using the more modern OpenOpt framework/library with Python. Ubuntu offers two flavors of openopt packages for Python: python-openopt and scikits-openopt and installing one will remove the other package!

OpenOpt has related superb automatic differentiation support in FuncDesigner.

OpenOpt is developed in the Ukraine and its homepage is at http://openopt.org.
It now finds wide adoption and widespread applications.From its Applications page, we see the following:

       
  • Small Aerial Vehicle Trajectory Planning; University of California, Berkeley, & University of Waterloo (pdf)
       
  • sagemath.org, SAGE - a viable free open source alternative to Magma, Maple, Mathematica and Matlab
       
  • pymvpa.org (Multivariate Pattern Analysis)
       
  • PythonXY (www.pythonxy.com)
       
  • Carnegie Mellon University started to teach students OpenOpt
       
  • simplemax.net online services
       
  • enthought.com repository and educational courses . The Enthought guys are very smart! - they ignored to answer my email with proposition of collaboration but involved my soft without even notification to me.
       
  • Measuring Inconsistency in Probabilistic Knowledge Bases; Technische Universitat Dortmund, Germany
       
  • Bayesian Inference Package (probabilistic calculations), Gulbenkian Institute of Science in Portugal
       
  • IdentiPy, parameter optimization and inverse problems for materials computation
       
  • Multiple-Shooting Optimization using the JModelica.org Platform; Lund University, Sweden
       
  • Optimal design of complex energy facilities (Ukraine, pdf, no English translation is available)


If you are a Ubuntu user, then installing openopt is a snap. The version I have is  

Importing openopt in ipython, we see that applying the dir() function provides the following major classes/routines:

'CDFP', 'CGLP', 'CLLAVP', 'CLLSP', 'CLP', 'CLUNP', 'CMILP', 'CMINLP',
 'CMMP', 'CNLLSP', 'CNLP', 'CNLSP', 'CNSP', 'CQP', 'CSDP', 'CSLE', 'CSOCP',
 'DFP', 'GLP',  'LLAVP', 'LLSP', 'LP', 'LUNP', 'MILP', 'MMP', 'NLLSP', 'NLP', 'NLSP', 'NSP', 'OpenOptException',
 'QP', 'SDP',  'SLE', 'SOCP'

Problem classes which may be solve by OpenOpt are the following:


Problems
DFPDataFit Problems
GLPGLobal Problems
LLAVPLinear Least Absolute Value Problems
LUNPLinear Uniform Norm Problems
MINLPMixed Integer Nonlinear Problems
MMP    MiniMax Problems
NLLSPNon-linear Least Square Problems
NLPNon-linear Problems
NLSPNon-linear System Problems
NSPNon-smooth Problems
QPQuadratic Problems
SDPSemi-Definite Problems
SOCPSecond Order Cone Problems


To be continued!


The version Ubuntu installs is .27 when the latest is .29!

We install FuncDesigner separately as it is not in any Ubuntu repository.


This is article is an introduction. We will expound further each important feature of openopt when we have the free time.


Our most pressing application is to use openopt to determine the parameters of an ARMA process. Stay tuned.

You can easily install 3 packages openopt, funcdesigner and derapproximator by typing


sudo easy_install openopt
sudo easy_install FuncDesigner
sudo easy_install DerApproximator


I thought it would get the latest versions. Not!

This set of packages will sure to invite some people who pine for Matlab but cannot afford the hefty price tag!

Sunday, June 20, 2010

Spyder, a new interactive Scientific Python development Environment

Flash! June 26: Latest 1.1.0 version just released! visit latest spyder console



There are more development environments for Python coming into use. What is wrong with TKinter, Eric 4, geanny, even Eclipse? Nothing wrong with these but Python developers will finally choose what suits them personally. Tkinter, I find a little slow, Eric is the best so far but I lose some of my work sometimes(It pays to save your work from time to time)! Geanny and Eclipse actually works for other languages. I suggest you give each editors/environment a try!

The newest I found is Spyder, available from http://code.google.com/p/spyderlib/downloads/detail?name=spyder-1.0.3-py2.6.eggand developed by Pierre Raybaut. When I downloaded it, the egg file was stored in /temp not in ~/Downloads. You type sudo easy_install spyder-1.0.3-py2.6.egg from the command line.

Once you activate it, you will be presented with multi-paned windows for file, classes and functions, Workspace,and Interactive Shell. It has a debugger and an interface to Pylint for your source code. There is also a convenient Tools submenu for Qt Designer and Qt Linguist.



It will take time for me to be familiar with it, and I think its major competitor will be Eric which is also a Qt application.

Try it and submit comments about your experiences with Spyder. The free and open source world depends so much on feed back from users. We hope that Spyder and Eric developers will learn from each other!