Software Engineering personal Projects

Source: Internet
Author: User

Personal Software Process Stages Time Reality
Plan
· Estimate how long this task will take Six days Six days
Development
· Demand analysis (including learning new technologies) Half an hour An hour
· Creating a design Document An hour An hour
· Design Review (and colleagues review design documents) Review if problems arise About four or five hours.
· Code specification (to develop appropriate specifications for current development) 。。 I don't know what this is. 。。 Still don't know
· Specific design 1.5 hours It's actually a lot of improvement, about three or four hours.
· Specific code Three days 15 hours
· Code review Review if problems arise About four or five hours.
· Test (self-test, modify code, commit changes) Test every little piece you finish writing. Five or six hours.
Report
· Test report Two hours Three hours
· Computational effort 。。。? Still don't know
· Summarize afterwards and propose process improvement plan Two hours Two hours
Total

1. About the file format I designed:

Files are stored in TXT format (laughter)

All right..
The formal format is like this.
V1.0
Subway xxxx Line
Bidirectional travel/one-way driving
Station Name 1
Station Name 2
Station Name 3
......
Station name N
End

If it is a loop, the station name n must be equal to the station name 1 (although the station name N will not be printed at the end)

If it is a one-way street, you must complete the final position that the single-line section can reach in single-line direction
For example, the Airport line is:
Subway Airport Line
One Way Drive
Dong Zhi Men
Sanyuan Bridge
Terminal third
Terminal second
Sanyuan Bridge
End

(This will print out Sanyuan bridge)

The station name is sorted in a certain direction, and the line can be ordered randomly.
Two-way driving and one-way driving is because the subway Airport line is very wonderful, single and ring
Because the design I started with was:
A class named Subline, which instantiates every metro line, has a vector<string> station in the class that stores each

At the same time there is a bool:iscircle-and whether the loop
There's also a bool:istwodir, whether you can drive in two directions
When creating a Metro network, set both values according to the file read-in

There is also a class station, which instantiates the object to be each of the stations: It's not a half-penny relationship with the station on the upper class.

The process of the whole program is: Read file--build subline-> according to Subline established Station-> based on station and subline to establish adjacency matrix (in fact, only use the subline of the two bool) Then we can play happily (and not)

The reason for this is that the airport line is a one-way street, so it is declared within the file so that it is easier to construct the matrix

  However, I found that I was really naive, and my eyes were blind.

Because the airport line, apart from a single line, it is a part of the one-way street, so

V2.0
Subway xxxx Line
Bidirectional travel/one-way driving
Station Name 1
Station Name 2
Station Name 3
Bidirectional travel/one-way driving
......
Station name N
End
This setting is because:

I found out that my Subline class had been created, and it was awkward, so I removed the class, though I might have forgotten to delete the code ... It doesn't matter

This time I'm going to make a change to the part that reads the file. This station class has played a great role, this class has the name of the site and the line name two attributes, will all stations exist a vector, so that the most convenient to establish the adjacency matrix, because the adjacency matrix is the vector for the axis.
    
Now, explain V2.0.

In order to further meet the wonderful airport line.
When I read the file, I wrote something like a state machine that responds to the reading and the current state.
For example: When reading: "Metro XXX Line", a string will be used to store the name of the line, the station after the assignment
If read: Two-way travel, a flag is set to 2, and then after the name is read into the station, the corresponding part of the adjacency matrix can be placed according to the flag
This explains the two-way drive:
I gave the definition from a two-way drive/one-way drive to the next two-way drive/one-way drive, which can establish two-way connections with a station in the same line as the one adjacent to the vector.
See the code for details, so you can resolve loops and single and partial single-line sections
So this time I deleted the subline, in the establishment station at the same time, the establishment of the adjacency matrix, I think this time the function of the read file is more powerful, and can handle the more wonderful subway line

2. About improving Program performance

In the previous section I mentioned culling the Subline class, which reduced some meaningless memory footprint and simplified the program structure (although the number of lines of code did not change). Maybe it's because I'm wrapping my curly braces, and I'm just changing the line!! Not to fight!! )

About-B commands: I'm using the Dijkstra algorithm, and this Part I can't think of any other optimizations.

About-C command: Although the teacher said that the two commands have a relatively large difference. Burning Goose. I have been witty to crack.

Traditionally, all the possible solutions were figured out, and then sorted, but I didn't know how to do it, and I thought of it with a retrospective approach.

Finally, I do not know how to think of this problem, I just think of the comparison between the transfer and the number of subway stations, simply a one-time comparison. So we have this algorithm.

       Dijkstra Algorithm • Magic change

Although the ontology is still Dijkstra, here I need a function to assist it output, not. Assist it to calculate

The idea of this algorithm is: because at the beginning of the design, I did not integrate the transfer station, in my design, the transfer station is two station name the same, and belong to the subway line different station (this is the background),

In the-b command, the distance between the transfer stations is 0;

In the-C command, the distance between the transfer station is a very large value, at least greater than the number of metro stations in the subway line, in my code is 1000, if the use of a larger metro network, this value is greater,

But fortunately the biggest network in Shanghai has no more than 1000 stations

So this auxiliary function is settransport--set the transfer station between the weight of the function, if the-b command, the transfer station between the weight set to 0, if it is-C, then set to the

At the end of the comparison distance, the first comparison of thousands, and then compare 10 and a bit, so that the first to find a transfer of the least line, at the same time found the least transfer and shortest distance line,

Of course, this method also has a bug, that is, because of the same name of the transfer station there are many, when the starting point is the transfer station, the program does not know which line from a station up, to which line of B station,

So it is possible that this meaningless transfer increases the distance error, so I modified the Settransport, if the station called the starting point and the end point is the transfer station, the distance of these stations is set to 0, other usual.

Perfect Solution ~

     

void Settransportweight (String Start,String end,int weight, vector<station>All) {for (int i =0; I! = All.size (); i++) {for (Int J =0; j<i; J + +) { if (all[i]. Name = = All[j]. Name) { if (all[i]. Name = = Start | | All[i]. Name = = end) {Adj[i][j] = 0; adj[j][i] = 0; continue; / * Now this is a problem and needs to be restored, first of all, this will only affect the transfer station.
Then, you still need to update before the next run, if the last station as S\e did not act,
will be re-assigned to weight, in addition, because only when the S, E is the transfer station when the situation,
The rest of the transfer station as usual, so ... Theoretically no big problem */ } Adj[i][j] = weight; Adj[j][i] = weight;} }}}

 

      

(I don't know if this is the two.) Put it up for the time being. Don't care what I'm listening to)


3. The test case is as follows:
-B sha Henan Percussion Lane
-C sha Henan Gong gu Xiang
Because we can use Baidu map to verify (it doesn't matter)

(In fact, only some can.) After all, the teacher gave the old map)
Our daily choice of route is Zhu Xinzhun transfer, this is the most convenient, but actually the shortest line transfer three times
In fact, people in the choice of time to consider the transfer and other subway times, this is a very important factor, not light distance is short, so this may be the next step in the direction of optimization

-C-Shan Zhuang Zhang Guo
This should be the farthest two points of the whole subway line ...

-B Shahe Terminal second
It doesn't matter where it starts ... I just wanted to test that the single-line part of the airport line was set correctly.

-C Sanyuan Qiaodong straight Door
This ibid, I just want to test the two-line part of the airport line is not set correctly

  

  I'll go to your Airport line!



Terminal third, terminal second
Terminal second, terminal third
This is still ditto.

-C Apple Garden Tin Tong Court
-B apple Orchard Tian Tong Court
This is similar to the South Drum alley, but farther away, providing more transfers may

Terminal third, terminal third
I think this command should be only mentally retarded to knock it out. But just in case I'll try it. Then the program will crash. I'm awesome.

Subway Line Line 10
General tasks

Subway Balabala
Test Error command

-A Hasidohoas Shahe
Test a partial rule-compliant command

Askjdgas asdhkasodasd Ah Safir Hfoeazd DFDSF
Simulating Bear Kids


4. What have I learned in my personal project?

I am now familiar with the Beijing subway line. (And not)
The Dijkstra algorithm is used to find the shortest path of single source, and the last single source shortest path is BFS.
Roughly learned to use C + +. Two days to learn C + +. Last time was a week of accelerated Java. The last one week was a quick compilation. Such a quick approach, though fast enough to meet development needs, is less concise because of the lack of a deep understanding of the language.
Requirements must be analyzed well, otherwise the direction of writing code is not clear, the design phase as far as possible to think of more problems, or later will appear to fill good one old bug, a new bug occurred.

Be sure to choose the right way to behave your data. For example, the transfer station is comprehensive. If my transfer station is not set to two stations. Maybe after I think of the-C algorithm, I'll go back and change the part of the file read. And the parts of the adjacency matrix, and the like: That's the word. I'm simply lazy because I don't have an integrated transfer station. I can't believe that lazy people have lazy blessings.

or something like that.

Ah.. I also learned to use Git bash

Attached Code Link: https://github.com/ChildishChange/personal-application

  

Above.. Just so much

' Peace good. I went to read the textbook.

  

Software Engineering personal Projects

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.