ampldoc

# ampldoc - Introduction to AMPL A Tutorial AMPL is a...

This preview shows pages 1–3. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Introduction to AMPL A Tutorial * August 12, 2005 AMPL is a powerful language designed specifically for mathematical programming. AMPL has many features and options; however this tutorial covers a small subset of these 1 . Sections 1 through 5 provide an in- troduction to modeling Linear Programming (LP) problems with AMPL. Sections 6 and 7 introduce AMPL’s modeling capabilities for Integer Programming (IP) and Nonlinear Programming (NLP), respectively. 1 A Simple LP Model Consider the following example. Berkeley Paint Company makes two colors of paint, blue and gold. The blue paint sells for \$10 per gallon, while the gold paint sells for \$15 per gallon. The company has one factory, and can make only one color of paint at a time. However, blue paint is easier to make so the factory can make 40 gallons per hour of blue paint, but only 30 gallons per hour of gold paint. In addition, the marketing department tells manufacturing that they can sell at most 860 gallons of gold paint and 1000 gallons of blue paint. If a week is 40 hours and paint can’t be stored until next week, we need to determine how many gallons of blue and gold paint to make; so that the total revenue is maximized. Let P aintB represent the gallons of blue paint we will make, and P aintG represent the gallons of gold paint we will make. Then the problem is formulated as the following LP: max 10 P aintB + 15 P aintG s.t. : (1 / 40) P aintB + (1 / 30) P aintG ≤ 40 ≤ P aintB ≤ 1000 ≤ P aintG ≤ 860 . AMPL is designed to allow mathematical programs to be entered in a syntax very close to the algebraic notation you see above. To use AMPL, we need to create a text file with the mathematical program code. To create a text file, you can use any text editor you feel comfortable with. For example, you can use Notepad , which is found on every Windows 95 and Windows NT system. To create the following program file, start Notepad , and enter the following text. * This tutorial was originally prepared by P. Kaminsky. The original version is later modified and expanded by D. Rajan. 1 For more information, see the book AMPL: A Modeling Language for Mathematical Programming by R. Fourer, D. M. Gay, and B. W. Kernighan (1993: Boyd & Fraser) 1 ## Example One var PaintB; # amount of blue var PaintG; # amount of gold maximize profit: 10*PaintB + 15*PaintG; subject to time: (1/40)*PaintB + (1/30)*PaintG <= 40; subject to blue_limit: 0 <= PaintB <= 1000; subject to gold_limit: 0 <= PaintG <= 860; Note the following things about the AMPL language: • The # symbol indicates the start of a comment. Everything after that symbol is ignored. • Variables must be declared using the var keyword. • All lines of code must end with a semi-colon....
View Full Document

## This note was uploaded on 04/02/2008 for the course IEOR 162 taught by Professor Zhang during the Spring '07 term at Berkeley.

### Page1 / 13

ampldoc - Introduction to AMPL A Tutorial AMPL is a...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online