Professional Documents
Culture Documents
minimizexpense: 10*numtrucks +
3*numcars;
maximize distance: x1 + 2*cos(x3);
Some more important things in AMPL
The semicolon: all commands must end with
one;
Comments: # this won’t be interpreted
To solve a problem, choose a solver:
CPLEX: for linear and integer programming
– Union: U = A union B
– Intersection: U = A inter B
– Cross Product: U = { A , B }
Theseoperations become useful or
necessary in many problems
Advantage of Set Operations
Suppose we have 3 sets of products,
– CANDY
– TOYS
– GAMES
Set PRODUCTS =
CANDY union TOYS union
GAMES;
param Demand: 1 2 3 :=
oreos 10 20 30
jenga 30 33 42
lazertag 40 30 22 ;
AMPL: Set indexing
Indexing of a one dimensional set
or
Param Demand: 1 2 3 :=
oreos 10 20 30
jenga 30 33 42
lazertag 40 30 22 ;
How to Transpose
Param: Calories :=
oreos 100 ;
Example
param a {S};
var x {S};
ampl : display X, Y;
X=6000
Y=1400
ampl : quit;
The two-variable linear program in
AMPL
Each variable is named in a var statement
Each constraint by a statement that begins
with subject to and a name like X_limit or
Time for the constraint
Multiplication requires an explicit *
operator
≦ relation is written <=
A linear programming model
Figure 1-1 shows the production problem in
algebraic notation
AMPL: Improved model
AMPL: Data file
Features of AMPL
AMPL supports wide range of problem types
Linear Programming
Mixed Integer Linear Programming
Quadratic Programming
Mixed Integer Quadratic Programming
Quadratic Constrained Programming
Mixed Integer Quadratic Constrained
Programming
- Millions of constraints and variables
Advantages
Syntax is almost similar to the
mathematical notation of optimization
problems.
This allows for a very concise and readable
definition of problems in the domain of
optimization.
AMPL References
– http://www.ampl.com/GUI/expermt.html
Thank you.
Any Questions ?
Email: manoj.imm@gmail.com
harishreddygavin@gmail.com