|
OR/MS Today - December 2004 Software Review Mathematica 5.1 Additional features make software well-suited for operations research professionals. By ManMohan S. Sodhi In the December 2003 issue, I reviewed Mathematica 5 from operations research professionals' viewpoint [1]. I wrote how version 5 is compelling for O.R. professionals who may have been intrigued by Mathematica software in the past but did not consider it useful for their profession, at least not over the numerical and statistical packages they already use. I was initially hesitant to review version 5.1, but the additional features in terms of the Internet, graphical user interface (GUI) development, and data handling and visualization alone can be considered as a major upgrade in contrast to what the version increment would suggest. Version 5 had introduced advanced numerical analysis, linear programming interior point as well as simplex method variants and sparse matrix manipulation with fast algorithms that compete with dedicated numerical software tools. Previous versions already had probabilistic and statistical functions and calculations, nonlinear algorithms and combinatorial calculations, so version 5 offers many features to interest O.R. professionals. Version 5.1 has many new features as listed at the Wolfram Research Web site (www.wolfram.com). This is a long list divided into enhancements for numerical computation, symbolic computation, language system, etc. However, I will focus on the added Internet, GUI and data handling features. Included in version 5.1 is the GUIKit that allows a user to create a GUI running on top of Mathematica for other users to do specific things. You can access Web services offered by other providers from within Mathematica and use the offered functionality as a Mathematica function. Data in spreadsheets (MS Excel) and databases can be directly accessed and drawn/analyzed in more ways. For the numerically inclined, piecewise functions have been introduced. Mathematica 5.1 allows users to query a Web site for the available services and to use these services as Mathematica functions. The functionality includes:
As an example, here are the Mathematica instructions to convert Hindu-Arabic numbers into Roman and vice versa in Mathematica 5.1 along with the output of each step:
Now, let's find out the price of "Linear Programming and Extensions" by G. Dantzig and M. Thapa (Princeton University Press, 1998) at Barnes & Noble prices (U.S. dollars) assuming we already know the ISBN number 0691059136. The sequel is "Linear Programming: Theory and Extensions, Vol. 2" (Springer, 2003) with ISBN 0387986138, so we can check the price for that one as well.
While these are simple examples for illustration, there is no reason why a linear programming Web service cannot be available at site like NEOS. Such a service would allow you to send an AMPL or XML file(s) with the model and data and obtain the solution as XML or other output. Also, Mathematica 5.1 has enhanced string manipulation capability so you may be able to do more with the results you get from a Web service. Allowing Web services to be used as Mathematica functions becomes increasingly important as many providers start providing information as Web services. In that case, you can try out the functionality within Mathematica first, even if your application is not going to be created within Mathematica.
As the name suggests, GUIKit is a kit for building user interfaces and has been built with Java. Simplistically speaking, Mathematica is a command-line-oriented software. This means invoking functions with many parameters. Say you want students to experiment with a particular function as to how it changes shape with different parameters. They would have to define the function and then repeatedly invoke and draw that function with different parameters. Or, in a work situation, say you want traders or engineers to do what-if analysis in a program you wrote in Mathematica. It would not be straightforward unless you wrote an interface in some other language or package and invoked Mathematical from that program. With GUIKit, you can keep everything within Mathematica. Some examples exist within Mathematica. One is a general-purpose calculator in which you can enter Mathematica expressions as arguments to produce the sum, difference, product and quotient. You would invoke it as follows:
This gives the user an interface in which to enter arguments and see the results (see Figure 1).
Another example is provided on their Web site for building a GUI to generate a random number with the click (see Figure 2). The "code" for this is:
Mathematica 5.1 comes with some serious applications already built in. For instance, there is the Equation Trekker that allows you to define-graph-and-view solutions to differential equations. With GUIKit being built using Java, you can access the entire Java component and class library, but you will likely not need to do so. More information about the GUIKit specifically is available at www.wolfram.com/guikit. As Mathematica runs on many platforms, your GUI program can run off multiple platforms as well without having to tweak the code as can be the case with Java itself [2]. A GUI application built using GUIKit can be run within Mathematica or as a stand-alone application that launches the necessary Mathematica kernel either on the same machine or on the network for the required computations.
In my previous review I had given an example of the "MatrixPlot" function within Mathematica to help visualize the structure in terms of non-zeros of large sparse matrices. For large matrices, MatrixPlot only samples elements (using some heuristic for "optimum" visibility) to display the structure (see Figure 3). The instructions I used are:
where A is a sparse matrix comprising the coefficients of the Netlib problem boeing1 obtained as above.
Now, what if you wanted to check if the coefficient array of your large linear programming problem has incorrect coefficients? With the new function "ArrayPlot," all the elements of an array are checked to see if they are non-zeros before displaying the non-zero structure. These are the instructions I used within Mathematica:
The option of color rules simply makes non-zeros stand out against a white background. The default option is more interesting in that ArrayPlot shows all the numbers in an array in different shades of gray, with the largest (absolute value) numbers being the darkest and the smallest being the lightest. Of course if some of the numbers are very big in the coefficient matrix for "boeing1," then most of the numbers will show up as "white." Using the above options, we see that the matrix structure shown by ArrayPlot (see Figure 4) is the same as that produced by MatrixPlot earlier.
There are additional ways to visualize data. For my money, most notable of the remainder is a package for cluster analysis and dendrograms.
For accessing data from other file formats this could be useful if you are using software already that produces such files the added features include:
My experience with TeX was rather mixed. You can use File-Save_as_Special from the menu for Mathematica 5.1 to generate the equivalent AMS-LaTeX file. However, you will likely have to hand-edit the generated files before compiling using a TeX compiler to get desired results. (Mathematica does not come with a TeX compiler, but there are many available in the public domain and for sale. I used TrueTeX that comes bundled with Scientific Word from TCI Software Research.) Importing a mathematical LaTeX expression is easy. You simply cut the expression from a plain text file with the expression and then paste it into a Mathematica cell for it to show up in the expected graphical notation. However, reading in a whole LaTeX article using File-Import simply reads in a .tex file as a plain text file without showing the mathematical expressions in graphical form. So my expectation is that you can move mathematical TeX expressions back and forth between Mathematica 5.1 and plain text LaTeX files, but that is really it for now. Regarding Excel, although you can import .XLS files (using the Import["filename.xls"] command), you should consider using comma-delimited files (CSV) or text files for import of tabular data rather than MS Excel native format files to get more control. I did not try the other file formats myself, but the list is impressive.
Word Processing (and Typesetting) As I had mentioned without testing in my previous review, you can write an article in Mathematica because you can type in a rather impressive array of mathematical and Greek symbols that are displayed as such. Also, the cells can be used for "outlining" in word processing packages and therefore help you organize your thoughts. A minor improvement since then has been that Mathematica 5.1 can read TeX expressions. If you copy and paste a TeX expression into Mathematica, it will show up as a Mathematica expression. Even older versions used to allow export of Mathematica expressions to TeX, so the functionality is more symmetric now. However, this does not mean you can read in an entire TeX file or vice versa, at least based on my experience as I recounted above. A major improvement on this front unfortunately resides outside Mathematica: Wolfram now sells another software called Publicon 1.0 for the Windows and Mac OS X platforms only. While I am not reviewing this software here, I can mention that Publicon is intended for the scientific and technical publishing community. The native format is still Mathematica's notebook, but you can export the entire contents of a file as a TeX file. (I was also able to read the .tex files generated by Publicon in Scientific Word, something I was not able to do with the .tex files generated by Mathematica 5.1.) For Mathematica users, Publicon would be a natural word processor for all documents for which these users would have otherwise used TeX or LaTeX. But even non-Mathematica users will find Publicon quite intuitive, and you get the typesetting power of Tex/LaTeX with the GUI of Publicon. Refer to Wolfram's Web site for details on Publicon. The second is that it provides more reasons for staying within the Mathematica environment regardless of where the data resides. There is a tremendous range of sources of data the Web, SQL databases, binary files of various types and Mathematica 5.1 lets you access these sources in a straightforward manner. Still, although the rewards can be high, learning to use the software naturally (as opposed to a one-off) requires a serious commitment and investment of time. I wish I could do all my word processing and spreadsheet within Mathematica as well, so it could be my one piece of software other than e-mail. You can already do presentations from within Mathematica, and there is new database functionality in 5.1. With GUIKit, perhaps an "office suite" for the technical user is not too far in the future!
References
ManMohan S. Sodhi is a member of the operations management faculty at Cass Business School in London. He is also the software review editor for OR/MS Today. OR/MS Today copyright © 2004 by the Institute for Operations Research and the Management Sciences. All rights reserved. Lionheart Publishing, Inc. 506 Roswell Rd., Suite 220, Marietta, GA 30060 USA Phone: 770-431-0867 | Fax: 770-432-6969 E-mail: lpi@lionhrtpub.com URL: http://www.lionhrtpub.com Web Site © Copyright 2004 by Lionheart Publishing, Inc. All rights reserved. |