XpressMP 2005A 數學模型與最適化軟體
The Mosel Language
Coding in Mosel is straightforward enough if you have some experience with other highlevel programming languages. The statements that specify a model's variables and constraints closely resemble the usual notation to describe optimization models.The accompanying lines (see box) provide an example of Mosel code.

The Mosel code defines and solves a capacitated facility location model where the demand in a set of DemandCities must be satisfied from facilities to be located in a set of candidate SupplyCities, while minimizing the sum of transportation costs and the fixed costs associated with open facilities. The statement uses "mmxprs" specifies that the functionality from the module XpressOptimizer is used in this code. The declarations block defines the objects in the model. The sets with the cities are declared as constant sets of string as they are populated with string data. The cost, capacity and demand data structures are declared as integer arrays indexed with the sets of cities. The shipped quantities (x) and the decision whether to open a facility at a candidate location (y) are arrays of type mpvar, a specialized type to define mathematical programming variables. The initializations block indicates that the problem data is read from an external file. Following the initialization block, there are a number of statements that define the problem constraints. There are comments (lines that begin with exclamation point !) describing each type of constraint. The minimize statement calls on the optimizer to solve the problem. Finally, some aspects of the solution are written to the standard output.
Of course, Mosel's data structures and data handling capabilities are a lot more powerful than what is presented in the example. Usually, problem domain sets are declared as dynamic sets that are resized automatically as they are populated with elements from external data sources. Mosel offers great versatility to perform input/output operations with external data sources such as databases and spreadsheets. A number of drivers that allow using standard input/output statements with various sources are part of the Mosel distribution. Also, userdefined drivers can be generated as customized Mosel modules.
Mosel's language structures for program flow control include "if "selections, loops, procedures and functions. For example, the following block of code has a loop over the set of SupplyCities, and it calls the procedure SolveAndReport:
forall (j in SupplyCities) do  
FORCED := y(j)=1 writeln(j, " is forced in") SolveAndReport 

enddo 
The block of code illustrates how modeling and processing statements are interlaced in Mosel. A constraint named FORCED is repeatedly redefined to study the effect of individually forcing each candidate facility to be open. The procedure SolveAndReport groups the minimize and reporting statements from the original example.
The Graphical User Interface
Figure 1 shows a view of the Capacitated Location Problem example in the XpressIVE. The center panel is the editor window for the Mosel code, and it features color highlighting of the language syntax, mouseoverinformation on identifiers and autocomplete when typing. The left panel is the Project Bar that shows the entity tree that gets populated with the model identifiers after a successful compilation. The value of the identifiers can be displayed on tooltips or view dialogs after the problem is solved. The right panel is the Run Bar, and it contains a number of tabs that display output from Mosel and the Optimizer. The view in Figure 1 shows the text output from Mosel generated by the procedure SolveAndReport in the example. Some of the other Run Bar tabs display the optimization statistics, different views of the matrix to be optimized (see Figure 2), the progress of the optimization and the MIP search, a tree representation of the branchandbound search (see Figure 3), and userdefined graphs built with the functionality of the mmive module.
Figure 1: XpressIVE.
Figure 2: Matrix representation.
Figure 3: Branch and Bound Tree representation.
The XpressIVE has a number of wizards to assist in the process of developing a model. Each wizard addresses a specific task typically required by a model, like the definition of Data Input, Variables, Objectives and Constraints, and special tasks like Text Output and Graphing. Wizards are based on mouse selection options that interactively generate Mosel source code. Figure 4 shows the wizard dialog and the selections for the programming and the XpressOptimizer callback wizards. The programming wizard produces the syntax of the different Mosel programming structures on the preview editor. The XpressOptimizer callback wizard produces the syntax to write Mosel procedures that are executed every time the optimizer encounters certain events. For example, a Mosel procedure could be called every time an integer solution is found during a branchandbound search.
Figure 4: Wizard Dialog with Programming and Optimizer Callback wizard.
Bundled with the wizards, there is a collection of complete sample models that are organized according to the level of difficulty in terms of the use of Mosel and XpressOptimizer features. The sample models are generally welldocumented, and further information about most of them is available in the book "Applications of Optimization with XpressMP" (see Heipcke 2002). The book, which can be downloaded for free from www.dashoptimization.com, contains many more sample models and an impressive range of applications implemented in Mosel. The wizards and sample models are an excellent tool to get exposed and to learn both the basics and the more advanced features of XpressMP.
I find the experience to develop a Mosel model using XpressIVE to be productive and rewarding. The user interface is well designed to perform the basic operations of editing the code, compiling and running the model, and analyzing the results. The dialogs are intuitive and selfexplained, and they encourage the user to directly experiment with options and features without having to resort to help documents. Compilation and logical errors get quickly resolved. The many ways to retrieve information about model entities and data, a stateoftheart Mosel debugger in the latest XpressMP release, and the different available views of the problem matrix are particularly useful tools to produce correct results. A tool to monitor and improve the efficiency of the code, in the form of a profiler that calculates how long it takes to execute each line of code, is also available with the latest release.
The Basics and Beyond
At a basic level Mosel provides an environment where it is simple to define and solve mathematical programming models. In my classroom experience with an introductory O.R. course, students felt comfortable when I presented Mosel models and the XpressIVE. There is value in working with a tool that offers more modeling flexibility than the spreadsheets typically used in O.R. courses. There is also great value in the facilities to visualize the solutions and the behavior of the algorithms.
Mosel also provides an environment where it is natural to accomplish advanced tasks. Although the XpressIVE and much of the documentation is targeted for using XpressOptimizer as the solver, the Mosel language itself does not have a default solver, and the procedures from different solvers can be invoked when they are made available as Mosel modules. The XpressOptimizer includes the simplex, barrier and MIP algorithms, as well as algorithms for quadratic and mixed integer quadratic problems often arising in financial applications. Another module from the XpressMP developers, XpressSLP, is a solver for nonlinear and mixed integer nonlinear problems based on the technique of successive linear approximations usually applied to problems in the process industries. Finally, XpressCP is a module containing constraint programming (CP) functionality, which is a solution approach for problems with general constraint relations over discrete variables. Constraint programming has a broad range of applications in scheduling and planning. The XpressCP module uses the CHIP engine developed by COSYTEC SA (see www.cosytec.com). The Mosel language has been extended to use highlevel objects to define CP problems. Also, by formulating and solving CP problems in the Mosel, it is possible to customize search strategies, and to combine the problemsolving strengths of CP and LP/MIP.
The Mosel language has also been extended to formulate and solve stochastic programming problems. Many decision problems involving uncertainty achieve better solutions when modeled as a stochastic program. XpressSP provides stochastic data types, such as random decision variables that take different values in different scenarios, and tools to build scenario trees. These language extensions significantly simplify the traditionally cumbersome process of defining a stochastic programming problem. XpressSP is also integrated with the XpressIVE providing visualization tools to analyze and debug the stochastic model and to interpret the results. There are many applications of stochastic programming, especially in energy, finance and transportation.
A new Mosel language extension available with the XpressMP 2005A is the XpressApplication Developer (XAD). This module contains functions and procedures to build graphical user interfaces in Mosel. Figure 5 shows an example of a facility location GUI developed with the XpressApplication Developer. The exciting possibility to develop applications that combine modeling, optimization, and userinterface functions within a single environment is now a reality with XpressMP.
Figure5: Facility location GUI built with XAD Mosel Module.
Availability, Cost and Installation
XpressMP 2005A is available from Dash Optimization (www.dashoptimization.com). XpressMP components are available offtheshelf on multiple Windows and Unix platforms, except for XpressIVE that is only available on Windows 32 platforms. Licenses may be either computer specific or dongle specific.
The process of installing the software and configuring a computerspecific license on my Windows XP machine went smoothly, and it only took a few minutes.
The price of a basic XpressMosel/XpressOptimizer commercial license starts at about $5,000, and it goes up from there depending on the features used and problem size. Free evaluation licenses with full functionality are available for a limited evaluation time period. Free licenses with full functionality but limited by the size of the problem that can be solved are available for students. Students may solve bigger size problems by submitting them to the NEOS server for optimization (see wwwneos.mcs.anl.gov/neos/), subject to prior authorization and availability. The XpressIVE has a dialog to facilitate the process of submitting problems to the NEOS server. For academicians, there is an attractive academic partnership program that provides a full version of XpressMP at no cost subject to satisfying certain conditions consisting of using the software for teaching and doing research.
Conclusion
XpressMP is a worldclass software suite for mathematical programming modeling and optimization. Mosel is an innovative modeling environment that has the potential of becoming the standard tool to develop optimizationcentric applications. Mosel's simplicity and elegance is appropriate for students and users who are just being introduced to mathematical programming. At the same time, XpressMP's efficiency and robustness is appropriate for the development and deployment of industrialstrength applications. Finally, Mosel's open architecture is appropriate for researchers and academicians who wish to advance the field of optimization. I strongly recommend XpressMP for anyone seriously interested in optimization.