Businessmen in travel and traveling saleman in negative world

Source: Internet
Author: User
In an article about search algorithms from search for prime numbers, this article mentions the prime number search algorithms, and roughly mentions some algorithms (algorithm) and search algorithms. Simply put, the search algorithm is to find qualified answers in a pile of input data that may be the answer. Previously, I mentioned in "Scheduling Problem and CPU scheduling" That Job-Shop problem is a very difficult Scheduling Problem (scheduling problem) and NP-complete. This article briefly introduces the search algorithm, how to use the search algorithm, the definition of NP-complete, and the dual problem ).

First,AlgorithmIs a bunchProcedure(STEP), includingStep by step, Step 1 to the last step, andBranch as neededWhen a situation is true, the execution goes one way. If it is not true, the execution goes another way, that is, the if-then-else process. It also includesReverse executionSome steps leave the loop until a certain situation is established or cannot be established, that is, the loop process. These projects are also included in general word or PowerPoint flowcharts!Search AlgorithmIt is almost a combination of the above three methods, and different steps are performed under different circumstances. So what is the question of "businessmen in Travel"? How can I find the answer to this question through search algorithms?

Merchant in travel merchant in travel 

Traveling Salesman Problem refers to a businessman who wants to visit n cities and know the costs of traveling between cities, only with minimal travel expenses can you visit every city, and each city just visits once.

Next let's take a look at what this problem requires.AnswerYes: the minimum travel expense is exactly one visit to every city. This problemInput materials(Input data) is the travel expenses required between cities. Possible answers and search for performance AlgorithmsPossible combinationYes: the order of cities to visit, for example, City 1, City 2 ,... , Until city n, or first visit City 1, then City 3, then City 4 ,... , City n, and finally visit City 2. The order of each visit varies with the travel expenses. The search algorithm needs to find a visit sequence in these combinations. The cheapest travel expense is the answer!

How can we list these combinations? Suppose there are four cities to visit today: Taipei, Kaohsiung, Beijing, and Shanghai. Then we marked the four cities on the map, connected them in a straight line, and wrote the travel expenses on it. Another step here is that it is important to solve the problem, that is, "abstraction 」.

Abstract abstract Abstract 

Abstract: when solving the problem, we only need to pay attention to the problem-related part. We can remove the irrelevant part first, so that we can focus on solving the problem. As in the preceding example, we do not need to pay attention to the size of each city 「Point. We do not need to pay attention to whether each city passes through the sea, mountains, and rivers. We only need to know the travel expenses between cities, so we use 「EdgeTo represent the connections between cities, and then write the travel expenses on it! Therefore, a map is abstracted 「PointAnd 「EdgeVerteces and edges, nodes and links.FigureGraph. The following is an example of the abstractFigure(Graph ).

 

Various Combinations, various combinations

So if there are n cities and each city just needs to be visited once according to the topic, how many steps are there in total? The answer is $ latex/frac {1} {2} (N-1 )! $. When N = 4, there are three steps. If T, K, B, and s are used in Taipei, Kaohsiung, Beijing, and Shanghai, the three steps are tbskt, tbkst, and tkbst. If you want to design an algorithm, that is, a bunch of steps to complete these steps, it can be like this:

(1) starting from

(2) list the sides that have not been visited at this point

(3) Walk along one of the unvisited sides

(4) If you go back to the starting point, and every city has just passed through once, the cost will be calculated and will be retained for the final comparison.

(5) Otherwise, determine whether there are other sides that have not been visited. If yes, return to step 2.

(6) Otherwise, go back to the point that has been taken before this point, and then repeat Step 2.

Algorithm performance Algorithm

We can see that there are three steps to play an algorithm: Step by step, branch according to different situations, and re-execute. Some problems can be computed using mathematical formulas, or the computer can run out the results using an algorithm. Although both of them use mathematics, they are used in different ways. For example, PCA (Principle Component Analysis) can be used for matrix calculation, or it can be obtained by a self-organized Map Neural Network, every point in a neural network performs a fixed step. However, when all neurons run together, the PCA solution can be computed from this neural network!

So what is the relationship between this problem and NP-complete? We can find that if you want to answer this question correctly, you have to combine the computing costs one by one and then find the cheapest way to go. NP is actually the abbreviation of non-deterministic polynomial, which means that the time complexity of Polynomial can be solved only on a non-deterministic Turing machine. I don't know if it will be scared. I have never heard of Turing machine or non-deterministic? This is also a long story. Let me try to explain it in white.

Jump past

First, Turing machine is a computing architecture proposed by Alan A. Turing in 1936. This machine hasRecord Space, There isRead/write HeadersWhich can be recognized by machines.Symbol table,Status record table, There is anotherAction Guidelines tableThe corresponding table is responsible for checking what the current machine is inStatus, Read and write headers nowWhat symbols are read?And then decide the next time,Whether to move the read/write header to the left or to the right,Machine statusThe status to be changed. This machine can simulate the basic architecture of each computer and evaluate the complexity of each algorithm. Therefore, in computer scienceComputing problemsWhen classification is performed, it is based on the Turing machine.

Deterministic corresponds to non-deterministic.DeterministicHere, it refers to the table corresponding to the code of conduct in the Turing Machine. Every time the status changes, the status of the previous step is determined, and the status of the next step is predictable.Non-deterministicEven if the status of the previous step is the same, the status of the next step is unpredictable and there are more than two possibilities. Therefore, the non-deterministic Turing machine has more computing power than the deterministic Turing machine. Therefore, it is also the time complexity of polynomial, And the NP problem will be more difficult than P. AsWhether NP is equal to PAnd is still unsolved. I think it is not easy to talk about it here. Readers who do not understand it can skip these two paragraphs and explain them in detail in another article later.

After knowing how NP is implemented, the definition of NP-complete is simple. If the problem isNPAndNP-hard, Then this problem isNP-complete. The previously mentioned Job-Shop problem and today's mentioned travelling salesman problem are all NP-complete problems. However, what is NP-hard? NP-hard refersA problem can be converted into another NP-complete problem.That is, NP-hard. That is to say, if the problem can be converted into the B problem, it means that if the B problem is solved, the problem will be solved, that is, the problem is more difficult than the B problem. (If you have learned the computing theory, we need to add that the reduction process requires Polynomial-reducible.) through this reduction process, we can always turn the contract into a single question.Tree of reduced relationships. For example

TSP is the travelling salesman problem mentioned today. In the figure, we can see that this problem can be converted into a Hamilton cycle problem, and then the Hamilton cycle problem can be converted into a vertex cover problem, to finalize it into a CNF-SAT problem (conjunctive normal form-satisfiability ). Today may not be a problem to slowly talk about, but this figure represents that, as long as the CNF-SAT to solve this problem, vertex cover will follow the solution, Hamilton cycle will follow the solution, then today's problem TSP will be solved!

 Dual Problem dual problem

Finally, we will mention dual problem ). The so-called dual problem is that the two problems are actually two sides,Solve one of the problems, and solve the other problem, even if the two problems do not look the same on the surface. For example, we have abstracted cities and routesPointAndEdge. If the problem to be solved today is that an ant wants to climb a plaster image with an angle, it needs to finish everySectionAnd then there are different costs between different slices. In this case, we canSection, Corresponding to the abstract response just nowPoint, TwoAdjacent section, Just nowAdjacent city. The two problems become the same.Dual ProblemNow!

The dual problem is something like in literature.CoupletOr crab canon in BAHA is a song with the same melody ). The RNA in the cell also has palindrome, that is, the reading sequence is the same in both directions. Couplets, duals, and battlesThere are the same places, AlsoThere are differencesTo show the beauty. The same is becausePart of speech(Part-of-speech) must be the same. The difference is thatWordIt must be different. This Chinese version is humorous and interesting. If you are interested, you may wish to see the beauty of the couplet!

Therefore, the dual problem is like 「Negative worldGenerally, it looks like another world in the mirror, a bit like a shadow world, or a world we live in.There are the same places, But againThere are differences. But most importantly,Solve one of the problems, and solve the other problem.. Therefore, this method is often used for dual problems, and the dual problems after conversion are easier to answer. At this time, the original problem is first converted into a dual problem. After the answer is obtained, then, convert the answer to the original question in the same way, and then become the answer to the original question.

Today, ourProbability TheoryThere are two important rules: (1) the probability of all events is equal to 1. (2) the probability of each event is greater than or equal to 0. If one person invented oneNew Probability TheoryTo make the probabilityNegativeOr evenVirtual numberIt may be a new probability of human civilization.Milestone(Negative probability ). From the beginning of this article, we have learned that, at least in the computer science field, there are so many issues waiting for solutions.Problem, There are so manyMethod. EachAnswerThe emergence of human civilization is a step forward. People who are interested in research will make us continue to work tirelessly, and humans will be able to continueProgressNow!

Wikipedia references

  • Travelling Salesman Problem
  • NP-complete
  • Turing Machine
  • Dual Problem
  • Palindrome
  • PCA (Principle Component Analysis)
  • Som (self-organized map)
  • Part-of-speech
  • Negative Probability

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.