shortest and longest path problems in AMPL

1,990 views
Skip to first unread message

alpha041

unread,
Jun 4, 2014, 6:22:22 AM6/4/14
to am...@googlegroups.com
Hi
I want to model shortest and longest path problem in AMPL but can't find any results in web search.
can anyone help me on this?
thanks

Robert Fourer

unread,
Jun 5, 2014, 1:57:25 PM6/5/14
to am...@googlegroups.com
See chapter 15 of the AMPL book on Network Linear Programs. Section 15.2 has a shortest path example. You could adapt it for various longest-path problems, though in general the longest path is much harder to find.

Bob Fourer
am...@googlegroups.com

=======

fbahr

unread,
Jun 5, 2014, 2:16:50 PM6/5/14
to am...@googlegroups.com
A simple formulation for shortest path problems is given in the AMPL book, ch. 15: Network Linear Models

> http://www.ampl.com/BOOK/CHAPTERS/18-network.pdf#page=11
> http://www.ampl.com/BOOK/EXAMPLES/EXAMPLES2/index_files.html

(see also: http://lyle.smu.edu/~olinick/emis8374/handouts/amplcode.html)

For finding the longest path in a network you might want to read

> http://en.wikipedia.org/wiki/Longest_path_problem#Acyclic_graphs_and_critical_paths

and then take a look at Hakan Kjellerstrand's critical path model implementation

> http://www.hakank.org/ampl/critical_path1.mod

--fbahr

alpha041

unread,
Jun 7, 2014, 11:09:18 AM6/7/14
to am...@googlegroups.com
Dear All
Thanks

imalitt...@hotmail.com

unread,
Aug 17, 2017, 9:41:54 AM8/17/17
to AMPL Modeling Language, 4...@ampl.com
Hello, I am trying to code a shortest path problem, could you please tell me what's wrong with my code? I have also included the mathematical model that I'm trying to code (source node is A, terminal node is J). Thanks!
12.PNG
123.PNG
1234.PNG

inverse matrix

unread,
Aug 17, 2017, 1:58:45 PM8/17/17
to AMPL Modeling Language
ayy lmao engg1400

btw hint: otherwise doesn't include sets s and t
Message has been deleted

Robert Fourer

unread,
Aug 18, 2017, 9:08:43 AM8/18/17
to am...@googlegroups.com
To get help with a particular AMPL statement that is giving you errors, copy the entire text of the error message into your email, and also attach your actual files (not the screenshots of the files).

To find an AMPL constraint definition that is syntactically correct but does not specify the constraint correctly, look for obviously wrong constraints in the output of "expand;" which shows the actual constraints generated.

Bob Fourer
am...@googlegroups.com

=======

From: am...@googlegroups.com [mailto:am...@googlegroups.com] On Behalf Of dj1...@gmail.com
Sent: Friday, August 18, 2017 2:36 AM
To: AMPL Modeling Language
Cc: benji...@gmail.com
Subject: Re: [AMPL 14642] shortest and longest path problems in AMPL

I've written this aswell but ampl returns syntax errors and undefined "i". I can't seem to get it working


MAXIMILIANO ERNESTO RODRIGUEZ

unread,
Dec 25, 2021, 2:29:40 PM12/25/21
to AMPL Modeling Language
Hi

i need help on the shortest path problem, i have tried to formulate the model but it shows no solution. can anyone help me? Regards

AMPL Google Group

unread,
Dec 26, 2021, 6:21:23 PM12/26/21
to AMPL Modeling Language
Figure 15-7 of the AMPL book shows a correct formulation of a shortest path problem. If you can't get this to work, then to get some help, you will need to provide more information:
  • Explain specifically what is wrong. For example, don't just say "it shows no solution"; instead, copy the part of your AMPL session where you tried to see a solution, and paste it into your question.)
  • Copy all lines of any error messages into your question.
  • Attach your model and data files.


--
Robert Fourer
am...@googlegroups.com
{#HS:1739356892-107821#}
Reply all
Reply to author
Forward
0 new messages