1. MLM Numbers Game
- Posted by "C. K. Lester" <cklester at yahoo.com> Oct 12, 2001
- 416 views
Matthew and Dan, Here are your function results compared... For a population of 20000: Matthew Dan Soldiers 18945 18946 Squad Leaders 948 947 Lieutenants 95 94 Captains 10 9 Generals 2 1 Dan, the 947 squad leaders could only support a total of 18940. Your numbers show them supporting six more than possible using the parameters. Also, with 9 Captains, you'd need at least two generals (commanding 5 and 4 respectively). Matthew's results show that one of the squads will only have 5 soldiers, which is not enough to warrant a Squad Leader. However, I'm changing the parameters for matrix development with this: the lowest tier requirement is a "minimum." That is, a squad leader MUST have at least 20 soldiers, but CAN HAVE MORE than that if necessary. So, in Matthew's matrix, the six extra "soldiers" are actually each part of a group of 21 soldiers. This is a fine solution. Once Dan has fixed his version, I'd like to examine each method to see how they differ, how they approach the problem, and then run tests to see which way is more efficient. Thanks so much for your help with this! <\<
2. Re: MLM Numbers Game
- Posted by "C. K. Lester" <cklester at yahoo.com> Oct 12, 2001
- 424 views
(VIEW THIS EMAIL USING NON-PROPORTIONAL FONT!) Matthew, I used a test value of 10556. This should give us a General with one FULL leg. Your program worked fine {10000, 500, 50, 5, 1}. If you use 10557, however, you get TWO Generals! This extra guy should be in the soldiers tier. Is it possible to manage the matrix itself in a sequence variable? This might allow us to actually PLACE units instead of estimate where they'd be... For instance: Here's a matrix with one unit per tier, except for n soldiers: matrix = { {General, {Captain, {Lieutenant, {SquadLeader, {Soldier1, Soldier2,...SoldierN} } } } } } The matrix above wouldn't actually work... Compare to below for why... Here's a "full One General Matrix" using prerequisites of {2,2,2,2,1}: matrix = { {General, { -- General's downline {Captain1, { -- Captain1's downline {Lieutenant1, { -- Lieutenant1's downline {SquadLeader1,{Soldier1, Soldier2}}, {SquadLeader2,{Soldier3, Soldier4}}, }, -- end of Lt1 downline {Lieutenant2, { -- Lieutenant2's downline {SquadLeader3,{Soldier5, Soldier6}}, {SquadLeader4,{Soldier7, Soldier8}}, }, -- end of Lt2 downline } } } } ...??? sheesh! Okay, what I was trying to do was model the downline using a sequence. Maybe someone else can do better. Here's the matrix in outline form: General Captain 1 Lieutenant 1 Squad Leader 1 Soldier 1 Soldier 2 Squad Leader 2 Soldier 3 Soldier 4 Lieutenant 2 Squad Leader 3 Soldier 5 Soldier 6 Squad Leader 4 Soldier 7 Soldier 8 Captain 2 Lieutenant 3 Squad Leader 5 Soldier 9 Soldier 10 Squad Leader 6 Soldier 11 Soldier 12 Lieutenant 4 Squad Leader 7 Soldier 13 Soldier 14 Squad Leader 8 Soldier 15 Soldier 16
3. Re: MLM Numbers Game
- Posted by Mike Nelson <MichaelANelson at WORLDNET.ATT.NET> Oct 12, 2001
- 408 views
Here is a correction of my previous function: function get_tiers(integer pop,sequence tiers) --tiers is a sequnce of ratios, first element is ratio of --lowest level of leaders to grunts, second is ratio --of second-lowest level of leaders to lowest level, etc. --returns a sequence one longer than tiers, with the number of --each rank from grunts on up. --No error checking is done. integer num_tiers num_tiers=length(tiers) if num_tiers=0 then return {pop} end if tiers[1]+=1 for i=2 to num_tiers do tiers[i]=tiers[i]*tiers[i-1]+1 end for for i=num_tiers to 1 by -1 do tiers[i]=floor(pop/tiers[i]) pop-=tiers[i] end for return pop & tiers end function -- Mike Nelson
4. Re: MLM Numbers Game
- Posted by "C. K. Lester" <cklester at yahoo.com> Oct 12, 2001
- 420 views
Doesn't seem to work for the 10557 case... In fact, the matrix is only filled with 10556. > D'oh! I thought I could simply get away by checking the lowest rank. This > should work: > > --**************CHANGE THIS**************-- > if quo then > sum = quo > actual[ix] += sum > pop -= sum > for i = ix-1 to 1 by -1 do > sum *= required[i+1] > pop -= sum > actual[i] += sum > end for > else > pop += 1 > actual[ix+1] -= 1 > end if > --************************************-- > > --pop = remainder( pop , amount[ix] ) > ix -= 1 > end while > > if ix > 1 then > actual[ix] -= > > end if > > > > Is it possible to manage the matrix itself in a sequence > > variable? This > > might allow us to actually PLACE units instead of estimate > > where they'd > > be... > > I don't think you'd want something like that. Seems too difficult to > manage. However, you might set up something like an EDS table or simlply > use a-lists (EDS would probably be better for large populations, but Jiri's > a-list code is pretty easy to use): > > The key could be a name or whatever. You'd also store the rank, 'parent' > and 'children'. I'll simply put the 'key' as the first sequence element: > > {key, Rank, Parent, {Children (immediate)} > {Gen1, 5, {}, {Capt1, Capt2, Capt3, Capt4, Capt5}} > {Capt1, 4, Gen1, {lt1, lt2,...}} > > Now, you can find/add/delete as you like, and you can also assemble a tree > of people rather easily. Of course, if you delete, you'll need to remember > to update parent/children according to the rules of the organization (ie, do > you inheirit the children of a deleted child?} > > Matt Lewis > >
5. Re: MLM Numbers Game
- Posted by "C. K. Lester" <cklester at yahoo.com> Oct 12, 2001
- 426 views
Mike, seems to work. IMPORTANT NOTE: I've realized that EVERY level's prerequisite is simply a minimum. For instance, when there are 9 Captains, I thought there should be TWO generals, 5 for one and 4 for the other. But in our MLM scenario, it DOES NOT work this way. You cannot promote someone to general UNTIL there are 5 Captains for him to manage... So, Mike's get_tiers() function seems to work properly. Thanks, ck ----- Original Message ----- From: "Mike Nelson" <MichaelANelson at WORLDNET.ATT.NET> To: "EUforum" <EUforum at topica.com> Sent: Friday, October 12, 2001 2:35 PM Subject: Re: MLM Numbers Game > > Here is a correction of my previous function: > > function get_tiers(integer pop,sequence tiers) > --tiers is a sequnce of ratios, first element is ratio of > --lowest level of leaders to grunts, second is ratio > --of second-lowest level of leaders to lowest level, etc. > --returns a sequence one longer than tiers, with the number of > --each rank from grunts on up. > --No error checking is done. > integer num_tiers > num_tiers=length(tiers) > if num_tiers=0 then return {pop} end if > tiers[1]+=1 > for i=2 to num_tiers do > tiers[i]=tiers[i]*tiers[i-1]+1 > end for > for i=num_tiers to 1 by -1 do > tiers[i]=floor(pop/tiers[i]) > pop-=tiers[i] > end for > return pop & tiers > end function > > -- Mike Nelson > >
6. Re: MLM Numbers Game
- Posted by Dan Moyer <DANIELMOYER at prodigy.net> Oct 14, 2001
- 422 views
CK, I think my code oriented toward exactly what you have just understood, just as you originally specified. You originally specified that it was a matter of how many "up-levels" the lower levels could *support*, not the other way around, and that's what my code, I'm pretty sure, did. Could you re-examine your results of testing my code in light of your current understanding and original specifications? What you interpreted as wrong results should now be seen as right, I think. It appears that Mike's code is now similar in principle to mine, but done with superior simplicity. Mike's, I think, was originally essentially "programming" oriented, while mine was/is "math" oriented, in that mine took a solution to an equation and used that solution to determine the quantity in each tier; Mike's originally set up a "counting" type of solution, which was way longer in the *specific* instance (pre-defined support ratios, ie 20-10-10-5), but way *shorter* than mine in the generalized version (user specifies tier support ratios), though it didn't give correct results for the "up-support" conditions you originally specified. I had a suspicion that Mike's counting procedure would still be shorter and simpler than mine when corrected to your original specifications, and was looking forward to seeing that, but it looks like it was easier to make a simpler solution based on math equation solving than on counting, if I'm understanding our two methods correctly. Mike, good work! :) CK, thanks for the exercise! :) Dan ----- Original Message ----- From: "C. K. Lester" <cklester at yahoo.com> To: "EUforum" <EUforum at topica.com> Sent: Friday, October 12, 2001 1:07 PM Subject: Re: MLM Numbers Game > > Mike, seems to work. > > IMPORTANT NOTE: I've realized that EVERY level's prerequisite is simply a > minimum. > > For instance, when there are 9 Captains, I thought there should be TWO > generals, 5 for one and 4 for the other. But in our MLM scenario, it DOES > NOT work this way. You cannot promote someone to general UNTIL there are 5 > Captains for him to manage... So, Mike's get_tiers() function seems to work > properly. > > Thanks, > ck > > ----- Original Message ----- > From: "Mike Nelson" <MichaelANelson at WORLDNET.ATT.NET> > To: "EUforum" <EUforum at topica.com> > Sent: Friday, October 12, 2001 2:35 PM > Subject: Re: MLM Numbers Game > > > > Here is a correction of my previous function: > > > > function get_tiers(integer pop,sequence tiers) > > --tiers is a sequnce of ratios, first element is ratio of > > --lowest level of leaders to grunts, second is ratio > > --of second-lowest level of leaders to lowest level, etc. > > --returns a sequence one longer than tiers, with the number of > > --each rank from grunts on up. > > --No error checking is done. > > integer num_tiers > > num_tiers=length(tiers) > > if num_tiers=0 then return {pop} end if > > tiers[1]+=1 > > for i=2 to num_tiers do > > tiers[i]=tiers[i]*tiers[i-1]+1 > > end for > > for i=num_tiers to 1 by -1 do > > tiers[i]=floor(pop/tiers[i]) > > pop-=tiers[i] > > end for > > return pop & tiers > > end function > > > > -- Mike Nelson > > > > > >
7. Re: MLM Numbers Game
- Posted by Mike Nelson <MichaelANelson at WORLDNET.ATT.NET> Oct 15, 2001
- 431 views
My code with fuller comments: function get_tiers(integer pop,sequence tiers) --tiers is a sequnce of ratios, first element is ratio of --lowest level of leaders to grunts, second is ratio --of second-lowest level of leaders to lowest level, etc. --returns a sequence one longer than tiers, with the number of --each rank from grunts on up. --No error checking is done. --Comments below for the {20,10,10,5} test case integer num_tiers num_tiers=length(tiers) if num_tiers=0 then return {pop} end if tiers[1]+=1 -- for level 1 (ratio of 20) 20+1 = 21 needed to support 1 for i=2 to num_tiers do tiers[i]=tiers[i]*tiers[i-1]+1 -- for level 2 (ratio 10) 10*21+1 = 211 needed to support 1 -- for level 3 (ratio 10) 10*211+1 = 2111 needed to support 1 -- for level 4 (ratio 5) 5*2111+1 =10556 needed to support 1 end for for i=num_tiers to 1 by -1 do tiers[i]=floor(pop/tiers[i]) -- first pass calculates level 4's -- second pass calulates level 3's based on population -- reduced by number of level 4's, etc. pop-=tiers[i] -- reduce population end for -- original code was: -- tiers=floor(pop/tiers) -- for i=num_tiers to 1 by -1 do -- pop-=tiers[i] -- end for -- this calculates all the numbers at once using Euphoria sequences, but -- contains a subtle error: -- 2110 population will support 10 level 1's, but 2321 will not -- support 11 level 1's: 1 extra population is needed for the level 2! return pop & tiers end function -- Mike Nelson