Installing AMPL
Windows users:- Download the package amplcml.zip (this link is from the AMPL home page).
- Unzip the file amplcml.zip (double-click it).
- The unzipped amplcml/ folder contains, among others:
- sw.exe: a command line interface;
- ampl.exe: the true AMPL modeler;
- cplex.exe: a solver for Linear and Integer Programming problems;
- minos.exe: a solver for Nonlinear Programming problems.
- Create a new folder C:\Programs\AMPL (you may instead create the AMPL folder on the desktop, depending on your preference or if C:\Programs is read-only), and move all the files (the four above AND all the others) into the newly created AMPL folder.
- For your convenience, create a link to sw.exe and place it on your desktop.
- Double-click on sw.exe (either the link or the real file).
- A window appears with a prompt "sw:". Type "ampl". The AMPL prompt appears.
Using AMPL
You can also create model files and data files with your favorite text editor (Notepad, WinEDT, etc.) and use the ampl prompt simply to specify model and data before solving the problem. Examples:- tin can,
- knapsack,
- post office,
- diet,
- financial planning,
- project selection,
- production planning (data), and
- transportation (data).
ampl: model tin-can.mod;
Then set the proper solver for each problem (Minos for tin-can.mod and all Nonlinear Programming problems, Cplex for all Linear and Integer Programming problems).
ampl: option solver minos;
(notice the ";" at the end of each command). Finally, give the "solve;" command to solve it:
ampl: solve;
At this point, AMPL calls the Minos solver, and when Minos is done you will see again the AMPL prompt. At this point, if the solver did not encounter errors, you should be able to visualize the value of the variables:
ampl: display radius, height;
http://coral.ie.lehigh.edu/~belotti/teaching/ampl/ampl.html
ampl: include branch_and_bound.run
reset
No comments:
Post a Comment