Template:Ideal Sex Ratio/doc
Returns the ideal male population for a specified total adult population of animals, up to a maximum of 15 males.
Syntax[edit]
{{Ideal Sex Ratio|N|Name|Metric|Verbose}}
- N = Total adult population count.
- Name = Name of animal (optional). If not present, the current pagename is used.
- Metric = One of 'reproduction', 'baby slaughter nutrition', or 'adult slaughter nutrition'. Defaults to 'reproduction'. Will all return the same unless the animal lays unfert. eggs or makes milk.
- Verbose = If set, prints a trace of the iteration.
This template uses a long nested recursion, consuming up to 28 of the 40 expansion depth limit, so be careful with large values of N.
Dependencies[edit]
- Template:Gross Population Nutrition
- Assumption: Butchery efficiency, difficulty etc. modifiers are all the baseline 100%.
- Property:Milking Interval Days
- Property:Milk Name
- Property:Egg Laying Interval
- Property:Unfertilized Egg Name
- Property:Body Size
- Property:Baby Scale
- Template:Meat Leather Curve
- Template:Population Reproduction Rate
- Assumption: All the animals have a synchronized sleep cycle.
- Assumption: They're all sleeping on the floor.
- Assumption: They're all within the 30 tile distance needed to see each other.
- Property:Mate Mtb Hours
- Property:Gestation Period Days or Property:Egg Laying Interval
- Property:Average Offspring Per Birth or Property:Eggs Per Clutch Average
- Property:Can Lay Unfertilized Eggs
Used by[edit]
Pseudocode[edit]
def Ideal_Sex_Ratio(N, Metric):
v0 = 0
for m in range(1, 16):
f = N - m
if Metric == 'reproduction':
v1 = Population_Reproduction_Rate(m, f)
elif Metric == 'baby slaughter nutrition':
v1 = Gross_Population_Nutrition(M, F, 'baby')
else:
v1 = Gross_Population_Nutrition(M, F, 'adult')
if v1 <= v0:
break
v0 = v1
m = m - 1
return m
Examples
Normal output[edit]
{{Ideal Sex Ratio|30|Chicken|reproduction}}
10
Chicken[edit]
{{Ideal Sex Ratio|30|Chicken|reproduction|Y}}
n=30, name=Chicken, metric=reproduction
m=1, v1=1.9757168541398
m=2, v1=3.9514337082796
m=3, v1=5.9271505624194
m=4, v1=7.9028674165592
m=5, v1=9.8785842706991
m=6, v1=11.854301124839
m=7, v1=13.830017978979
m=8, v1=15.805734833118
m=9, v1=17.781451687258
m=10, v1=19.757168541398
m=11, v1=19
10
{{Ideal Sex Ratio|30|Chicken|baby slaughter nutrition|Y}}
n=30, name=Chicken, metric=baby slaughter nutrition
m=1, v1=7.9415008989489
m=2, v1=8.3830017978979
m=3, v1=8.8245026968468
m=4, v1=9.2660035957957
m=5, v1=9.7075044947447
m=6, v1=10.149005393694
m=7, v1=10.590506292643
m=8, v1=11.032007191591
m=9, v1=11.473508090541
m=10, v1=11.915008989489
m=11, v1=11.4
10
{{Ideal Sex Ratio|30|Chicken|adult slaughter nutrition|Y}}
n=30, name=Chicken, metric=adult slaughter nutrition
m=1, v1=10.905076180159
m=2, v1=14.310152360317
m=3, v1=17.715228540476
m=4, v1=21.120304720634
m=5, v1=24.525380900793
m=6, v1=27.930457080952
m=7, v1=31.335533261111
m=8, v1=34.740609441268
m=9, v1=38.145685621428
m=10, v1=41.550761801587
m=11, v1=39.9
10
Pig[edit]
{{Ideal Sex Ratio|30|Pig|reproduction|Y}}
n=30, name=Pig, metric=reproduction
m=1, v1=0.8832263110986
m=2, v1=1.7675601160042
m=3, v1=2.6531267913743
m=4, v1=3.5400713807928
m=5, v1=4.4285626084289
m=6, v1=5.3187979174596
m=7, v1=5.2542181460098
6
{{Ideal Sex Ratio|30|Pig|baby slaughter nutrition|Y}}
n=30, name=Pig, metric=baby slaughter nutrition
m=1, v1=2.1197431466366
m=2, v1=4.2421442784101
m=3, v1=6.3675042992983
m=4, v1=8.4961713139027
m=5, v1=10.628550260229
m=6, v1=12.765115001903
m=7, v1=12.610123550424
6
{{Ideal Sex Ratio|30|Pig|adult slaughter nutrition|Y}}
n=30, name=Pig, metric=adult slaughter nutrition
m=1, v1=10.510393102073
m=2, v1=21.03396538045
m=3, v1=31.572208817354
m=4, v1=42.126849431434
m=5, v1=52.699895040304
m=6, v1=63.293695217769
m=7, v1=62.525195937517
6
Iguana[edit]
{{Ideal Sex Ratio|30|Iguana|reproduction|Y}}
n=30, name=Iguana, metric=reproduction
m=1, v1=2.0103785533352
m=2, v1=4.023277957521
m=3, v1=6.038983591899
m=4, v1=6.8892421833598
m=5, v1=6.6242713301537
4
{{Ideal Sex Ratio|30|Iguana|baby slaughter nutrition|Y}}
n=30, name=Iguana, metric=baby slaughter nutrition
m=1, v1=1.9098596256684
m=2, v1=3.8221140596449
m=3, v1=5.7370344123041
m=4, v1=6.5447800741918
m=5, v1=6.293057763646
4
{{Ideal Sex Ratio|30|Iguana|adult slaughter nutrition|Y}}
n=30, name=Iguana, metric=adult slaughter nutrition
m=1, v1=5.6290599493386
m=2, v1=11.265178281059
m=3, v1=16.909154057317
m=4, v1=19.289878113407
m=5, v1=18.54795972443
4
Cow[edit]
{{Ideal Sex Ratio|30|Cow|reproduction|Y}}
n=30, name=Cow, metric=reproduction
m=1, v1=0.67012618444507
m=2, v1=1.341092652507
m=3, v1=2.012994530633
m=4, v1=2.6859418670659
m=5, v1=3.3600626771084
m=6, v1=3.5364136816047
m=7, v1=3.3981143304971
6
{{Ideal Sex Ratio|30|Cow|baby slaughter nutrition|Y}}
n=30, name=Cow, metric=baby slaughter nutrition
m=1, v1=22.544922717891
m=2, v1=24.092660385898
m=3, v1=25.643531677621
m=4, v1=27.197905254671
m=5, v1=28.756209968313
m=6, v1=28.646985833376
5
{{Ideal Sex Ratio|30|Cow|adult slaughter nutrition|Y}}
n=30, name=Cow, metric=adult slaughter nutrition
m=1, v1=31.558119898677
m=2, v1=42.130356562118
m=3, v1=52.718308114634
m=4, v1=63.323823366707
m=5, v1=73.949052975421
m=6, v1=76.211749850959
m=7, v1=73.188320752351
6
Recursion limit[edit]
{{Ideal Sex Ratio|100|Pig}}
Error: population too large; m > 15