Next: Integrated Model Estimation and
Up: Key Features of OPUS
Previous: Key Features of OPUS
Index
One of the most important parts in the system is the choice of programming language on which to build. This language must allow us to build a system with the above characteristics.
After considering several different languages (C/C++, C#, Java, Perl, Python, R, Ruby) we choose Python for the language in which to implement Opus. Python provides a mature object-oriented language with good management of the use of memory, freeing up the memory when an object is no longer needed (automatic garbage collection). Python has a concise and clean syntax that results in programs that generally are 1/5 as long as comparable Java programs. In addition, Python has an extensive set of excellent open-source libraries. Many of these libraries are coded in C/C++ and are thus are very efficient. There are also several mechanisms for `wrapping' other existing packages and thus making them available to Python code.
Some of the Python libraries used by OPUS as building blocks or foundational components are:
- Numpy: an open-source Python numerical library containing a wide variety of useful and fast array functions, which are used throughout Opus to provide high performance computation for large data sets. The syntax for Numpy is quite similar to other matrix processing packages used in statistics, such as R, Gauss, Matlab, Scilab, and Octave, and it provides a very simple interface to this functionality from Python. See http://numpy.scipy.org/ for more details and documentation.
- Scipy: a scientific library that builds on Numpy, and adds many kinds of statistical and computational tools, such as non-linear optimization, which are used in estimating the parameters for models estimated with Maximum Likelihood methods. See http://scipy.org/ for details.
- Matplotlib: a 2-dimensional plotting package that also uses Numpy. It is used in OPUS to provide charting and simple image mapping capabilities. See http://matplotlib.sourceforge.net/ for details.
- SQLAlchemy: provides a general interface from Python to a wide variety of Database Management Systems (DBMS), such as MySQL, Postgres, MS SQL Server, SQLite, and others. It allows OPUS to move data between a database environment and OPUS, which stores data internally in the Numpy format. See http://www.sqlalchemy.org/ for details.
- PyQt4: a Python interface to the Qt4 library for Graphical User Interface (GUI) development. This has been used to create the new OPUS/UrbanSim GUI. See http://www.riverbankcomputing.co.uk/pyqt/ for details.
Python is an interpretive language, which makes it easy to do small experiments from Python's interactive command line. For instance, we often write a simple test of a numarray function to confirm that our understanding of the documentation is correct. It is much easier to try things out in Python, than in Java or C++, for instance.
At the same time, Python has excellent support for scripting and running batch jobs, since it is easy to do a lot with a few lines of Python, and Python `plays well' with many other languages.
Python's ability to work well for quick experiments, access high-performance libraries, and script other applications means that modelers need only learn one language for these tasks.
Opus extends the abstractions available in Python with domain-specific abstractions useful for urban modelers, as described below.
Next: Integrated Model Estimation and
Up: Key Features of OPUS
Previous: Key Features of OPUS
Index
info (at) urbansim.org