ECE297 Communication and Design Winter 2020ECE297 Milestone 3Pathfinding and Giving Directions“If you don’t know where you are going, you’ll end up someplace else.”– Yogi Berra“If you don’t know where you’re going, any road will take you there.– Lewis CarrollAssigned on Monday, March 2 User Interface and In-lab demo = 5/16Due on Tuesday, March 24 Autotester = 9/16Coding Style and Project Management = 2/16Total marks = 16/1001 ObjectiveIn this milestone you will extend your code to find good travel routes between two pointsembedded in a graph. Algorithms to find paths in graphs are important in a very wide rangeof areas, including GIS applications like yours, integrated circuit and printed circuit boarddesign, networking / internet packet routing, and even marketing through social media.By the end of this assignment, you should be able to:1 Find the shortest path between nodes in a graph.2 Develop a user interface for finding and reporting travel directions.2 Path FindingYour code should implement the three functions shown in m3.h; we will automatically testthese functions with unit tests. Your load_map function will always be called by the unittests before we call any of the functions in Listing 1. Some tests of each function will bepublic and available to you to run with ece297exercise 3 while others will be private andrun only by the automarker after you submit your code.1 /*2 * Copyright 2020 University of Toronto3 *Page 1 of 7ECE297 Communication and Design Winter 20204 * Permission is hereby granted, to use this software and associated5 * documentation files (the Software) in course work at the University6 * of Toronto, or for personal use. Other uses are prohibited, in7 * particular the distribution of the Software either publicly or to third8 * parties.9 *10 * The above copyright notice and this permission notice shall be included in11 * all copies or substantial portions of the Software.12 *13 * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE19 * SOFTWARE.20 */21 #pragma once2223 #include StreetsDatabaseAPI.h2425 #include 26 #include 2728 // Returns the time required to travel along the path specified, in seconds.29 // The path is given as a vector of street segment ids, and this function can30 // assume the vector either forms a legal path or has size == 0. The travel31 // time is the sum of the length/speed-limit of each street segment, plus the32 // given turn_penalty (in seconds) per turn implied by the path. If there is33 // no turn, then there is no penalty. Note that whenever the street id changes34 // (e.g. going from Bloor Street West to Bloor Street East) we have a turn.35 double compute_path_travel_time(const std::vector& path,36 const double turn_penalty);373839 // Returns a path (route) between the start intersection and the end40 // intersection, if one exists. This routine should return the shortest path41 // between the given intersections, where the time penalty to turn right or42 // left is given by turn_penalty (in seconds). If no path exists, this routine43 // returns an empty (size == 0) vector. If more than one path exists, the path44 // with the shortest travel time is returned. The path is returned as a vector45 // of street segment ids; traversing these street segments, in the returned46 // order, would take one from the start to the end intersection.47 std::vector find_path_between_intersections(48 const IntersectionIndex intersect_id_start,49 const IntersectionIndex intersect_id_end,50 const double turn_penalty);515253 // Returns the time required to walk along the path specified, in seconds.54 // The path is given as a vector of street segment ids. The vector can be of55 // size = 0, and in this case, it the function should return 0. The walking56 // time is the sum of the length/ for each street segment, plus57 // the given turn penalty, in seconds, per turn implied by the path. If therePage 2 of 7ECE297 Communication and Design Winter 202058 // is no turn, then there is no penalty. As mentioned above, going from Bloor59 // Street West to Bloor street East is considered a turn60 double compute_path_walking_time(const std::vector& path,61 const double walking_speed,62 const double turn_penalty);636465 // This is an uber pool-like function. The idea is to minimize driving travel66 // time by walking to a pick-up intersection (within walking_time_limit secs)67 // from start_intersection while waiting for the car to arrive. While walking,68 // you can ignore speed limits of streets and just account for given69 // walking_speed [m/sec]. However, pedestrians should also wait for traffic70 // lights, so turn_penalty applies to whether you are driving or walking.71 // Walking in the opposite direction of one-way streets is fine. Driving is72 // NOT! The routine returns a pair of vectors of street segment ids. The first73 // vector is the walking path starting at start_intersection and ending at the74 // pick-up intersection. The second vector is the driving path from pick-up75 // intersection to end_interserction. Note that a start_intersection can be a76 // pick-up intersection. If this happens, the first vector should be empty77 // (size = 0). If there is no driving path found, both returned vectors should78 // be empty (size = 0).79 // If the end_intersection turns out to be within the walking time limit,80 // you can choose what to return, but you should not crash. If your user81 // interface can call this function for that case, the UI should handle82 // whatever you return in that case.83 std::pair, std::vector>84 find_path_with_walk_to_pick_up(85 const IntersectionIndex start_intersection,86 const IntersectionIndex end_intersection,87 const double turn_penalty,88 const double walking_speed,89 const double walking_time_limit);Listing 1: m3.hA key function in m3.h is find_path_between_intersections. This function must pass3 types of tests; you can obtain part marks if you pass some of the checks but fail others, butyou will have to pass them all to obtain full marks.• The route must be legal – that is, it must be a sequence of street segments which form aconnected path from the start intersection to the end intersection. You must also respectone way streets, and not try to travel down them in the wrong direction. Note that it isalso possible that no legal route exists between two intersections, in which case you shouldreturn an empty (size = 0) vector of street segments.• Your route should have the minimum possible travel time between the two intersections,where travel time is defined below.• You should find the route quickly; you will fail performance tests if your path-findingcode is not fast enough.代做ECE297留学生作业、C++程序语言作业调试、data课程作业代做、代写c++作业 代写留学生Prolog|代做JThe travel time required to traverse a sequence of street segments is the sum of twocomponents.Page 3 of 7ECE297 Communication and Design Winter 2020• The time to drive along each street segment, which is simply the length of the streetsegment divided by its speed limit.• The time to make turns between street segments. We assume that no turn is requiredwhen you travel from one street segment to another if they are both part of the same street– that is, we are assuming you hit only green lights when you are going straight down astreet. When you travel from a street segment that is part of one street (e.g. Yonge Street)to a street segment that is part of another street (e.g. Bloor Street) however, you will haveto make a turn and this will cost turn_penalty extra time. turn_penalty models theaverage time it takes for you to wait for a break in traffic and/or a traffic light to turngreen so you can turn.See Figure 1 for an example of driving paths and travel times.Blue path:Figure 1: Two driving paths between Cecil & Ross and College & McCaul; one has a lower traveltime than the other. The turn_penalty is 15 seconds in this example.The second major function in m3.h is find_path_with_walk_to_pick_up. It is a pathfinding function in which you can walk for a specified time to reach an intermediate intersection;at that intermediate intersection you will meet a car (e.g. an uber or taxi) and you will thendrive the rest of the way to the end_intersection. The walking path must take less thanthe walking_time_limit to walk to from the start_intersection and the driving pathmust have the minimum travel time possible to the end_intersection from any intersectionthat is reachable by walking for at most the walking_time_limit. This function returns apair of vectors, with the first representing the walking path and the second the driving path.Figure 2 gives an example. In this case the start intersection is St. Joseph St. & Queen’sPark Cres., and the person has a walking time limit of 360 s and a walking speed of 2 m/s.The person can reach multiple intersections before the car arrives to take him/her to thePage 4 of 7ECE297 Communication and Design Winter 2020end_intersection (Yonge St. & Elm St.). Walking to Bay St. & Wellesley is possible withinthe 360 s walking time, and minimizes the driving time to the end_intersection.startend_intersectionWalkingpath DrivingpathFigure 2: A path from St. Joseph St. & Queen’s Park Cres. to Yonge St. & Elm that consists of awalking path (to Bay & Wellesley) and a driving path from there to the destination.To make it easier to verify that you compute turns and travel times correctly, m3.h requiresyou to implement compute_path_travel_time (for driving) and compute_path_walking_timefunctions; ece297exercise provides unit tests for them. Make sure you pass these unit tests,as you will not be able to find shortest travel time routes if these basic functions are incorrect.3 User InterfaceImplementing your path finding algorithm is only part of this milestone; you also need tomake this functionality usable by end users. You should decide on commands that will betyped and/or entered with mouse clicks by the user to specify what path he/she is interestedin finding. The required features of your user interface are:Page 5 of 7ECE297 Communication and Design Winter 2020• Your program must work with any map without recompilation, so the user should beable to specify the map of interest.• Users must be able to enter commands that exercise your code to find a path betweentwo intersections (specified by entering street names at each intersection, e.g. Yonge Streetand Bloor Street).• Your interface must have some method that allows users to specify partial street names(e.g. Yong) instead of full street names to identify the street.• Users must also be able to find paths between intersections by mouse clicking on intersections.• You must have some method for users to request both types of path finding (drive onlyand walk + drive) implemented in this milestone. For the walk + drive function, usersshould be able to enter a walking speed and walking time limit as well as the start and endintersections.• You must display the found path(s) in the user interface; for full marks this path shouldbe easy to understand and give a good sense of how to follow it.• You must print out detailed travel directions to the console or in the graphics. For fullmarks, these travel directions must be sufficiently detailed and clear that a typical drivercould follow them.• You must give informative error messages if the user mistypes something (e.g. an invalidstreet or map name).• You must have some method (e.g. a help GUI button or notes in dialog boxes) so newusers can learn the interface.Beyond meeting the basic requirements above, your user interface will be evaluated onhow user-friendly and intuitive it is. You should produce user-friendly walking and drivingdirections, using both text and graphical drawing. For example, directly printing the sequenceof street segment ids that your path finding code returns would be a completely unusable userinterface! Print out clear directions giving all the information you would want if you werebeing given driving directions. Draw an informative picture of the route to follow. Integratingboth your intersection input and driving directions output into the graphics will generallylead to a more user-friendly design than having the user type and read text at the commandprompt.When creating a user interface like this it is a good idea to test it on people who arenot part of the development group. Feedback from a person not involved in the design(friends, family, etc.) is very useful in identifying what is intuitive and what is obscure inyour interface.Page 6 of 7ECE297 Communication and Design Winter 2020Page 1 of 1file:///C:/Users/Mohamed/Desktop/light-bulb-7.svg 7/8/2014One part of making your interface more user-friendly is to support goodmatching of (partial) input text to street names. You can use your milestone1functions to achieve a basic partial name matching, but you can also exploreother options to do more than match string prefixes. One option is usingthe regular expression feature in the C++ standard library, whichlets you match general patterns in strings.4 Grading• 9/16 marks will come from the autotester.The auto tester will test basic functionality, speed and that your code has no memoryerrors or leaks (via a valgrind test).• 5/16 marks will be assigned by your TA based on an in-lab demo of your interface.Your interface should meet all the requirements listed above, be easy to use, and feel fastand interactive. The sophistication and ease of use of your interface will be compared tothat of the average design in the class to help assess this mark.• 2/16 marks will be based on your TA’s evaluation of your code style and project management,which includes planning and tracking tasks on your wiki and using git effectively.Your TA will review git logs and your wiki page, and ask team members questions aboutthe design and each member’s contribution to it. If a team member has made a smallcontribution or shows poor knowledge of the design, his or her mark may be reduced and ifmerited some marks may be transferred to other team members.Page 7 of 7转自:http://www.daixie0.com/contents/13/4936.html