Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
AMPL
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=={{anchor|example}}A sample model== A transportation problem from [[George Dantzig]] is used to provide a sample AMPL model. This problem finds the least cost shipping schedule that meets requirements at markets and supplies at factories.<ref> {{cite book |first=George |last=Dantzig |author-link=George Dantzig |chapter=3. Formulating a Linear Programming Model |title=Linear Programming and Extensions |chapter-url=https://books.google.com/books?id=hUWPDAAAQBAJ&pg=PA32 |date=2016 |orig-year=1963 |publisher=Princeton University Press |isbn=978-1-4008-8417-9 |pages=32β62}} </ref> <!-- See http://pygments.org/docs/lexers/#lexers-for-the-ampl-language --> <syntaxhighlight lang="ampl"> set Plants; set Markets; # Capacity of plant p in cases param Capacity{p in Plants}; # Demand at market m in cases param Demand{m in Markets}; # Distance in thousands of miles param Distance{Plants, Markets}; # Freight in dollars per case per thousand miles param Freight; # Transport cost in thousands of dollars per case param TransportCost{p in Plants, m in Markets} := Freight * Distance[p, m] / 1000; # Shipment quantities in cases var shipment{Plants, Markets} >= 0; # Total transportation costs in thousands of dollars minimize cost: sum{p in Plants, m in Markets} TransportCost[p, m] * shipment[p, m]; # Observe supply limit at plant p s.t. supply{p in Plants}: sum{m in Markets} shipment[p, m] <= Capacity[p]; # Satisfy demand at market m s.t. demand{m in Markets}: sum{p in Plants} shipment[p, m] >= Demand[m]; data; set Plants := seattle san-diego; set Markets := new-york chicago topeka; param Capacity := seattle 350 san-diego 600; param Demand := new-york 325 chicago 300 topeka 275; param Distance : new-york chicago topeka := seattle 2.5 1.7 1.8 san-diego 2.5 1.8 1.4; param Freight := 90; </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)