Uva1456cellular Network (Probabilistic DP)

Source: Internet
Author: User
Tags rounds

Cellular Network

Description

A cellular network is a radio network made up of a number of cells each served by a base station located in the cell. The base station receives call signals from mobile users (mobiles) in the cell it serves, which then connects 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.

mobiles move from once cell to 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 are guaranteed to being in one of the 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 (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 C Ells 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 be modeled With n probability values, where the probability of the MO Bile being present in a cell can is estimated for each of These n cells at the time of a Call arrival. Let p i being the probability that the mobile was located at the Cell C I and all the probabilities is independent. A Sequential paging strategy is to page the cells sequentially in n Paging rounds Termin Ating 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:

(i x Pi), ( ix Pi).

TheParallel Paging StrategyIS-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. Let z1,z 2,..., zwBe the partition of theC(i.e., a partition ofCIntoWGroups), where each Ziis Non-empty and corresponds to a distinct paging zone. When a-call arrives for a mobile, the cells in the first paging zone Z1was paged simultaneously in the first round and then if the mobile was not found in the first round of paging, all the cell s in the second paging zone Z2is paged, and so on. Let the number of cells in the paging zone ZiBe denoted by ni = | Zi|, and letBeing the corresponding zone probabilities of the users in the paging zone Zi, where=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 the C Ells in the location area is partitioned.

For example, there is n = 5 cells in a location areaC = {c1, C2,..., C5} and the probability of each cells in C is as follows:


0.05 TD align= "Center" nowrap valign= "BASELINE" >
c I C 1 C 2 C 3 C 4 c 5
p I 0.3 0.1 < Span style= "font-size:18px" >0.3 0.25


If the cells in C is partitioned into paging zonesZ1 = {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) = 3x 0.45 + 5 X 0.55 = 4.1

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


If the cells in C is partitioned into paging zonesz1 = {c1, c4},z2 = {C2, C3, c5}, the average cost of paging,, and the average paging delay in L Ocating the mobile,is:


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

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


Given the number of cells in a location area C, the probabilities of each cells that a mobile is located at the C ell, and the fixed numberW of paging zones, write a program to partition the cells inC into w p Aging zones such that the average cost of paging to find the location of the the mobile is minimized.

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, where1wn. The second line of all test case containsNIntegersU 1, u2,..., un, where the probability PiFor each cell CIInchCIs pi = ui/(u1 + u2 + ... + uN). All integers in the second line is between 1 and 10,000.

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

Test instructions: The positioning of mobile phones in the honeycomb is a basic problem. Assuming the cellular network already knows that the phone is in C1, C2, c3,....cn, one of these areas, the simplest way is to find a cell phone in these areas at the same time. But this is a waste of time, because the cellular network can know the probability of the mobile phone in the different areas, so the tradeoff is to divide these areas into the W group, and then access. For example, you already know that the phone may be in 5 regions, the probability is 0.3, 0.05, 0.1, 0.3, 0.25, W = 2, one way is to first access {C1,C2, C3}, and then access {C

4,C5}, the mathematical expectation for the access area is (0.3+ 0.05+0.1) + (3+2) * (0.3+0.25) = 4.1. Another way to access the method is to access {C1,C4} at the same time, and then access {C2,C3, c5}, the mathematical expectation of the Access zone is (0.3+0.3) + (3+2) * (0.05+0.1+0.25) = 3.2.


the topic gives not a probability value, but a number of integers. u1,u2,u3,...un, the probability of a cell phone in Ci is Pi = UI/(U1+u2+u3+....+un).


Idea: a simple probability DP

First, the probability values of each region are sorted, and the probability of a large row in front. The processing of prefixes and, in this way can be divided into a continuous paragraph to deal with.

State transition equation:

DP [I,J] represents the minimum expected value of the first I, divided into J continuous interval, divides the former k-1 into j-1 continuous interval, and then k to I as a continuous interval. Traverse all k to find the minimum value.

DP [I,j] = min {dp [i,j],DP [k-1,j-1] + i * (p [i]-p [k-1] )}
Wherein 1 <= i <= n ,1 <= J <= W, 1 <= k <= i


<span style= "FONT-SIZE:18PX;" > #include <cstdio> #include <iostream> #include <cstring> #include <cmath> #include < string> #include <algorithm> #include <queue> #include <stack>using namespace Std;const int INF = 1 <<29;const Double PI = ACOs ( -1.0); const double e = 2.718281828459;const double eps = 1e-8;const int maxn = 110;DOUBL E P[maxn];d ouble dp[maxn][maxn];bool cmp (double x, double y) {return x > y;}    int main () {freopen ("In.txt", "R", stdin);    Freopen ("OUT.txt", "w", stdout);    int N, W;    int case;    cin>>case;        while (case--) {cin>>n>>w;        Double sum = 0;        memset (p, 0, sizeof (p));            for (int i = 1; I <= n; i++) {cin>>p[i];        Sum + = P[i];        } for (int i = 1; I <= n; i++) {p[i]/= sum;        } sort (p+1, p+1+n, CMP);        for (int i = 1; I <= n; i++) {P[i] + = p[i-1];    Fill (Dp[i], dp[i]+1+w, INF);                Initialize} for (int i = 1, i <= N; i++) {for (int j = 1; J <= W; j + +) { for (int k = 1; k <= i; k++) {Dp[i][j] = min (Dp[i][j], dp[k-1][j-1]+ (p[i]-                P[K-1]) *i);    }}} printf ("%.4f\n", Dp[n][w]); } return 0;} </span>


Uva1456cellular Network (Probabilistic DP)

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.