UVA 14,566 Cellular Network

Source: Internet
Author: User
Tags rounds

Cellular Network

Time Limit: 3000MS Memory Limit:0KB 64bit IO Format:%lld &%llu

SubmitStatusPracticeUVA 1456

A cellular network is a radio network made up of a number of cells each served by A base station located in the cell. T He base station receives call signals from mobile users (mobiles) in the cell it serves, which then C Onnects the calls to the wired Land-line telephone network. When a call was requested to connect to a mobile, the cellular network must know in which cell the mobile was located so tha T the call was routed to the base station of the cell appropriately.

The

Mobiles move from the once cell to the another in a cellular network. Whenever a mobile reports its new cell as it crosses boundaries of cells, the cellular network would know its exact cell a T any time and finding (paging) the mobile becomes a trivial task. But it's usually infeasible for a mobile-report it enters a new cell because of the Insuffi Ciencies of resources such as the radio bandwidth. But normally at the time of a call arrival, the cellular network knows a limited number of cells where the mobile is Locat Ed. In this situation, a lot of paging strategies is developed to locate a mobile efficiently. The ultimate goal of paging strategies is to minimize both the time delay and cost of paging until the mobile is found.

Now we define our problem formally. The location area is the Set of  n  cells  c  = { c 1,  c 2,...,   c N} such that the Mobile is guaranteed to being in one's these cells at the time of a call arrival. Suppose that it's possible to page no subset of These  n  cells in a unit of time ( Span class= "Textit" >paging rounds) and find out if the mobile are located in one of the cells paged. The fastest strategy to find the cell where the mobile is located are to page all The  n &nb Sp;cells in the first and only round. However this strategy uses a lot of wireless bandwidth.

In many cases, the cellular network knows about the whereabouts of the mobile. This knowledge can is modeled with n probability values, where the probability of the mobile being present in A cell can be estimated for each of these n cells at the time of a call arrival. Let PI being the probability that the mobile are located at the cell CI and all the probabilities AR E Independent. A Sequential paging strategy is to page the cells sequentially in n Paging rounds terminating once the mobile is found. Then the average cost of paging (number of cells paged), , and the average paging delay (number of paging rounds) in Locating the mobile,can be expressed as follows:

( Ix Pi), ( Ix Pi).

TheParallel paging strategy is to page the cells in a collection of cells simultaneously. Sequential paging strategy have lower paging cost than parallel paging strategy, but at the expense of larger paging delay. The method of parallel paging is to partition the cells in a location area into a series of indexed groups referred to asPaging zones. LetZ1,Z2,...,ZW Be the partitionC(i.e., a partition ofCIntoWGroups), where eachZI am non-empty and corresponds to a distinct paging zone. When a-call arrives for a mobile, the cells in the first paging zone Z1 is paged simultaneously in the first round and so if the mobile is not found in the first round of Pagi Ng, the cells in the second paging zone Z2 is paged, and so on. Let the number of cells in the paging zone Zi is denoted by ni = | zi|, and let is the corresponding zone probabilities of the users in the paging zone zi, whe Re = pJ. Then the average cost of paging (number of cells paged), , and the average paging delay (number of paging rounds) in Locating the mobile, D, can be expressed as follows:

= (),( Ix).

In parallel paging strategy, there are a tradeoff between bandwidth for time. For example, we increases the number of paging zones and then the paging cost could be decreased. If We decrease the number of paging zones, then the paging cost could is increased. Furthermore, for a fixed number W of paging zones, the paging cost could is different to the strategies how T He cells in the location area is partitioned.

For example, there is n = 5 cells in a location area C = {c1, C2,..., c< /C10>5} and the probability of each cells in C is as follows:

CI C1 C2 C3 C4 C5
PI 0.3 0.05 0.1 0.3 0.25


If the cells in C is partitioned into paging zones Z1 = {c1, C2, c3}, Z2 = {c4, C5}, the average cost of paging, , and the average paging delay In locating the mobile, is:


= N1 + (n1 + n2) = 3 (0.3 + 0.05 + 0.1) + (3 + 2) (0.3 + 0.25) = 3 x 0.45 + 5 x 0.55 = 4.1

= 1 +2 = 1 (0.3 + 0.05 + 0.1) + 2 (0.3 + 0.25) = 1 x 0.45 + 2 x 0.55 = 1.55


If the cells in C is partitioned into paging zones Z1 = {c1, c4} , Z2 = {c2, C3, C5}, the average cost of paging, , and the average paging Delay in locating the mobile, is:


= N1 + (n1 + n2) = 2 (0.3 + 0.3) + (3 + 2) (0.05 + 0.1 + 0.25) = 2 x 0.6 + 5 x 0.4 = 3.2

= 1 +2 = 1 (0.3 + 0.3) + 2 (0.05 + 0.1 + 0.25) = 1 x 0.6 + 2 x 0.4 = 1.4


Given the number of cells in a location area C, the probabilities of each cells, a mobile was located at The cell, and the fixed number W of paging zones, write a program to partition the cells in c into w paging zones Such, the average cost of paging to find the location of the mobile is Minimi Zed.

Input

Your program was to read from standard input. The input consists ofTTest cases. The number of test casesTis given on the first line of the input. Each test case consists of lines. The first line of each test case contains the integers. The first integer, N, is the number of cells in a location area, and the second integer, w, is the number of paging Zones, where 1wn100. The second line of all test case contains nintegers u1, u2,..., uN, whe Re the probability pi for each cell Ci in c is pi = u i/(u1 + u2 + ... + uN). All integers in the second line is between 1 and.

Output

Your program is-to-write to standard output. Print exactly one line for each test case. The line should contain the minimum average cost of paging to find the location of the mobile. The output should has a precision of exactly 4 digits after decimal point. Round to the 4 digits after decimal point or round off in the 4-th digit after decimal point.

The following shows sample input and output for both test cases.

Sample Input

2 5 2 30 5 10 30 25 5 5 30 5 10 30 25

Sample Output

3.2000 2.3000
1#include <stdio.h>2#include <string.h>3#include <algorithm>4 using namespacestd;5 6 BOOLcmpDoubleXDoubley)7 {8     returnX>y;9 }Ten  One Const Doubleinf=0x3f3f3f3f; A  - intMain () - { the     inti,j,k; -     intn,w; -     intT; -     Doubledp[ the][ the]; +     Doublea[ the],sum[ the]; -     Doubles; +scanf"%d",&T); A      while(t--) at     { -s=0; -scanf"%d%d",&n,&W); -          for(i=1; i<=n;i++) -         { -scanf"%LF",&a[i]); ins=s+A[i]; -         } toSort (A +1, a+n+1, CMP); +sum[0]=0; -          for(i=1; i<=n;i++) the         { *sum[i]=sum[i-1]+A[i]; $         }Panax Notoginseng  -dp[0][0]=0; the          for(i=1; i<=n;i++) +dp[i][0]=inf; A  the          for(i=1; i<=n;i++) +         { -              for(j=1; J<=i && j<=w;j++) $             { $dp[i][j]=inf; -                  for(k=0; k<i;k++) -                 { the                     if(J-1<=k) -Dp[i][j]=min (dp[i][j],dp[k][j-1]+i* (Sum[i]-sum[k])/s);Wuyi                 } the             } -         } Wu  -printf"%.4lf\n", Dp[n][w]); About     }     $     return 0; -}
View Code

UVA 14,566 Cellular Network

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.