Wednesday, April 12, 2017

We have been discussing Inventory with techniques for organization. These techniques were based on storage. However, when business needs change, the organization may have to classify their resources to meet different expectations. If they were all storage based, then there would be far too many changes to the storage since business requirements can change very often. On the other hand many requirements don't translate to assets as they relate better with tiers. Software engineers come up with an interesting technique of separating the requirements from the resource organization. The former called groups is dynamic and is represented by rules  and policies while the latter called pools is more static and remains a system design. 
The organization of the application is such that the static and the dynamic parts are separated lending more stability while reusing existing organization against more and more changes. As an example the inventory may meet different servicing groups and the assets may move only in and out of pools. To the inventory the groups and policies don't matter and they can be partitioned or load balanced accordingly. They can scale independently from the groups or can have resources throttled. By letting groups migrate between pools, we can change the services for the groups without having to change the pools.  
Accounting and performance are both improved by this design. The assignment of the groups helps with both. The assignment is based on logic which can encompass many criteria that are not necessarily part of the assets information in the inventory.  For example, an individual customer may have better servicing than others. Both the logic and the pool organization become an administrator's arsenal and lets her make changes to the user friendly groups with changes to the criteria on which the group is assigned while allowing maintenance chores and partitioning of resources in the backend. 
Assets servicing a group also enables group throttling. This is particularly useful when groups are not well behaved.  The statistics is collected by the pools which keeps track of request rates.  The same determination is used for load balancing. Automatic load balancing can now be based on pool partitioning approach and the group based throttling.  This improves multi-tenancy in the environment as well as handling of peaks in traffic patterns. And the algorithm can be adaptive even choosing appropriate metrics to determine traffic patterns that are better known and have been handled before.   
Moreover traffic patterns can now be better analyzed with this organization and changed  on demand with little disruption.
#codingexercise
We were looking at an exercise involving count of all numbers formed by subsequences in  the digits representing a number. We stated that this is in fact represented by  binomial coefficients. Let's take an example and see the pattern:
a0, a1, a2
can be combined as a0 + a1 + a2  + a0a1 + a1a2 + a0a2 + (a0a1a2 ) resulting in 3C1 + 3C2 + 3C3 = 7 subsequences
Since we know the individual count of increasing length subsequences, we can now easily count different kinds of subsequences. For example, to count odd length subsequences only we do 
Int GetCount(List<int>A, int start, int end)
{
If (start>end) return 0;
If (start==end)return A[start];
int count= 0
For (int n = 1; n <=A.Count; n=n+2) // odd length subsequences
       count += GetNChoosekDP(A.Count, n)
Return count;
}
int GetNChooseKDP(uint n, uint k)
{
if (k == 0 || k == n)
    return 1;
return GetNChooseKDP(n-1, k-1) + GetNChooseKDP(n-1,k);
}
It is also interesting to note that the enumeration of the subsequences corresponding to each binomial coefficient k can be done by selecting the combinations with length corresponding to the binomial coefficient.

No comments:

Post a Comment