Introduction to AMPL Student Version for Windows - PowerPoint PPT Presentation

1 / 27
About This Presentation
Title:

Introduction to AMPL Student Version for Windows

Description:

Quit AMPL and Edit GT_data.txt with WordPad. 24. Find New Solution and Save Results ... Open results.txt with WordPad or Word. 26. AMPL Syntax Notes ... – PowerPoint PPT presentation

Number of Views:105
Avg rating:3.0/5.0
Slides: 28
Provided by: ieor
Category:

less

Transcript and Presenter's Notes

Title: Introduction to AMPL Student Version for Windows


1
Introduction to AMPL Student Version for Windows
  • updated 23 January 2008

2
Using AMPL Student Edition on Windows
  • Download AMPL Student Edition
  • Download these files from Blackboard
  • transport_model.txt
  • GT_data.txt
  • diet.txt
  • GTRR.txt
  • Save the files in the amplcml directory created
    in step 1
  • Double click on the AMPL icon to start AMPL

3
AMPL Student Edition for Windows
4
Setting Up and Solving the Diet Problem
Interactively
  • ampl var milk gt 0
  • ampl var cheese gt 0
  • ampl var apples gt 0
  • ampl minimize cost milk 2.5 cheese 0.75
    apples
  • ampl subject to protein 40 milk 20 cheese
    10 apples gt 80
  • ampl subject to vtmnA 5 milk 40 cheese
    30 apples gt 60
  • ampl subject to vtmnB 20 milk 30 cheese
    50 apples gt 50
  • ampl subject to vtmnC 30 milk 50 cheese
    60 apples gt 30
  • ampl solve
  • MINOS 5.5 optimal solution found.
  • 1 iterations, objective 2.869565217
  • ampl display milk, cheese, apples
  • milk 1.56522
  • cheese 0
  • apples 1.73913
  • ampl quit

5
Solving the Diet Problem With A Script File
  • Create a text-only file with commands you would
    type at the AMPL prompt

6
AMPL Script File for the Diet Problem
diet.txt an AMPL script file for the diet
problem var milk gt 0 var cheese gt 0 var
apples gt 0 minimize cost milk 2.5 cheese
0.75 apples subject to protein 40 milk 20
cheese 10 apples gt 80 subject to vtmnA
5 milk 40 cheese 30 apples gt 60
subject to vtmnB 20 milk 30 cheese 50
apples gt 50 subject to vtmnC 30 milk 50
cheese 60 apples gt 30 solve display milk,
cheese, apples
7
Solving the Diet Problem With A Script File
  • ampl commands diet.txt
  • MINOS 5.5 optimal solution found.
  • 1 iterations, objective 2.869565217
  • milk 1.56522
  • cheese 0
  • apples 1.73913
  • ampl quit

8
Modify the Script to Save the Results to a File
diet.txt an AMPL script file for the diet
problem var milk gt 0 var cheese gt 0 var
apples gt 0 minimize cost milk 2.5 cheese
0.75 apples subject to protein 40 milk 20
cheese 10 apples gt 80 subject to vtmnA
5 milk 40 cheese 30 apples gt 60
subject to vtmnB 20 milk 30 cheese 50
apples gt 50 subject to vtmnC 30 milk 50
cheese 60 apples gt 30 solve display
cost, milk, cheese, apples gt diet_output.txt quit

9
Solving the Diet Problem With A Script File
  • ampl commands diet.txt
  • MINOS 5.5 optimal solution found.
  • 1 iterations, objective 2.869565217
  • ampl quit

10
Results Saved in File diet_output.txt
11
Contents of diet_output.txt
cost 2.86957 milk 1.56522 cheese 0 apples
1.73913
12
Script File for GT Railroad Problem
GTRR.txt - AMPL script for GT Railroad
problem var x11 gt 0 var x12 gt 0 var x13
gt 0 var x14 gt 0 var x21 gt 0 var x22 gt
0 var x23 gt 0 var x24 gt 0 var x31 gt
0 var x32 gt 0 var x33 gt 0 var x34 gt 0
13
Script File for GT Railroad Problem
minimize cost 13x11 35x12 42x13 9x14
6x21 61x22 18x23
30x24 15x31 10x32 5x33
9x34 subject to IE_Junction x11 x12 x13
x14 lt 4 subject to Centerville x21 x22
x23 x24 lt 1 subject to Wayover_Cty x31 x32
x33 x34 lt 2 subject to A_Station x11
x21 x31 gt 1 subject to Fine_Place x12 x22
x32 gt 1 subject to Goodville x13 x23
x33 gt 1 subject to Smwhr_st x14 x24 x34
gt 1 solve display x11, x12, x13, x14 display
x21, x22, x23, x24 display x31, x32, x33, x34
14
Solving the GT Railroad Problem With the
GTTR.txt Script File
15
A General Transportation Model
  • Notation
  • O is the set of origins
  • D is the set of destinations
  • ai is the number of units available at origin i
  • rj is the number of units required at destination
    j
  • cij is the cost of shipping one unit from origin
    i to destination j
  • xij is the number of units shipped from origin i
    to destination j

16
A General Transportation Model
17
transport_model.txt
  • set O
  • set D
  • param a i in O
  • param r j in D
  • param c i in O, j in D
  • var x i in O, j in D gt 0
  • minimize cost sum i in O, j in D ci,j
    xi,j
  • subject to supply i in O sum j in D xi,j
    lt ai
  • subject to demand j in D sum i in O xi,j
    gt rj

18
GT_data.txt
set O IE_Junction, Centerville, Wayover_City
set D A_Station, Fine_Place, Goodville,
Somewhere_Street supply param a
IE_Junction     4 Centerville     1
Wayover_City    2 demand param r
A_Station       1 Fine_Place     
1 Goodville       1 Somewhere_Street        1
19
GT_data.txt
param c                A_Station      
Fine_Place      Goodville       Somewhere_Street
IE_Junction     13             
35              42              9
Centerville     6              
61              18              30
Wayover_City    15       10
5 9       
20
Solving the Model
21
Solving the Model with CPLEX
22
The expand Command
23
The expand Command
24
Quit AMPL and Edit
GT_data.txt with WordPad
25
Find New Solution and Save Results
26
Viewing the Results
  • Quit AMPL
  • Open results.txt with WordPad or Word

27
AMPL Syntax Notes
  • AMPL files must be text-only files
  • Use the pound sign () to insert a comment
  • Except for comments, all AMPL statements must end
    with a semicolon ()
  • Use letters, numbers, and underscore (_) for
    user-defined names (e.g., variable names)
  • Use the command reset before re-reading a model
    file
Write a Comment
User Comments (0)
About PowerShow.com