---restore content starts---
Subway Travel Route
Https://github.com/ChengFR/PersonalProgram_SubwayRoute
Time Expectations
PSP 2.1 |
Personal Software Process Stages |
Time |
Planning |
Plan |
|
· Estimate |
· Estimate how long this task will take |
|
Development |
Development |
|
· Analysis |
· Demand analysis (including learning new technologies) |
3h |
· Design Spec |
· Creating a design Document |
1h |
· Design Review |
· Design Review (and colleagues review design documents) |
0.5h |
· Coding Standard |
· Code specification (to develop appropriate specifications for current development) |
1h |
· Design |
· Specific design |
1h |
· Coding |
· Specific code |
2h |
· Code Review |
· Code review |
0.5h |
· Test |
· Test (self-test, modify code, commit changes) |
1h |
Reporting |
Report |
|
· Test Report |
· Test report |
|
· Size Measurement |
· Computational effort |
|
· Postmortem & Process Improvement Plan |
· Summarize afterwards and propose process improvement plan |
1h |
|
Total |
11h |
Actual elapsed time
PSP 2.1 |
Personal Software Process Stages |
Time |
Planning |
Plan |
|
· Estimate |
· Estimate how long this task will take |
|
Development |
Development |
|
· Analysis |
· Demand analysis (including learning new technologies) |
4h |
· Design Spec |
· Creating a design Document |
0.5h |
· Design Review |
· Design Review (and colleagues review design documents) |
\ |
· Coding Standard |
· Code specification (to develop appropriate specifications for current development) |
2h |
· Design |
· Specific design |
2h |
· Coding |
· Specific code |
3h |
· Code Review |
· Code review |
1h |
· Test |
· Test (self-test, modify code, commit changes) |
1h |
Reporting |
Report |
|
· Test Report |
· Test report |
|
· Size Measurement |
· Computational effort |
|
· Postmortem & Process Improvement Plan |
· Summarize afterwards and propose process improvement plan |
1h |
|
Total |
14.5h |
Program Performance
During the program design phase, the performance of the program is considered.
When the minimum transfer path is realized, the subway map is initially prepared to be processed in accordance with the general figure, and the Dijkstra algorithm is used to record the previous station (in the shortest route) of each station. The cost of defining a transfer is a larger number, defining the transfer behavior as the previous station of the station and not on the same subway line, The transfer cost is added to the calculation of the distance of the node. Finally, the line is launched according to the site record.
However, the algorithm to search for a large number of nodes, because Dijkstra use greedy strategy, the first search is the terminal (from the terminal backward) on the line of all the sites, and a large number of cases are often the transfer, and therefore inefficient.
Considering that the subway map has a certain particularity, only in the transfer station can be "transfer", that is, two not on the same subway line between the site is bound to pass through the two stations on the route of the transfer station. Therefore, extracting the transfer station to seek the road, the processing node is much less than the original node, but the distance between the compute nodes will increase the time overhead. (In fact, the function that calculates the distance really takes up the most time)
The final performance analysis diagram of the program:
When the program is tested, it invokes a findtrailb function and a FINDTRAILC function, which are the shortest pathfinding and the least transfer pathfinding.
You can see that file processing takes up the most time during initialization. In the FINDTRAILC minimum transfer pathfinding function, the distance calculation function Calcdis takes up the most time.
The function is implemented as:
int Subnet::calcdis (station* sta1, station* sta2, subline* line) {
if ((!inline (sta1, line)) | | (!inline (Sta2, line))) {
Cerr << "Stations is not in a line." << Endl;
if (!inline (sta1, line))
Cerr << sta1->_name << "not on line." << Endl;
if (!inline (Sta2, line))
Cerr << sta2->_name << "not on line." << Endl;
return-1;
}
int NUM1 = 0, num2 = 0;
Auto B = Line->_stations.begin ();
Auto E = Line->_stations.end ();
int i = 0;
for (; b! = e; b++, i++) {
if ((*b) = = sta1)
NUM1 = i;
if ((*b) = = Sta2)
num2 = i;
}
if (LINE->_ISCIR) {
int length = Line->_stations.size ();
int dis1 = (num1-num2)% length;
int dis2 = (num2-num1)% length;
Return (Dis1 > Dis2)? Dis1:dis2;
}
else {
Return (Num1 > num2)? NUM1-NUM2:NUM2-NUM1;
}
}
Program Testing
Route Output Test Example: (Randomly selected)
Line Line 1
Daxing Line
Shortest Path Finding test:
Princess Tomb of the Spring Road//There are many routes, including multiple transfer routes closer to the direct route
Zhi Chun Road Princess Tomb//Reverse test
Firearms Camp//Ring test
Minimum transfer test:
Princess Tomb know Chun Road//There are many routes, of which the direct route is not the latest
Zhi Chun Road Princess Tomb//Reverse test
Firearms Camp//Ring test
Princess Graves International TRADE//There are many direct routes
Shahe Hwaseong//Because the minimum transfer algorithm is based on the transfer station to find the road, set not to go through the transfer station route to see if it can normally find the road
An input sample with no errors listed
These 10 test samples have a certain representativeness, the actual test sample more than these.
Personal Harvest
1. Re-learning C + + knowledge. Because of a period of time without using C + +, some unfamiliar. This exercise has improved C + + skills.
A practice of 2.OOP. A program written using object-oriented thinking. However, the normative process needs to be improved.
3. The ability to solve practical problems has been improved in a sense.
Personal items-Subway travel route