2017 Huawei Elite Challenge Summary

Source: Internet
Author: User
Website of the competition:http://codecraft.huawei.com/ Game reading:http://mp.weixin.qq.com/s/on_l5Rc3Be-DjgUOXftaNw Case and compilation of official software packages:huawei_code_craft_2017_ Preliminary Competition software package (readme.txt in detail)

From 2017.3.15 to 2017.4.6, it took three weeks to invest in the 2017 Huawei elite Challenge. This is my first time to participate in this similar to the ACM algorithm competition, although the results from the first 32 strong finally fell out of the top 64 to the semi-finals, but really learned a lot of things. Great God many, master like Cloud, continue to work hard.

Share the experience of the game and summarize the efforts and work you have done in this challenge:

The graph above is the network topology diagram of the G province, the black Circle is the network node, the red circle is the consumption node, the number in the circle is the node number. The connection between nodes is a network link. In the tag on the link (x, y), x represents the total link bandwidth (in Gbps), and Y represents the network lease fee per Gbps. The number of consumer node-connected links is the bandwidth consumption requirement (in Gbps) of the consumption node.

Now assume that you need to deploy a video content server on this network to meet the needs of all consumer nodes. A lower cost scenario is shown in the following illustration (select 0,1,24 as the server), where the green circle represents the deployed video content server, and the network paths to the different consumer nodes are identified with a different color and are accompanied by the size of the bandwidth consumed:

through the analysis of the title of our team found that can be summed up in the following questions:

1. When selecting a server location, how to develop a strategy to provide bandwidth to the consumer nodes.

For example: as shown in the figure, select 0,1,24 as the server, how to make a strategy to meet the bandwidth requirements of all consumer nodes under the premise that the cost of the smallest.

2. How to select the location of the server.

L Initial Server Location selection problem

L Update server location policy issues

Answer:

for Issue 1:

The minimum cost maximum flow method, which is used to solve the minimum cost required to provide maximum bandwidth from one point to another, connects all servers to a single Super server (source point) and connects all consumer nodes to a single super consumption node (meeting point). For example, when selecting a server 0,1,24, the connection scenario is shown in the following illustration. Note: The source to the server bandwidth Unlimited, the cost of 0, one-way transmission, consumer nodes to the meeting point bandwidth for their own bandwidth required, the cost of 0, one-way transmission . At this point, you only need to calculate the minimum cost maximum flow from the source point to the meeting point. If the cost stream is maximum bandwidth < bandwidth required for all nodes and (that is, the bandwidth required by the meeting point), the selected server will not meet the requirements, or it will meet the requirements and calculate the minimum cost of the source point to the meeting point. Finally, add a single server cost * server number to get the total minimum cost.

If you do not connect and consider a problem like this, you will encounter problems with complex computational logic and slow computation in the calculation. Through continuous optimization, we finally in the data scale reached 800 points, the consumption node 360 points, calculate a cost flow of only about 10ms.

for Issue 2:

Method 1: This question is obviously a np-hard problem, the beginning we want to use the method of violence to solve, first with each consumer node directly connected to the network node placement server (that is, the initial server location selection, because this will guarantee that there are solutions), Then the global Network node considers that the collection of servers is either randomly used to subtract one, change one, or add a server, and then use each selected server collection to calculate the cost stream, storing the lowest cost stream. the iteration runs until the final convergence or the time limit for the problem runs. Among them, when reduce and add are random number randomly selected, and minus which network node is also randomly selected by random number, so as to ensure a certain randomness, to prevent falling into the local optimal (in fact, we still do not have a good solution to this problem).

Method 2: because when the data scale increases to a certain extent, the algorithm of Method 1 cannot converge in the 90s of the problem requirement, so a quicker convergence scheme is required. The second approach is to use a direct-attached approach to layout the initial server collection, and we only randomly subtract one or another from the current direct-attached server to the consumer node until it converges to a minimum cost of a server layout. so we're going to search for the solution in the 800-point Network node, it is obvious that our algorithm cannot find the global optimal solution in order to search the nodes in the network node directly connected with 360 nodes, but it can converge to a smaller cost in a limited time. because has been in the direct Connection network node search, so the server unit price is not high situation or have a good solution. And because has been in direct connection calculation of the cost flow, in the specified time to calculate the cost of the flow time reduced a lot, so in the big case has a good solution. In large cases (800 network nodes) we test that the number of iterations can be as many as 30,000 times, while the first method is only 3,000 times faster, 10 times times quicker. It's a good idea to pursue the best solution in a limited time in a big case, thanks to the good results we have achieved in the case of large-scale competitions.

Method 3: In fact, it is obvious that the above two methods will encounter the problem of the local optimal solution, once we fall into a local optimal solution does not jump out, obviously still need a heuristic method, classical algorithms such as ant colony, mountain climbing, simulated annealing, genetic algorithm, particle swarm, etc. We can consult the relevant papers, these are classic tsp problem is a good solution, used here is certainly feasible. We finally used the server site is simulated annealing , the algorithm is simple and fast, this is our third algorithm. The third method initializes or uses a direct-attached method, each random add a server, minus one or another, but we do not set this probability to death, not to the current cost does not reduce the effect of the decision to abandon this choice, but with a certain probability to accept it, and this probability with the iterative depth slowly reduced, This is the classical simulated annealing algorithm, to some extent, can avoid falling into the local optimal.

methods to be implemented:

But unfortunately, the idea is very good, because there is no experience, after two days to adjust our effect is still not ideal, did not resolve into the local best predicament. The problem was not resolved until the end of the game, and unfortunately did not enter the semi-finals.

In fact, the best way to solve the local problem is to increase the randomness, one is to select the server time to increase randomness, here rand () so the use of time as a srand parameter is naturally the best.

In addition to the randomness of the initial server, so once the results converge we should restart and continue the search, but unfortunately this method we do not have time to practice, is the server layout do not choose direct connection, but the global random selection of the same number of nodes with the same server, and then many choices until convergence.

Finally, there is a thought that after simulated annealing, the acceptance probability will be smaller and less, into the local optimal solution. Then we should warm up the temperature, that is, accept the probability of return to a certain value, cool again, so repeated.

I think we failed is defeated here, some regret, in the end to want to understand. Other people's methods I do not know, there may be some more inspired selection methods, we also based on each network node to design each network node to select the weight of the server, natural out of the big situation we would prefer it to be selected as a server, but the final effect is not satisfactory. When the game is over, look at the code of the Great Gods, and worship and rethink the problem.

we have done the optimization case:

The whole process, we have done a lot of optimization of the algorithm, although we do not escape the local optimal solution of the predicament, but I dare say our minimum cost and the whole algorithm optimization is the top. The speed with which they share in the discussion group is not as fast as ours.

There are mainly the following optimizations:

1, regardless of the intermediate route layout in the calculation of the cost flow, we optimize the multi-source multiple-sink problem into unit pair unit, that is, the simulation design two super nodes, one connecting all servers, one connecting all the consumption nodes, the whole process is simplified as the single-source of the single sink cost flow;

2, every iteration does not have to reload all the graph data, we use individual data reduction and then again to the next round of the minimum cost flow calculation can;

3, the server collection storage, we use the Standard Template Library in the set data structure is actually the best, the first server will not repeat set is very consistent with this nature, the second set is based on the red-black tree implementation, insert Delete is very fast, so use set than any other data structures are better, This design allows us to improve the efficiency of the algorithm a lot;

4, in various cycles, should consider its early termination of the situation, to avoid meaningless calculation.

The above is my summary, although unfortunately did not enter the semi-finals, but the process has learned a lot, continue to refuel.

Finally, provide our code: Https://github.com/DUTFangXiang/2017HuaWei_CraftCode

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.