|
OR/MS Today - October 2007 Software Review Mathematica 6 'Major' upgrade to popular computational system includes many new features and enhanced ease of use. By ManMohan S. Sodhi In the December 2003 issue of OR/MS Today, I reviewed Mathematica 5 from an operations research professional's 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 over the numerical and statistical packages they already use. Version 5 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. In the December 2004 issue, I reviewed Version 5.1 that had a long list of enhancements for numerical computation, symbolic computation, language system, etc [2]. I focused on the added Internet, GUI and data handling features. The GUIKit allowed a user to create a GUI running on top of Mathematica for other users to do specific things. Mathematica 5.1 gave access to Web services offered by other providers (e.g., Amazon) as a Mathematica function. It also allowed better access to spreadsheets (MS Excel) and databases. Now we have a major upgrade 6.0 (or more specifically, 6.0.1.0) that I tested on Windows XP; it is available for 32-bit and 64-bit versions of Windows variants up to Vista, MacOS 10.4 (Intel and PPC), Linux and various Unix flavors. When I say "major," I really mean that. Installation for 6.0 takes much longer than it did for 5.1 as you quickly find out when you start installing, because the program and the accompanying files are much bigger as is the functionality. The benefit is not only a lot more functionality but also an increase in the ease of use of many of the features introduced in 5.1, for instance by making some GUIs and getting some kinds of financial data transparent without you having to explicitly invoke Web services. Not all functions in notebooks you created will work without modification in fact, Mathematica 6 analyzes any notebook file created by older versions when you try to open to diagnose which function calls need to be modified. The new features are too many to list. I would recommend going to the Wolfram Web site to check these out (www.wolfram.com/products/mathematica/newin6/). Pay special attention to the following new features for operations research professionals: combinatorial optimization, constrained nonlinear optimization, exploratory data analysis, symbolic statistical computing and extended array operations. My review does not cover these; instead it intends to provide a feel of the new version as distinct from its worthy predecessor. Documentation Center. The first thing to notice is "help" has been replaced by the "Documentation Center." As with Web search engines, you now get multiple results for any query you have rather than, as before, having to search among different sources, patterned after the folder structure in NeXT computers (remember those!). Manipulate to Explore. A rather neat feature is a GUI call whereby you can put parameters for a plot in slider bars and just play with these slider bars to see how the plot changes. It is amazing how easily this can be done all it takes is a single function call and how wonderful it can be for teaching purpose or for building intuition. Consider this example. You want to show students how three different two-parameter probability distributions change as you change the two parameters. To vary the two parameters continuously using slider bars, all you need is the following Manipulate call around the usual Plot call that draws the probability distribution. Here we have three parameters for the Manipulate call: the first parameter m, the second parameters s and the distribution itself Normal, Gamma and LogNormal. Figure 1 shows the output: For the continuously varying parameters (2 to 4 for the first parameter and 0.0001 to 2 for the second), we get slider bars and for the third discrete parameter, i.e., the type of distribution, we get tabs. Manipulate[
Data Visualization. One new thing is color schemes such as "PlumColors," "RoseColors," "SolarColors," "SouthwestColors," "StarryNightColors," "SunsetColors" and "ThermometerColors." Rather than choose every color in a multi-color graph, why not choose only a color scheme? Consider the following contour plot of z = x + y*y using the following call: ContourPlot[x + y^2, {x, -3, 3}, {y, -2, 2}, ColorFunction -> "PlumColors", ContourLabels -> True] This produces the results in Figure 2 and if you replace PlumColors by the ThermometerColors scheme, you get Figure 3.
Data Sets. One feature that stands out, something that business school researchers may appreciate even more than their science colleagues, is access to various kinds of data. The data resides on data servers at Wolfram Research so you have to be connected to the Internet for access. For instance, you can get Microsoft's closing stock prices from Jan. 1, 2004 simply by invoking Financial Data with the parameters "MSFT" and "Jan. 1, 2004." Then plot it as follows to obtain the graph in Figure 4 (note also that Mathematica 6 allows you to notate the graph as illustrated in Figure 4): DateListPlot[FinancialData["MSFT",
Your science colleagues will get more data as there are data on quite a few properties of different chemicals. You could look for the list of all chemicals in the dataset that begin with "Kryp," invoking: ChemicalData["Kryp*"] gives you a list ("Kryptopyrrole,", "Kryptocyanine," "Krypton") but not Kryptonite for Superman fans. (Although Krypton is an inert gas, it can form certain compounds that are stable at very low temperatures.) Data residing on Wolfram's data server means they can keep these datasets current. Searches can also be analyzed to figure out which databases are more useful. Of course, you have to live with the unhappy consequence that any search on the Internet for data with a U.S.-based company at least is subject to U.S. government scrutiny recall Google having to share its search data so it would be best to avoid certain kind of chemicals. (Unfortunately, the above three chemicals are suspect from this regard.) Interestingly, there are text "data sets" as well such as the U.N. Human Rights in many languages including English. Calling ExampleData["Text"] lists various text data sets (these reside on the Wolfram data server) and then you can invoke: NotebookPut[ to see all 30 articles of human rights in a separate notebook. The software allows you to obtain all the words as separate elements in a list (or vector) so you can count occurrence of words or do other analysis. I did not test these features, but Wolfram's Web site ("what's new in version 6") promises integrated algorithmic functions for string metrics; nearest-neighbor finding and cluster analysis; integrated HTML import; built-in natural language dictionary lookup; and word properties and connections for "sophisticated natural language analysis." Linear Programming and the Constraint Matrix. Linear programming now has integer programming. As with 5.1, you can call up MPS format files and several MPS datasets for testing can be found by invoking: ExampleData["LinearProgramming"] A number of NETLIB datasets are listed but in my tests, only the afiro data appears to be available on the server (this is the dataset referred to in the software's examples). For this particular data, I was able to import the data, convert to Mathematica's internal (sparse) matrix representation and solve or plot the constraint matrix (Figure 5) to visualize the sparse structure. The documentation center was not very helpful on how to deal with MPS datasets, given that the calls and the procedure have changed since version 5.1. {c, A, b, d} = Import[ "ExampleData/afiro.mps" , "LinearProgrammingData"]; where c is a (dense) cost vector, A is a sparse coefficient matrix, b is the (dense) right hand side, and d are the bounds for the primal variables.
Unlike MatrixPlot, all the elements of an array are checked with ArrayPlot. I invoked it to see all the non-zeros in A (Figure 6): ArrayPlot[A,ColorRules->{0->White,_->Black}]
I would like to be able to create the linear programming data using the kind of compact and clear notation that AMPL uses so I could avoid MPS format altogether. After all, Mathematica already has much of the notation and access to spreadsheets and databases built-in. As an aside, linear programming within Mathematica can provide rational results if all the parameters are rational (I would suggest trying this feature only for small problems). Additionally, Mathematica can be asked to use interior point methods that the document centre claims to be faster than the extreme point method. Finally, the documentation centre has a nice example of generating Klee-Minty problems of any size and then solving these. As regards integer programming, consider the following examples: LinearProgramming[{1., 1.}, {{5., 2.}}, {3.}, Automatic, Integers] This gives the integer solution {1,0}. If only the first variable is integer (and the second as a real number), you can specify the problem as: LinearProgramming[{1., 1.}, {{5., 2.}}, {3.}, Automatic, {Integers, Reals}] to get the solution {1, 0.0}. There are new constrained non-linear optimization capabilities as well that I have not tested. Word Processing and Typesetting. My experience with using Mathematica to create TeX files remains mixed, but my guess is that this aspect of Mathematica will get cleaned up sooner rather than later. You can use File-Save as (instead of File-Save as Special in previous versions) to generate the equivalent AMS-LaTeX file. For a large file, I could not get anywhere. For a small file with a single call, the ContourPlot call earlier, I did get the correct output using TrueTex, but the TeX compiler complained a lot so you will likely have to hand edit generated files before compiling. I believe that Wolfram is serious about making word processing and typesetting easy to use in Mathematica itself. For one, many of its intended users publish scientific or mathematical articles and moving from Mathematica to LaTeX is still not straightforward. Second, Mathematica had introduced Publicon for publication but that product has been stuck in version 1.0 for a long time, and even with that using LaTeX, it was not as easy as GUI front-ends like MacKichan Software's Scientific Word. Of course, one could question why use LaTeX instead of MathML format, but most journals have a preference for LaTeX. I would be happy if Wolfram were to introduce Publicon's ease of use in future updates of version 6.0 to let me do my wordprocessing within Mathematica this alone would make it easier for many users to work solely in a Mathematica environment and then hand edit the generated LaTex files if necessary. As with any other good thing, we always want more. At the top of my wish list for Mathematica 6.x or 7.y are two things: (1) wordprocessing/typesetting to extend the functionality and ease of use in Wolfram's Publicon software, and (2) being able to use the features it already has to create linear programming problems as with languages such as AMPL or OPL. Statistical analysis in Mathematica is already quite advanced, but you need to consider the ease of use of your current statistical package of choice for ease of use. Still, cluster analysis may be easier in Mathematica 6 than in your current package. The documentation center is quite impressive, but it needs to be more helpful regarding new features. [as regards?] The rewards of using Mathematica 6 are even higher than the already plentiful benefits of earlier versions. However, it requires a large commitment and investment of time.
ManMohan S. Sodhi (M.Sodhi@city.ac.uk) heads the Operations Research group at Cass Business School in London. References
OR/MS Today copyright © 2007 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 2007 by Lionheart Publishing, Inc. All rights reserved. |