Question: An important part of writing code is writing efficient code that takes as little time as possible to run. This particularly important when dealing with
An important part of writing code is writing efficient code that
takes as little time as possible to run. This particularly important
when dealing with large problems, as is often the case for realworld
optimisation problems.
Here the task is to compare the efficiency of your code written in
Question with the code given in Question to see which format
is best that is fastest
For this question you cannot use the AMPL version downloaded
from learnOnline as this version will only solve small problems.
Download and install the AMPL Community Edition, and use the
opensource solver HiGHS which allows problems of any size. Choose
the HiGHS solver with
option solver highs ;
a The code
display totalsolvetime ;
will show the time taken to complete the last solve command.
Place this code at the end of your code written in Question
and at the end of the code given in Question
Systematically run the code from both Question and Ques
tion for all numbers of cities given in and record the time
taken to solve each problem. Since the solve time can be
quite variable, you should do each test multiple times and
then calculate the average time use your judgement to deter
mine how many runs you should do Also, you want this to
be a fair test so do all runs on the same computer under the
same conditions.
Note that two largest problems will take some time
to run, and it is possible that your computer is not able to
solve them using both codes. If you fail to solve these larger
problems, then make a note of this and complete this question
without these results you will not be penalised
Tabulate your results. Comment on anything that you think
is interesting or important about these results. In particular,
comment on the efficiency of the code.
b Plot the average run times against for both codes on the
same graph. Make sure your graph is displaying useful in
formation for example, you might find that a log plot or a
semilog plot is more informative than a linear plot
From your plot, estimate how long it might take to solve a
TSP with cities assuming it is possible to do so
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
