and data then begins to make sense, especially as they
realize that changing from the tutorial example to the
homework set involves changing only the data file.
This contrasts with the need to rewrite the entire
model, as would be required with Lindo.
The models can be run either through the Scite inter-
face or at the AMPL command prompt.
• To run a script in AMPL through the Scite inter-
face, the user simply opens the script (usually a
".run" file) in Scite, and presses the F5 function key.
AMPL then runs in a side panel. Note that if you
have a model file open without a "solve" command,
AMPL will read the model, but not solve it because
it has not received the "solve" command.
• To run a script at the AMPL command prompt,
click Start, Run, type ampl in the dialog and press
enter. This opens an AMPL command window.
To run the 2matching.run script, at the "ampl:"
prompt, type "run 2matching.run;", and press en-
ter. In the command window, they will need to
enter the reset command to clear AMPL's memory.
("Reset" is not needed if they use Scite as the inter-
face.) Remind them not to reset before using "dis-
play" to see results. Explain that when they are
frequently rerunning a script, they may want to
put "reset;" at the end of the script.
After students get the two models running, they are
given access to the script (makesvg.run
(45)
) which
produces the SVG graphical output, and shown how
to call the script from their existing run files. This visu-
alization gives them a powerful and immediate indi-
cation as to whether their model is correct, and how
it is related to the TSP. This would be the time to ex-
plain the commands filename command, which is used
to give AMPL a list of commands from a file.
SVG can be viewed in a web browser with a free add-
in (such as Adobe's SVG Viewer,
http://www.adobe.com/svg). We have carefully written
all models and scripts to have uniform variable and
set definitions, so they all will work with makesvg.run.
For algorithms such as the 1-tree subgradient optimiza-
tion, the graph can be viewed as the algorithm is pro-
gressing, simply by refreshing the browser. Copying
the image to a word processing program is convenient.
The images are valuable for teaching, and are also
conveniently copied to presentation software such as
PowerPoint.
Given sufficient time, students may be given AMPL
scripts for the minimum spanning tree (prims.run
(46)
or kruskal.run
(47)
, originally developed by Olinick
(2006). Alternatively, the minimum spanning tree may
be covered in a later tutorial, after the material is pre-
sented during the lecture.
The workshop approach has multiple benefits, as im-
mediate help can be given to those students who have
difficulty starting and running AMPL. Points of syntax
can be addressed immediately, and students get a
quick positive result, with a problem that is easy
computationally. Key AMPL commands, such as "re-
set", "display", and "expand", are explained and imme-
diately put to use. Sometimes, students become suffi-
ciently confident and enthused that they want to at-
tempt the homework assignment immediately.
Provision of this one-hour workshop has alleviated a
host of problems in using AMPL. Students come up
to speed much more quickly compared to simply being
given a sheet of instructions.
Lecture 2. Relaxations and solution methods. Power-
Point presentation
(48)
Following Lecture 1's introduction to TSP formula-
tions, Lecture 2 introduces some solution methods.
We first present the assignment problem with branch
and bound, using an example from Winston (2003, pp.
530-534), then give the 1-tree, with Prim's and
Kruskal's algorithms. This information is easy to ex-
plain, and tends to be understood easily, partly be-
cause of the highly graphical nature of the information,
and as it is given just a few weeks following more
general IP cuts and branch and bound.
The final section of this lecture covers the Held & Karp
1-tree subgradient optimization algorithm. Many stu-
dents get completely thrown at this point, as the lecture
has moved from tree, to 1-tree, to an entirely new al-
(45)
http://ite.pubs.informs.org/Vol7No1/LeeRaffensperger/AMPL_files/makesvg.run
(46)
http://ite.pubs.informs.org/Vol7No1/LeeRaffensperger/AMPL_files/Prims/prims.run
(47)
http://ite.pubs.informs.org/Vol7No1/LeeRaffensperger/AMPL_files/kruskal/kruskal.run
(48)
http://ite.pubs.informs.org/Vol7No1/LeeRaffensperger/PowerPoint/02_Solution_methods_for_the_TSP.ppt
© INFORMS ISSN: 1532-054543INFORMS Transactions on Education 7:1(37-69)
LEE & RAFFENSPERGER
Using AMPL for teaching the TSP