How can I implement these 2 additional constraint in this AMPL shortest path problem?

112 views
Skip to first unread message

Giuseppe Milazzo

unread,
Dec 18, 2020, 12:54:31 PM12/18/20
to AMPL Modeling Language

The U.S. Department of Transportation (DOT) is planning to build a new interstate to run from Detroit (Michigan) to Charleston (South Carolina). Several different routes have been proposed. They are summarized in the figure below, where node 1 represents Detroit and node 12 represents Charleston.

Graphical representation here

 The numbers on the arcs indicate the estimated construction costs of the various links (in millions of dollars). It is estimated that all of the routes will require approximately the same total driving time to make the trip from Detroit to Charleston. Thus, the DOT is interested in identifying the least costly alternative.

 

1. Formulate an ILP model to determine the least costly construction plan.

2. Implement the model using the modeling language AMPL, and solve it by means of CPLEX.

3. Formulate an ILP model to determine the least costly route in case there are the following additional constraints: if arc (1,4) is used, then also arc (4,6) must be used; on the other hand, if arc (1,4) is not used, then the route must pass through node 9.

4. Implement the model in 3. using AMPL and CPLEX, and compare its optimal solution with the one found at point 2.

I figured out how to determine the least costly route in this way:

 this is the file .mod

model.PNG

here there is the file.dat

data.PNG

while here there is the solution

soluzione.PNG

So, give this, what should I change in these 2 files for resolve these 2 points?

3. Formulate an ILP model to determine the least costly route in case there are the following additional constraints: if arc (1,4) is used, then also arc (4,6) must be used; on the other hand, if arc (1,4) is not used, then the route must pass through node 9.

4. Implement the model in 3. using AMPL and CPLEX, and compare its optimal solution with the one found at point 2.

Really much apprecciate.

(Ps: Due Tre Quattro Cinque Sei Sette Otto Nove Dieci Undici are italian words for nombers, in english they are respectively Two Three Four Five Six Seven Eight Nine Ten Eleven)




AMPL Google Group

unread,
Dec 20, 2020, 10:11:41 AM12/20/20
to AMPL Modeling Language
Is this an exercise assigned to your class? (There are already several adequate interstate highway routes from Detroit to Charleston.) I would not want to give away the answer. If you have a more narrow concern, however, such as how to write a certain AMPL statement correctly, or interpret a particular error message, or use a particular solver, then you can ask your question in this forum. Be sure to include a copy of the most recent version of your AMPL statements (or attach your model and data files) and provide the full text of any error messages that you are seeing.


--
Robert Fourer
am...@googlegroups.com
{#HS:1373123719-96694#}
--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ampl/de78b39c-54f3-44f6-a898-27f4fdb7e925n%40googlegroups.com.

Giuseppe Milazzo

unread,
Dec 20, 2020, 10:41:20 AM12/20/20
to AMPL Modeling Language
this is actually a project from my university.
I need to solve an ILP  through programming language AMPL using the solver CPLEX.

I tried to resolve the points 3 and 4 in this way.

file.mod
model2.PNG
file .dat
data2.PNG
Solution:
soluzione2.PNG


As you can see in this case It uses another route because I added the 2 constraints .
Is this correct? Or it s not and I m missing something?
(P.s Due Tre Quattro Cinque Sei Sette Otto Nove Dieci Undici are numbers from 1 to 11 in italian, respectively 1,2 ,3 ...)


AMPL Google Group

unread,
Dec 21, 2020, 9:43:12 AM12/21/20
to AMPL Modeling Language
Your model defines "var particularroute{Link2} binary;" but that variable is not used in any of the constraints. So something must be wrong with your formulation.

I suggest that you return to the Shortest path models section in the Network Linear Programs chapter of the AMPL book, and adapt the example there (Figure 15.7) to model parts 1 and 2 of your project. Then, after you have done that successfully, consider how you would add constraints to enforce the extra conditions in parts 3 and 4. (Note that you will want to explicitly define the variables as "binary".)


--
Robert Fourer
am...@googlegroups.com
{#HS:1373123719-96694#}
On Sun, Dec 20, 2020 at 3:41 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
this is actually a project from my university.
I need to solve an ILP through programming language AMPL using the solver CPLEX.

I tried to resolve the points 3 and 4 in this way.

file.mod
model2.PNG
file .dat
data2.PNG
Solution:
soluzione2.PNG

As you can see in this case It uses another route because I added the 2 constraints .
Is this correct? Or it s not and I m missing something?
(P.s Due Tre Quattro Cinque Sei Sette Otto Nove Dieci Undici are numbers from 1 to 11 in italian, respectively 1,2 ,3 ...)

On Sun, Dec 20, 2020 at 3:11 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
Is this an exercise assigned to your class? (There are already several adequate interstate highway routes from Detroit to Charleston.) I would not want to give away the answer. If you have a more narrow concern, however, such as how to write a certain AMPL statement correctly, or interpret a particular error message, or use a particular solver, then you can ask your question in this forum. Be sure to include a copy of the most recent version of your AMPL statements (or attach your model and data files) and provide the full text of any error messages that you are seeing.


--
Robert Fourer
am...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages