share 4 resources according to 3 different consumers equally

Ventolin

New member
Joined
Apr 2, 2014
Messages
3
Hi all,

I have given quantities 4 resources - food, wood, stone and ore and 3 consumers (troops) - Mounted, Foot, Ranged. Each type of troop consumes different quantities of each of the 4 resources. I would like to find out what numbers of each type of troop are required to leave the wood, stone and ore resources equal (but not the food).


Mounted troops consume: 150 food, 110 wood, 50 stone, 200 ore
Foot troops consume: 150 food, 220 wood, 100 stone, 50 ore
Ranged troops consume: 150 food, 55 wood, 200 stone, 100 ore


For example, I have 1200K food, 1000K wood, 900K stone, 1200K ore (K=thousand). What numbers of Mounted, Foot and ranged troops do I need to consume as much resources as possible yet leave the wood, stone, ore equal? Furthermore, I have a variable, limited number of total troops available at any one time, e.g. 1210 total.



I can work out the troops required if the resources are all equal. Through some trial I have found the ratio of the different types of troops to be Mounted:Foot:Ranged = 11:9:12. I can't it work out if the resources are unequal. I think it is something to do with the proportion of resources available but can't figure out the multiplication factors.


From the ratio of 11:9:12 (m:f:r) total is 11+9+12=32, multiplication factors are 11/32, 9/32, 12/32 = 0.344, 0.281, 0.375
If the resources are equal I can do:
Total number of troops = minimum of: Food/450 or max given number of troops(450 comes from 150+150+150)

Suppose the max number of troops = 8616, then troops required:
mounted = 8616*0.344 = 2962
foot = 8616*0.281 = 2423
ranged = 8616*0.375 = 3231

Resources for the above required:
Mounted: F=150*2962=444300, W=110*2962=325820, S=50*2962=148100, O=200*2962=592400
Foot: F=150*2423=363450, W=220*2423=533060, S=100*2423=242300, O=50*2423=121150
Ranged: F=150*3231=484650, W=55*3231=177705, S=200*3231=646200, O=100*3231=323100
Totals:
Food = 444300+363450+484650=1292000
Wood = 325820+533060+177705=1037000
Stone= 148100+242300+646200=1037000
Ore = 592400+121150+323100=1037000


Desired result is Wood, stone and ore are consumed equally.


The problem is if the resources are not equal - what are the troops numbers required to leave the wood, stone and ore equal? Things are also further complicated if not enough resources are available for the given number of troops. In that situation, the number of possible troops would reduce such that the final number of resources available is always positive and equal.


I have figured out a program to work this out by iteratively changing the values of the troops until the resources are equal by adding or subtracting the troop type numbers such that the total remains the same (i.e. the ratio of troop types changes)

For example, F=1200K, W=1000K, S=900K, O=1200K
Max troops available = 8616
Computed result:
Mounted=4080
Foot=1599
Ranged=2321
Total Troops=8000 (sum of above)
Yields:
Food=0
Wood=71.77K
Stone=71.9K
Ore=71.95K


So, to state the issue again, how do I work out what troops are needed without computing using an iterative loop, but using a formula instead?


Would really appreciate an answer, I have been scratching my head for weeks on this!
Thanks in advance!
 
Hi guys,

I'm feeling slightly better as someone has not instantly said "you just do this..." which would have been embarrassing!

However, I do hope someone is able to help as the solution feels tantalisingly close, but is still elusive.

Thank you for your consideration!

Vent
 
This has constraints like a "linear programming" problem but the question asked is NOT.

If the question is to make "wood, stone, and ore consumed equal",
then you want to solve the two equations 110M+ 220F+ 55R= 50M+10OF+ 200R (wood= stone) and 110M+220F+55R= 200M+50F+ 100R (wood= ore). "stone= ore" follows from those two equations and is not a third independent equation. Those easily reduce to 90M- 170F+ 45R= 0 and 60M+ 110F- 145R= 0. One obvious solution is M= F= R= 0 but there are others. Solve for two of the unknown values in terms of the others and leave that one as a "parameter". The constraints, such a M+ F+ R\(\displaystyle \le\) 1210, will limit the values of that parameter.
 
Last edited by a moderator:
Hi, thanks for replying HallsofIvy and Denis, I have had some trouble replying myself to the thread. Keep getting Internal Server Error.

Denis, you're right some games can be quite educational! I hadn't come across linear programming before; it looks very deep though!

As you probably figured out already, 1 troop would consume all 4 resources of the amounts given. Final troop numbers would indeed be integers, I did use the fractional equivalents in my calculations of course rather than the decimal.

I "found" the ratio of 11:9:12 by working out troop numbers manually with some trial by adjusting troop amounts in small quantities until the resources were consumed equally. This was starting out with equal resources in the first place however. I would have liked to arrive at the ratio mathematically though. It's not a given!

As I say, I have worked out the troop numbers if the initial resources were equal using the ratio. However, the initial resources aren't equal most of the time and so I need to work out the troop numbers in that scenario. That is really where I need help.

It "feels like" the "proportions" of the initial resources would give the answer, maybe give a "weight", bu I can't quite work that part out.

For example,

Say initial proportions of W:S:O are a:b:c

To work out weights x,y,z
a*(some formula)=x
b*(some formula)=y
c*(some formula)=z

so that the weights x,y,z can be used like this:

M=Total Troops*11/32*x
F=Total Troops*9/32*y
R=Total Troops*12/32*z

Final W,S,O would then be calculated using M,F,R.
Total troops would be the lower of initial F/450, W/385, S/350, O/350 such that W,S,O >=0 and using all troop types. (I'm not really sure how to properly define that, but if say wood was very low you'd only be able to have a few troops).

x,y,z are chosen so that the final W:S:O are in the proportions of 1:1:1 and maximum resources are consumed.

Also it may be that it's not possible to have all troop types in order to get the 1:1:1 proportions. Additionally, there may not be a solution to get all three resources to 1:1:1 in which case we'd need to get two resources to 1:1 if possible, if not then as close to possible to 1:1:1 or 1:1 in order to consume as much as possible.

HallsofIvy, I just about understand what you have written, but I am unsure how to go from there.

I might be barking up the wrong tree here with the proportions and weights etc, I'm not really sure how else to do it though.

Thank you very much for taking the time to help!

Best Regards,

Vent
 
Last edited:
Top