1. Army Composition

For a given population, what is the maximum number of persons at each rank?

Soldiers - no requirements
Squad Leader - commands 20 soldiers
Lt. - commands 10 Squad Leaders
Captain - commands 10 Lt.s
General - commands 5 Captains

I need a EUPHORIA program to compute these values given a population.

Who's got one?

Thanks!
ck

new topic     » topic index » view message » categorize

2. Re: Army Composition

First, how many Generals are there per people in the population?

Euman
euman at bellsouth.net

----- Original Message ----- 
From: "C. K. Lester" <cklester at yahoo.com>
To: "EUforum" <EUforum at topica.com>
Subject: Army Composition


> 
> For a given population, what is the maximum number of persons at each rank?
> 
> Soldiers - no requirements
> Squad Leader - commands 20 soldiers
> Lt. - commands 10 Squad Leaders
> Captain - commands 10 Lt.s
> General - commands 5 Captains
> 
> I need a EUPHORIA program to compute these values given a population.
> 
> Who's got one?
> 
> Thanks!
> ck
> 
> 
>

new topic     » goto parent     » topic index » view message » categorize

3. Re: Army Composition

I want to know how many a certain population can support.

If I have 2 million people, how many will be soldiers, how many Generals,
and how many of each rank in between... You have to build it from the bottom
up... Maybe there won't be any generals if the population isn't over a
certain number...

Don't let the military designations confuse things. This isn't strictly a
military problem as much as it is a tiered-organization problem.

Thanks!
ck

----- Original Message -----
From: <euman at bellsouth.net>
To: "EUforum" <EUforum at topica.com>
Sent: Wednesday, October 10, 2001 1:35 PM
Subject: Re: Army Composition


>
> First, how many Generals are there per people in the population?
>
> Euman
> euman at bellsouth.net
>
> ----- Original Message -----
> From: "C. K. Lester" <cklester at yahoo.com>
> To: "EUforum" <EUforum at topica.com>
> Sent: Wednesday, October 10, 2001 11:46
> Subject: Army Composition
>
>
> > For a given population, what is the maximum number of persons at each
rank?
> >
> > Soldiers - no requirements
> > Squad Leader - commands 20 soldiers
> > Lt. - commands 10 Squad Leaders
> > Captain - commands 10 Lt.s
> > General - commands 5 Captains
> >
> > I need a EUPHORIA program to compute these values given a population.
> >
> > Who's got one?
> >
> > Thanks!
> > ck

new topic     » goto parent     » topic index » view message » categorize

4. Re: Army Composition

Hey, Cassidy...

Not everybody in the population will (can) be soldiers. For instance, if I
have a population of 20000, I won't have 20000 soldiers... Some of those
20000 will be Squad Leaders, LTs, Captains, and maybe Generals.

I'm going to try and work with your program, but maybe you can beat me to
it.

Thanks,
ck

----- Original Message -----
From: "Cassidy Napoli" <gonzotek at yahoo.com>
To: "EUforum" <EUforum at topica.com>
Sent: Wednesday, October 10, 2001 1:30 PM
Subject: RE: Army Composition


>
> I'm no good at math (read: really, really bad), so this may be totally
> wrong.  But I like the challenge and I'd like to see the correct code if
> mine isn't it.
> [code]
> --Rank over Population Problem
> --By A. Cassidy Napoli
>
> --For a given population, what is the maximum number of persons at each
> rank?
>
> --Soldiers     no requirements
> --Squad Leader commands 20 soldiers
> --Lieutenant   commands 10 Squad Leaders
> --Captain      commands 10 Lt.s
> --General      commands 5  Captains
> include get.e
> integer population,soldier,leader,lieutenant,captain,general
>
> population = prompt_number("Population Size: ", {})
> soldier    = floor(population / 1)
>
> leader     = floor(soldier / 20)
> if remainder (leader,20) then leader += 1 end if
>
> lieutenant = floor(leader / 10)
> if remainder (lieutenant,10) then lieutenant += 1 end if
>
> captain    = floor(lieutenant / 10)
> if remainder (captain,10) then captain += 1 end if
>
> general    = floor(captain / 5)
> if remainder (general,5) then general += 1 end if
>
> puts(1, "Population: ")
> ? (population)
>
> puts(1, "Soldiers: ")
> ? (soldier)
>
> puts(1, "Squad Leaders: ")
> ? (leader)
>
> puts(1, "Lieutenants: ")
> ? (lieutenant)
>
> puts(1, "Captains: ")
> ? (captain)
>
> puts(1, "Generals: ")
> ? (general)
> [end code]
>
>
> C. K. Lester wrote:
> > I want to know how many a certain population can support.
> >
> > If I have 2 million people, how many will be soldiers, how many
> > Generals,
> > and how many of each rank in between... You have to build it from the
> > bottom
> > up... Maybe there won't be any generals if the population isn't over a
> > certain number...
> >
> > Don't let the military designations confuse things. This isn't strictly
> > a
> > military problem as much as it is a tiered-organization problem.
> >
> > Thanks!
> > ck
> >
> > ----- Original Message -----
> > From: <euman at bellsouth.net>
> > To: "EUforum" <EUforum at topica.com>
> > Sent: Wednesday, October 10, 2001 1:35 PM
> > Subject: Re: Army Composition
> >
> >
> > > First, how many Generals are there per people in the population?
> > >
> > > Euman
> > > euman at bellsouth.net
> > >
> > > ----- Original Message -----
> > > From: "C. K. Lester" <cklester at yahoo.com>
> > > To: "EUforum" <EUforum at topica.com>
> > > Sent: Wednesday, October 10, 2001 11:46
> > > Subject: Army Composition
> > >
> > >
> > > > For a given population, what is the maximum number of persons at
each
> > rank?
> > > >
> > > > Soldiers - no requirements
> > > > Squad Leader - commands 20 soldiers
> > > > Lt. - commands 10 Squad Leaders
> > > > Captain - commands 10 Lt.s
> > > > General - commands 5 Captains
> > > >
> > > > I need a EUPHORIA program to compute these values given a
population.
> > > >
> > > > Who's got one?
> > > >
> > > > Thanks!
> > > > ck
> >
> >
>

new topic     » goto parent     » topic index » view message » categorize

5. Re: Army Composition

Matthew... Zowie! Thanks for the math lesson.

I had to modify your program for a few typos... and I made a few other
aesthetic changes. HOWEVER, it doesn't work properly... Check this out:

include get.e

sequence required, amount, actual, ranks
atom pop, startpop
object junk

pop = rand(1000000)

pop = 20000 -- for testing purposes
startpop = pop

required = {1,20,10,10,5}
ranks = { "Soldier", "Squad Leader","Lieutenant","Captain","General" }

amount = repeat(0,length(required))
actual = amount

function product( sequence mult )
  atom p
  p = 1
  for i = 1 to length( mult ) do
    p *= mult[i]
  end for
  return p
end function

-- first calculate required number for each rank
atom sum
for i = length(required) to 1 by -1 do
  sum = product( required[1..i] )
  amount[i..length(required)] += sum
end for

atom quo
integer ix
ix = length( actual )
-- next calculate amount of each for a population
while ix and pop do
  if ix < length( actual ) then
    actual[ix+1] += 1
    -- account for overflow
  end if
  quo = floor( pop / amount[ix] )
  sum = quo
  for i = ix to 1 by -1 do
    sum *= amount[i]
    actual[i] += sum
  end for
  pop = remainder( pop , amount[ix] )
  ix -= 1
end while

puts(1,"\nFor a population of ")
? startpop
puts(1,"...\n")

for t=1 to length(actual) do
 puts(1,"\n" & ranks[t] & "(s) = ")
 ? actual[t]
end for

junk = wait_key()



----- Original Message -----
From: "Matthew Lewis" <matthewwalkerlewis at YAHOO.COM>
To: "EUforum" <EUforum at topica.com>
Sent: Wednesday, October 10, 2001 2:48 PM
Subject: RE: Army Composition


>
>
> Here's how I'd solve this:
>
> You need to know the total number of people, which means you need to know
> the soldiers (p), squad leaders (s), lt's (l), captains (c) and generals
> (g).
>
> It's almost like a factorial.  First calclulate the soldiers that one
> general would have under him:
>
> 5 * 10 * 10 * 20 = 10,000
>
> Next, the squad leaders:
> 5 * 10 * 10 = 500
>
> Lt:
> 5 * 10 = 50
>
> Captain:
> 5
>
> Plus one for the general gives you 10,556.
>
> I'm not sure how you want to deal with remainders, but you can either
> 'overburden' one commander with more than these levels, or have one with
> just a fraction of the amount laid out.
>
> I'd do the same calculations for the lower ranks, and start subtracting:
>
> g = 10,556
> c = 2,221
> l = 211
> s = 21
>
> I'd keep these values in a sequence, and here'd be the code:
>
> sequence required, amount, actual
> atom pop
>
> pop = rand(1000000)
> required = {1,20,10,10,20,5}
> amount = repeat(0,length(required))
> actual = amount
>
> function product( sequence mult )
>   atom p
>   p = 1
>   for i = 1 to length( mult ) do
>     p *= mult[i]
>   end for
>   return p
> end function
>
> -- first calculate required number for each rank
> atom sum
> for i = length(required) to 1 by -1 do
>   sum = product( required[1..i] )
>   amount[i..length(required)] += sum
> end for
>
> atom quo
> integer ix
> ix = length( actual )
> -- next calculate amount of each for a population
> while ix and pop do
>   if ix < length( actual ) then
>     actual[ix+1] += 1
>     -- account for overflow
>   end if
>   quo = floor( pop / amount[ix] )
>   sum = quo
>   for i = ix to 1 by -1
>     sum *= amount[i]
>     actual[i] += sum
>   end for
>   pop = remainder( pop / amount[i] )
>   ix -= 1
> end while
>
> ? actual
>
>
> Unfortunately, I can't test this right now, but it should calculate for an
> arbitrary number of ranks (just change the initial sequences) with
whatever
> requirements you're looking for.
>
> Matt Lewis
>
>
> -----Original Message-----
> From: C. K. Lester [mailto:cklester at yahoo.com]
>
> For a given population, what is the maximum number of persons at each
rank?
>
> Soldiers - no requirements
> Squad Leader - commands 20 soldiers
> Lt. - commands 10 Squad Leaders
> Captain - commands 10 Lt.s
> General - commands 5 Captains
>
> I need a EUPHORIA program to compute these values given a population.
>
> Who's got one?
>
>

new topic     » goto parent     » topic index » view message » categorize

6. Re: Army Composition

eeewwww. That was yucky. :)

----- Original Message ----- 
From: "Cassidy Napoli" <gonzotek at yahoo.com>
To: "EUforum" <EUforum at topica.com>
Subject: RE: Army Composition


> 
> Sorry, I messed up the formatting using Topica's web
> interface.  Here's an attachment of the code I think works.
> 
> =====
> 
> Content-Type: application/octet-stream; name="pop.ex"
> Content-Transfer-Encoding: base64

new topic     » goto parent     » topic index » view message » categorize

7. Re: Army Composition

Cassidy...

Running the program you sent me, it shows 18889 soldiers and 999 Squad
Leaders. 18889 soldiers won't support more than 944 Squad Leaders, so there
must be a problem somewhere...

-ck

----- Original Message -----
From: "Cassidy Napoli" <gonzotek at yahoo.com>
To: "EUforum" <EUforum at topica.com>
Subject: RE: Army Composition


>
> Hmmm...Seems needlessly complicated.  Does this meet the reqirements?
> [code]

<snippage occurred>

new topic     » goto parent     » topic index » view message » categorize

8. Re: Army Composition

C.K.,

Ok, how about this:

--<code begins>
include get.e
include misc.e


integer s, sql,lt,cp,gn, p
sequence quitYn

while 1 do
p = prompt_number("enter the population of soldiers: " , {0,1073741823} )

 s = floor(10000*p/10556)
 sql = floor(s/20)
 lt = floor(sql/10)
 cp = floor(lt/10)
 gn = floor(cp/5)

puts(1, "population: " & sprint(p) & "\n")
puts(1, "soldiers: " & sprint(s) & "\n")
puts(1, "squad leaders: " & sprint(sql) & "\n")
puts(1, "Lts.: " & sprint(lt) & "\n")
puts(1, "Cptns.: " & sprint(cp) & "\n")
puts(1, "Generals: " & sprint(gn) & "\n")
puts(1, "total: " & sprint( s + sql + lt + cp + gn) & "\n")

quitYn = prompt_string("quit, y/n?")
if equal("y", quitYn) then
   exit
end if


end while

--<code ends>

I would suggest you rethink your terms, though, because this is really an
ARMY, not a POPULATION;  a population of x could not support an army of x,
your civilian population must generally be larger than your army.

Also, the "excess" should probably be folded into the ranks of the soldiers,
I would think.  I didn't do that, I'll leave it to you, :)

Dan Moyer


----- Original Message -----
From: "C. K. Lester" <cklester at yahoo.com>
To: "EUforum" <EUforum at topica.com>
Sent: Wednesday, October 10, 2001 9:46 AM
Subject: Army Composition


>
> For a given population, what is the maximum number of persons at each
rank?
>
> Soldiers - no requirements
> Squad Leader - commands 20 soldiers
> Lt. - commands 10 Squad Leaders
> Captain - commands 10 Lt.s
> General - commands 5 Captains
>
> I need a EUPHORIA program to compute these values given a population.
>
> Who's got one?
>
> Thanks!
> ck
>
>
>

new topic     » goto parent     » topic index » view message » categorize

9. Re: Army Composition

C.K.,

The number "10556" was  calculated by simple algebra:

--Soldiers - no requirements
--Squad Leader - commands 20 soldiers
--Lt. - commands 10 Squad Leaders
--Captain - commands 10 Lt.s
--General - commands 5 Captains


-- soldiers + squad leaders + Lts. + Captains + Generals = Population
(army!)
--s + (s/20) + ((s/20)/10) + (((s/20)/10)/10 ) + ((((s/20)/10)/10)/5)= P
-- s + s/20  +  s/200 +  s/2000  + s/10000 = p
-- 10000s + 500s + 50s + 5s + s = 10000p
-- 10556s = 10000p
-- s = 1000p/10556


I don't understand what you mean by "4 levels and 6 levels" of rank.  You
only specified 5 levels of rank.

If you want to find out how many different ranks there are, just look at
each rank var, if not zero, increment a "NumberOfRanks" counter.

I didn't really understand what you're doing with the matrix, either, and
the change in your rank system,
ranks = { "Soldier" , "Leader" , "Captain" , "Sergeant" , "General" }
seems wrong, it should be:
ranks = { "Soldier" , "Leader" , "Sergeant" ,"Captain"  , "General" }

Can you explain more about what you mean by
"determine at
> -- run time the number of different "levels" of rank."
if it's not what I suggested above?

Dan


----- Original Message -----
From: "C. K. Lester" <cklester at yahoo.com>
To: "EUforum" <EUforum at topica.com>
Sent: Wednesday, October 10, 2001 7:41 PM
Subject: RE: Army Composition


>
> Okay, Dan, I've made a few modifications to your code. Let me know what I
> need to do to resolve the questions I've peppered therein... :)
>
> --<code begins>
> include get.e
> include misc.e
>
> function product( sequence x )
> atom prod
> prod = x[1]
> for t=2 to length(x) do
> prod = prod * x[t]
> end for
> return prod
> end function
>
> integer s, sql,lt,cp,gn, p, total, matrixLeg
> sequence matrix, ranks
>
> -- I eventually want to be able to determine at
> -- run time the number of different "levels" of rank.
> -- For instance, I'd like to run stats on 4 levels
> -- and 6 levels of rank for a given population.
> -- So, instead of s, sql, lt, cp, and gn, I'll have
> -- Level[1], Level[2], Level[3],..., Level[n]
>
> ranks = { "Soldier" , "Leader" , "Captain" , "Sergeant" , "General" }
> matrix = { 1, 20 , 10 , 10 , 5 }
>
> if length(ranks) != length(matrix) then
> puts(1,"ERROR! Length of ranks does not equal length of matrix.\n")
> abort(0)
> end if
>
> matrixLeg = product( matrix )
>
> while 1 do
> p = prompt_number("enter the population of soldiers (0=quit): " ,
> {0,1073741823} )
>
> if p=0 then exit end if
>
>  s = floor(matrixLeg*p/10556) -- how is 10556 calculated?
>  sql = floor(s/matrix[2])
>  lt = floor(sql/matrix[3])
>  cp = floor(lt/matrix[4])
>  gn = floor(cp/matrix[5])
>
> total = s+sql+lt+cp+gn
> s = s + (p-total)
>
> puts(1, "matrixLeg: " & sprint(matrixLeg) & "\n")
> puts(1, "population: " & sprint(p) & "\n")
> puts(1, ranks[1]&"(s): " & sprint(s) & "\n")
> puts(1, ranks[2]&"(s): " & sprint(sql) & "\n")
> puts(1, ranks[3]&"(s): " & sprint(lt) & "\n")
> puts(1, ranks[4]&"(s): " & sprint(cp) & "\n")
> puts(1, ranks[5]&"(s): " & sprint(gn) & "\n")
> puts(1, "total: " & sprint( s + sql + lt + cp + gn) & "\n")
>
> end while
>
> --<code ends>
>
>
>

new topic     » goto parent     » topic index » view message » categorize

10. Re: Army Composition

C..K.,

Would this be a "real-time" recalc of number of tiers?

That is, in either the beginning or course of use of your program, would
there be a query (or other opportunity to set):  "how many tiers of managers
do you want?", or would this be a pre-set for each application?

Dan


----- Original Message -----
From: "C. K. Lester" <cklester at yahoo.com>
To: "EUforum" <EUforum at topica.com>
Sent: Wednesday, October 10, 2001 8:32 PM
Subject: RE: Army Composition


>
> Hey, Dan, thanks for the help. All truth will soon be revealed.
>
> > The number "10556" was  calculated by simple algebra:
> >
> > --Soldiers - no requirements
> > --Squad Leader - commands 20 soldiers
> > --Lt. - commands 10 Squad Leaders
> > --Captain - commands 10 Lt.s
> > --General - commands 5 Captains
> >
> >
> > -- soldiers + squad leaders + Lts. + Captains + Generals = Population
> > (army!)
> > --s + (s/20) + ((s/20)/10) + (((s/20)/10)/10 ) + ((((s/20)/10)/10)/5)= P
> > -- s + s/20  +  s/200 +  s/2000  + s/10000 = p
> > -- 10000s + 500s + 50s + 5s + s = 10000p
> > -- 10556s = 10000p
> > -- s = 1000p/10556
> >
> >
> > I don't understand what you mean by "4 levels and 6 levels" of rank.
You
> > only specified 5 levels of rank.
>
> Right. But "What If" I needed to calculate for a differently leveled
> organization? What if my calculations required a 4-tier organization or a
> 6-tier organization, other than the 5-tier organization we've hard coded
so
> far...?
>
> What if we had { "Soldier" , "Leader" , "Captain" , "General" }?
>
> > If you want to find out how many different ranks there are, just look at
> > each rank var, if not zero, increment a "NumberOfRanks" counter.
>
> Yeah. That's what I mean. But how to implement? That's what I need to
know.
>
> > I didn't really understand what you're doing with the matrix, either,
and
> > the change in your rank system,
> > ranks = { "Soldier" , "Leader" , "Captain" , "Sergeant" , "General" }
> > seems wrong, it should be:
> > ranks = { "Soldier" , "Leader" , "Sergeant" ,"Captain"  , "General" }
>
> Okay! Sounds right to me. But anything would.
>
> I'm just using familiar labels. We could also be using
>
> { "Pion" , "Assistant Manager" , "Manager" , "VP" , "President" }
>
> or something similar. The labels aren't what's important... It's the
tiered
> organization that matters.
>
> Hopefully I've shed a little light on the above.
>
> -ck

new topic     » goto parent     » topic index » view message » categorize

11. Re: Army Composition

Derek,

C.K. can correct me if I'm wrong, but I think he intends to approach it
backwards from your assumption, namely  that there will *always* be grunts,
but only any generals if there are enough grunts to support them.  So in an
army of 4, there'd only be 4 grunts, period, I think?  Of course, it's also
possible he hadn't considered this possibility :)


He said:
<
I want to know how many a certain population can support.

If I have 2 million people, how many will be soldiers, how many Generals,
and how many of each rank in between... You have to build it from the bottom
up... Maybe there won't be any generals if the population isn't over a
certain number...>

Dan

----- Original Message -----
From: "Derek Parnell" <ddparnell at bigpond.com>
To: "EUforum" <EUforum at topica.com>
Sent: Wednesday, October 10, 2001 9:28 PM
Subject: RE: Army Composition


>
>
> C. K. Lester wrote:
> > For a given population, what is the maximum number of persons at each
> > rank?
> >
> > Soldiers - no requirements
> > Squad Leader - commands 20 soldiers
> > Lt. - commands 10 Squad Leaders
> > Captain - commands 10 Lt.s
> > General - commands 5 Captains
> >
> > I need a EUPHORIA program to compute these values given a population.
> >
> > Who's got one?
>
> Here is my humble attempt. But first a few assumptions need to be
> stated.
>
> There is a precedence involved, such that we must have at least one of
> each rank, except if there are not enough people to fill all stations.
> Using the ranks above, if there was only an army of 4, then we would
> have a General, a Captain, a Lt, and a Squad leader, but no grunts.
>
> So, each SL can handle 20 grunts plus him/herself thus a maximum of 21
> people are involved for each SL. A Lt can handle 10 SL plus him/herself,
> thus as there as 21 people for each SL it means that for a Lt there is a
> maximum of 10 * 21 + 1 = 211. And so on up the line. This means that a
> General can have as many as 10556 people under him/herself.
>
> So for every 10556 people (or fraction thereof) we need a General.
> Taking the Generals out of the remaining corp size, we can then see how
> many Captains are needed for the remaining people. Etc...
>
> Anyhow, here is a generalised program that does all these calcs...
>
> -------------
> sequence UnitHead,      -- Rank of unit leader
>          MaxUnitSize,   -- Maximum number of immediate subordinates
>          MaxGroupSize,  -- Maximum number of total subordinates
>          UnitSize       -- Number of people in each rank
>
> integer CorpSize        -- Total size of army corp
>
>
> UnitHead = {
>         "General",
>         "Captain",
>         "Lieutenant",
>         "Corporal",
>         "Soldier"
>         }
> MaxUnitSize = { 5, 10, 10, 20, 0 }
>
> CorpSize = 20000
>
> -- Returns the next integer if the parameter has a decimal portion.
> function ceiling(atom x)
>     integer q
>
>     q = floor(x)
>     return q + (x!=q)
> end function
>
> -- Calculates the total number of subordinates for each rank.
> procedure CalcGroupSize()
>     integer lStart
>
>     lStart = 0
>     MaxGroupSize = repeat(0, length(UnitHead))
>
>     for i = length(UnitHead) to 1 by -1 do
>         MaxGroupSize[i] = MaxUnitSize[i] * lStart + 1
>         lStart = MaxGroupSize[i]
>     end for
> end procedure
>
>
> -- Calculates the required number of people for each rank.
> procedure CalcUnitSize()
>     integer lRemaining
>
>     lRemaining = CorpSize
>     UnitSize = repeat(0, length(UnitHead))
>
>     for i = 1 to length(UnitHead) do
>         UnitSize[i] = ceiling(lRemaining / MaxGroupSize[i])
>         lRemaining -= UnitSize[i]
>     end for
>
> end procedure
>
> procedure DoCalcs()
>
>     CalcGroupSize()
>
>     CalcUnitSize()
>
> end procedure
>
>
<snip>

>
>

new topic     » goto parent     » topic index » view message » categorize

12. Re: Army Composition

C.K.,

Whew!  ok, this should do what you want, but it *wasn't* easy, at least not
for me!

It may no longer "exit" from each entry; it did originally, but then I
wanted to change the wording of the input requests, which made more inner
loops, which destroyed the exits.

I tested it against the original premise you provided, and it returned the
same values, but that's not to say you couldn't find some way to crash it,
or make it return incorrect values!

Had to figure factorials, just like Matthew said.

Dan

--<code follows>
include get.e
include misc.e
include print.e

constant True = 1,
         False = 0


integer s, sql,lt,cp,gn, p, t, quit
sequence Tiers, TiersBlank
integer top, bottom  -- top and bottom are numerator and denominator
integer temp  -- used to figure factorials

Tiers = {}
TiersBlank = {{},{}}  -- {number in tier}, {ratio to previous tier}
quit = False


while 1 do
top = 1  -- will be multiplied into
bottom = 0  -- added into

t = prompt_number("enter the number of ranks (0= quit): " , {0,1073741823} )
if t = 0 then exit end if

Tiers = repeat({{},{}}, t)

for n = 1 to t-1 do
  if n = 1 then
     Tiers[n][2] = prompt_number("enter the number of ranks commanded by the
TOP rank (0= quit): " , {0,1073741823} )
    if Tiers[n][2] = 0 then
       quit = True
       exit
    end if
  else

     Tiers[n][2] = prompt_number("enter the number of ranks commanded by
this next lower rank (0= quit): " , {0,1073741823} )
    if Tiers[n][2] = 0 then
     quit = True
     exit
    end if
  end if
end for
Tiers[t][2] = 1  -- last level only commands themself

if quit then exit end if


p = prompt_number("enter the population of soldiers (0= quit): " ,
{0,1073741823} )
if p = 0 then exit end if

for m = 1 to length(Tiers) do
  top *= Tiers[m][2]   -- numerator is just "numbers commanded" multiplied
together
end for


-- and this is how I did factorials:
for m = length(Tiers)-1 to 1 by -1 do
 temp = 1
 for n = 1 to m do
    temp *= Tiers[n][2]
 end for
  bottom += temp
end for
bottom += Tiers[length(Tiers)][2]

-- s, sql, lt, cpt, gen
for m = length(Tiers) to 1 by -1 do
  Tiers[m][1] = floor((top*p/bottom)/Tiers[m][2])
end for

for m = length(Tiers) to 1 by -1 do
  Tiers[m][1] = floor((top*p/bottom)/Tiers[m][2])
  puts(1, sprint(Tiers[m][2]) & "   " & sprint(Tiers[m][1]) & "\n")  --
shows result!
  if m > 1 then
    Tiers[m-1][2] *= Tiers[m][2]
  end if

end for

end while

-- <end code>


----- Original Message -----
From: "C. K. Lester" <cklester at yahoo.com>
To: "EUforum" <EUforum at topica.com>
Sent: Wednesday, October 10, 2001 8:32 PM
Subject: RE: Army Composition


>
> Hey, Dan, thanks for the help. All truth will soon be revealed.
>
> > The number "10556" was  calculated by simple algebra:
> >
> > --Soldiers - no requirements
> > --Squad Leader - commands 20 soldiers
> > --Lt. - commands 10 Squad Leaders
> > --Captain - commands 10 Lt.s
> > --General - commands 5 Captains
> >
> >
> > -- soldiers + squad leaders + Lts. + Captains + Generals = Population
> > (army!)
> > --s + (s/20) + ((s/20)/10) + (((s/20)/10)/10 ) + ((((s/20)/10)/10)/5)= P
> > -- s + s/20  +  s/200 +  s/2000  + s/10000 = p
> > -- 10000s + 500s + 50s + 5s + s = 10000p
> > -- 10556s = 10000p
> > -- s = 1000p/10556
> >
> >
> > I don't understand what you mean by "4 levels and 6 levels" of rank.
You
> > only specified 5 levels of rank.
>
> Right. But "What If" I needed to calculate for a differently leveled
> organization? What if my calculations required a 4-tier organization or a
> 6-tier organization, other than the 5-tier organization we've hard coded
so
> far...?
>
> What if we had { "Soldier" , "Leader" , "Captain" , "General" }?
>
> > If you want to find out how many different ranks there are, just look at
> > each rank var, if not zero, increment a "NumberOfRanks" counter.
>
> Yeah. That's what I mean. But how to implement? That's what I need to
know.
>
> > I didn't really understand what you're doing with the matrix, either,
and
> > the change in your rank system,
> > ranks = { "Soldier" , "Leader" , "Captain" , "Sergeant" , "General" }
> > seems wrong, it should be:
> > ranks = { "Soldier" , "Leader" , "Sergeant" ,"Captain"  , "General" }
>
> Okay! Sounds right to me. But anything would.
>
> I'm just using familiar labels. We could also be using
>
> { "Pion" , "Assistant Manager" , "Manager" , "VP" , "President" }
>
> or something similar. The labels aren't what's important... It's the
tiered
> organization that matters.
>
> Hopefully I've shed a little light on the above.
>
> -ck
>
>
>

new topic     » goto parent     » topic index » view message » categorize

13. Re: Army Composition

CK,

Oops, the following should be deleted from what I sent you for the general
case of n ranks or Tiers; it doesn't make anything wrong, it's just a
section that I made work correctly just after it, so it just makes a part of
a later whole get done twice.

Dan

--<unnecessary code, to be removed:>
-- s, sql, lt, cpt, gen
for m = length(Tiers) to 1 by -1 do
  Tiers[m][1] = floor((top*p/bottom)/Tiers[m][2])
end for
--<end unnecessary code>

new topic     » goto parent     » topic index » view message » categorize

14. Re: Army Composition

CK,

Just a math note:

in my earlier response which gave you a way to let the user set how many
ranks or command tiers there are, and how many are commanded by each tier, I
mentioned that it used factorials, and that's not true.

Factorials are a sequence of multiplications of each integer from 1 to some
number (ie, 1*2*3*4 is 4! or 4 factorial);  what was involved here (in the
computation of the denominator of the expression which gives the number of
people in a command level) was a summation of products of a diminishing set
of multiplicands (ie, start with a set of 5,10,10,20; multiply all together
and save that product; now remove the last member of the set & multiply the
remaining members of the set (5*10*10) and add that product to the first
product; then remove the last member of that set and multiply (5*10), and
add that product to the previous sum; then add (5), and then add 1).

Clear?  ;)

Dan


----- Original Message -----
From: "C. K. Lester" <cklester at yahoo.com>
To: "EUforum" <EUforum at topica.com>
Sent: Wednesday, October 10, 2001 8:32 PM
Subject: RE: Army Composition


>
> Hey, Dan, thanks for the help. All truth will soon be revealed.
>
> > The number "10556" was  calculated by simple algebra:
> >
> > --Soldiers - no requirements
> > --Squad Leader - commands 20 soldiers
> > --Lt. - commands 10 Squad Leaders
> > --Captain - commands 10 Lt.s
> > --General - commands 5 Captains
> >
> >
> > -- soldiers + squad leaders + Lts. + Captains + Generals = Population
> > (army!)
> > --s + (s/20) + ((s/20)/10) + (((s/20)/10)/10 ) + ((((s/20)/10)/10)/5)= P
> > -- s + s/20  +  s/200 +  s/2000  + s/10000 = p
> > -- 10000s + 500s + 50s + 5s + s = 10000p
> > -- 10556s = 10000p
> > -- s = 1000p/10556
> >
> >
> > I don't understand what you mean by "4 levels and 6 levels" of rank.
You
> > only specified 5 levels of rank.
>
> Right. But "What If" I needed to calculate for a differently leveled
> organization? What if my calculations required a 4-tier organization or a
> 6-tier organization, other than the 5-tier organization we've hard coded
so
> far...?
>
> What if we had { "Soldier" , "Leader" , "Captain" , "General" }?
>
> > If you want to find out how many different ranks there are, just look at
> > each rank var, if not zero, increment a "NumberOfRanks" counter.
>
> Yeah. That's what I mean. But how to implement? That's what I need to
know.
>
> > I didn't really understand what you're doing with the matrix, either,
and
> > the change in your rank system,
> > ranks = { "Soldier" , "Leader" , "Captain" , "Sergeant" , "General" }
> > seems wrong, it should be:
> > ranks = { "Soldier" , "Leader" , "Sergeant" ,"Captain"  , "General" }
>
> Okay! Sounds right to me. But anything would.
>
> I'm just using familiar labels. We could also be using
>
> { "Pion" , "Assistant Manager" , "Manager" , "VP" , "President" }
>
> or something similar. The labels aren't what's important... It's the
tiered
> organization that matters.
>
> Hopefully I've shed a little light on the above.
>
> -ck
>
>
>

new topic     » goto parent     » topic index » view message » categorize

15. Re: Army Composition

CK,

Perhaps this is what you are looking for  -- a function which does the
calculation, to be embedded in your program:

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 the tiers, with 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
   tiers=floor(pop/tiers)
   for i=1 to num_tiers do
      pop-=tiers[i]
   end for
   return pop & tiers
end function

-- Mike Nelson

new topic     » goto parent     » topic index » view message » categorize

16. Re: Army Composition

Mike,

Unless I've done something wrong with your function, it doesn't return
exactly the correct values.  As I tested it, for a population of 10,000,
same command ratios CK used in his example (20, 10,10,5), your function
returns {9473,476, 47, 4,0}; but as CK pointed out for another routine, 476
can't be "supported" by 9473, the most that can be supported by 9473 is 473.

As far as I know, the code I sent earlier does result in the proper values.

CK,

Did you check my code?  Does it give values that seem correct? Do you need a
function?

Dan Moyer


----- Original Message -----
From: "Mike Nelson" <MichaelANelson at WORLDNET.ATT.NET>
To: "EUforum" <EUforum at topica.com>
Sent: Thursday, October 11, 2001 8:46 AM
Subject: Re: Army Composition


>
> CK,
>
> Perhaps this is what you are looking for  -- a function which does the
> calculation, to be embedded in your program:
>
> 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 the tiers, with 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
>    tiers=floor(pop/tiers)
>    for i=1 to num_tiers do
>       pop-=tiers[i]
>    end for
>    return pop & tiers
> end function
>
> -- Mike Nelson
>
>
>

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu