AMPL A Mathematical Programming Language at the Universityof

AMPL A Mathematical Programming Language at the Universityof

AMPL A Mathematical Programming Language at the Universityof Michigan Do cumentation Version 2 D. Holmes [email protected] 23 June 1992 Up dated 16 Novemb er, 1994 Up dated 18 August, 1995 Contents 1 Intro duction 1 2 AMPL: A Brief Description 2 2.1 The Mo del Section :: :::: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 2 2.1.1 Sets ::: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 3 2.1.2 Parameters :: :::: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 3 2.1.3 Variables ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 4 2.1.4 Ob jective ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 5 2.1.5 Constraints :: :::: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 5 2.1.6 An example :: :::: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 6 2.2 The Data section ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 7 2.3 Using AMPL interactively :: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 9 2.4 Controlling the solver from within AMPL ::: :::: ::: :::: ::: :::: ::: :::: : 9 3 AMPL at the University of Michigan 10 3.1 Using the IOE AMPL/Solver package AMPLUM ::: ::: :::: ::: :::: ::: :::: : 10 3.2 Using solvers directly : :::: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 13 4 Technical Details 13 4.1 How AMPL interfaces with solvers :::: ::: :::: ::: :::: ::: :::: ::: :::: : 13 4.2 The AMPL package : :::: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 14 4.3 AMPLUM details. :: :::: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 16 1 Intro duction AMPL A Mathematical Programming Language [6] is a high-level language for describing mathematical programs. AMPL allows a mathematical programming mo del to b e sp eci ed indep endently of the data used for a sp eci c instance of the mo del. AMPL's language for describing mathematical programs closely follows that used byhumans to describ e mathematical programs to each other. For this reason, mo delers may sp end more time improving the model and less time on the tedious details of data manipulation and problem solution. A functional diagram of how AMPL is used is shown b elow. To start, AMPL needs a mathematical programming model, which describ es variables, ob jectives and relationships without refering to sp eci c data. AMPL also needs an instance of the data, or a particular data set. The mo del and one or more data les are fed into the AMPL program. AMPL works likeacompiler: the mo del and input are put into an intermediate form which can b e read bya solver. The solver actually nds an optimal solution to the problem by reading in the intermediate le pro duced by AMPL and applying an appropriate algorithm. The solver outputs the solution as a text le, which can b e viewed directly and cross-referenced with the variables and constraints sp eci ed in the mo del le. Model Data File 1 Data File 2 File AMPL AMPL MPS (Text) or Binary File OSL MINOS ALPO Linear, Linear, Linear, Solver Integer Nonlinear Quadratic Programs Programs Programs Solution File A commercial version of AMPL has b een p orted to most UNIX workstations at the UniversityofMichi- gan's Computer Aided Engineering Network CAEN. AMPL may b e used with several di erent mathe- matical program solvers, including MINOS version 5.4 [1], ALPO [8], CPLEX citecplex and OSL [5] version 2. AMPL may b e used interactively or may b e used in batch mo de. Used interactively, a mo deler may selectively mo dify b oth the mo del and its data, and see the changes in the optimal solution instan- taneously. Used in batch mo de, a mo deler may obtain detailed and well-formatted solutions to previously de ned mathematical programs. A shell script that may b e used on any UNIX platform has b een develop ed to simplify batch op eration. Using this script, one can directly see the optimal solution to an AMPL problem without knowing UNIX or the details of the CAEN network. This do cumentation is arranged into two sections. The rst gives a brief intro duction to the AMPL mathematical programming language. A more detailed description may b e found in [6]. In addition, a 1 tutorial by the authors of AMPL is available [7]. The second section describ es the use of AMPL and various solution packages on the CAEN network. Supp orting technical details of the lo cal AMPL interface are also presented. 2 AMPL: A Brief Description AMPL stands for \A Mathematical Programming Language", and is a high level language that translates mathematical statements that describ e a mathematical program into a format readable by most optimization software packages. The version of AMPL implemented here at the University of Michigan will currently mo del linear, mixed-integer, and nonlinear programs. The following description of the AMPL programming language presupp oses some knowledge of the format and nature of mathematical programs. A complete description of a sp eci c mathematical program requires b oth a functional description of the relationships b etween problem data and the problem data itself. AMPL separates these two items into separate sections, the model section and the data section. These sections are usually in separate les i.e. a separate mo del le and a data le, but may b e combined into one or multiple les. The data section must always follow the mo del section. NOTE: The following sections describ e the most imp ortant features of AMPL. Many fea- tures of AMPL describ ed in the referenced do cumentation are not describ ed here. A complete reference may b e found in the app endix of [6] available from the Engineering Library, call num- b er QA402.5 F695 2.1 The Mo del Section The general form for a linear program considered by AMPL is X max c x 1 i i i2I X a x b 8j 2 J 2 st ij i j i2I P P Here, c ;a ; and b are all parameters, I and J are Sets, c x is the ob jective, and a x i ij j i i ij i i2I i2I b are constraints. j The form of an AMPL mo del le closely follows that of the mathematical program stated ab ove. Sp ecif- ically, a mo del le is arranged into the following sections. Declarations using the following keywords: set param var arc Ob jectives declared with: maximize minimize Constraints subject to node A prototyp e and example of each item is given b elow, followed by a full example of an AMPL mo del le. For the purp oses of explanation, we will consider a pro duction planning mo del. Sp eci cally,we wish to nd an optimal pro duction schedule for a group of pro ducts given known demands, known linear costs, and known requirements for raw materials for each unit of pro duct pro duced. The example considered is provided with the AMPL programming package. 2 2.1.1 Sets Sets are arbitrary collections of ob jects that are assigned to variables or constraints. For example, in a pro duction planning example, a set may b e a group of raw materials or pro ducts. AMPL also allows sets of indexed integers to b e used for the purp oses of describing constraints or ob jectives. The prototyp e is: set [set name] For example, a pro duction planning mo del optimizes pro duction of a set of pro ducts that are made from a set if raw materials. AMPL groups these pro ducts and raw materials using the declarations set P; Products set R; Raw Materials Note that a comments out the rest of the AMPL line. Let setexp be anyvalid set expression. Optional phrases that may b e used when describing sets are Keyword Meaning dimen n De nes the dimension of the set within setexp Checks that declared set is a subset of set expr. := setexp Sp eci es a value for the set. default setexp Sp eci es default value for set. ordered [ by [ reversed ] set ] The de ned set has an order p ossibly de ned by set. circular [ by [ reversed ] set ] The de ned set has a circular order p ossibly de ned by set. The set used in the ordered keyword describ ed ab ovemay b e a real valued interval or an integral interval, using the set description interval[a,b] or integer[a,b]. Several functions that de ne and op erate on sets are available, including union, diff, symdiff, intersection, cross cartesian pro duct, firstS, lastS, and cardS. More detailed examples of sets are given b elow. set U; set A := 1..n; set B := i..j by k; set C ordered set D:= {i in C: x[i] in U}; set E := D diff U set V within interval[i,j; set W ordered by integera,b; 2.1.2 Parameters Parameters are scalars, vectors, or matrices of known data. These may include limits of index sets, rhs co ecients, matrix entries, etc. The prototyp e declaration for parameters is param [name] f index1, index2, ... g attributes.. ; where [name] is a required identi er, index1, index2, ... are optional sizes or ranges for subscripts on the data, and attributes states attributes the parameter must have, such as the p ossible range of values the parameter may take. AMPL allows parameters to b e de ned in terms of other previously de ned parameters. The attributes assigned to a parameter may b e sp eci ed using the following keywords: Keyword Meaning binary Parameter must b e either 0 or 1. integer Parameter must b e an integer. symbolic Allows non-numeric parameters. <<==!=>>= expression Parameter must satisfy expression. default expression Default in case parameter not de ned in data section. in setexp Parameter must b e in setexp Examples relevant to our pro duction planning problem include: 3 param T > 0; number of production periods param M > 0; Maximum production per period param a{R,P} >= 0; units of raw material i to manufacture 1 unit of product j param b{R} >= 0; maximum initial stock of raw material i param c{P,1..T}; estimated profit per unit of product in period t param d{R}; storage cost per period per unit of raw material param f{R}; estimated remaining value per unit of raw material after last period Note that a set of indices 1; 2;:::;T may b e written as {1..T}.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    17 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us