1 / 17

AMPL

AMPL. Presentation 1. By Raymond Kleinberg. Outline. AMPL - Ugh! - What is it good for? Basics Starting a Problem Running the Problem Example. AMPL. Ugh! - What is it good for?. AMPL does:. Solves simple LP’s (Slightly older than CDs) Solves not-so-simple LP’s Solves hard LP’s

fritzy
Download Presentation

AMPL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. AMPL Presentation 1 By Raymond Kleinberg

  2. Outline • AMPL - Ugh! - What is it good for? • Basics • Starting a Problem • Running the Problem • Example

  3. AMPL Ugh! - What is it good for?

  4. AMPL does: • Solves simple LP’s (Slightly older than CDs) • Solves not-so-simple LP’s • Solves hard LP’s • Solves IP’s • Solves MIP’s (that does not include Will Smith!) • You’ll see how much it can do!!

  5. Basics • Files you will need • How to write them • How to save them

  6. Writing the .mod file Open up OxEdit and type the file - we’ll learn how to do that later.

  7. Saving the file Save the file as a mod file e.g. helloworld.mod

  8. Syntax of File • As with any computer language, AMPL requires the file it reads to be a certain way. • The first set of problems we will do will only require one file and the format is very simple and natural. • Here’s how it goes.

  9. Order of entry Enter the variables first: var x1 >=0; var Sally >=4.5; var smileyface <=-1; var happy integer >=0;

  10. Order of Entry- Cont. Next enter the objective: maximize OBJ: 3*x1 - happy + 2*Sally; minimize COST: 3*x3 + 2*x1 - Sally; maximize WHOCARES: 0;

  11. Order of Entry - Cont. Next enter the constraints: subject to WOOD: 2*x1 - 40*happy<=27; subject to WORK: x3 + 2.5*Sally<=34; subject to MACHINE: happy - Sally<=14;

  12. Put it all together: var x1 >=0; var Sally >=4.5; var smileyface <=-1; var happy integer >=0; maximize OBJ: 3*x1 - happy + 2*Sally + 4.5*smileyface; subject to WOOD: 2*x1 - 40*happy<=27; subject to WORK: x3 + 2.5*Sally<=34; subject to MACHINE: happy - 3*smileyface<=14;

  13. Running the File Once you have the file written and saved, we need to run it to get our solution.

  14. How to Run AMPL • Open up AMPL • Tell AMPL what you want solved by: • “model data\project1.mod;” • If you want to use a different solver: • “option solver <solver name>;” • Tell AMPL to solve it: • “solve;”

  15. Getting the variables • This will only give you the optimal value, if it exists. How do you know the variable values that give this objective? • Tell AMPL to give them to you: • “display x1,x3,Sally,happy,smileyface;” • This will display the variable values • Remember, AMPL is case sensitive.

  16. Put it all together • ampl: model data\ampl1.mod;ampl: option solver cplex;ampl: solve;CPLEX 8.0.0, optimal integral solution found, objective value 712.2, 0 MIP iterations, 0 branch and bound nodesdisplay x1,x3,Sally,smileyface,happy;x1 = 0x3 = -1Sally = 22.33333happy = 11smileyface = 0

  17. That’s it. • You’ve seen that AMPL can solve many types of programming problems with lots of variables and constraints. • Later you will see more of its power when it comes to streamlining the problem and running it more efficiently.

More Related