(I had no idea how to tag this, any help would be great) :)
I am a programmer with little math experience beyond high school - this will be demonstrated by my explanation.
I am developing an application that needs a formula. The formula involves calculating what amounts of food to eat based on factors like calories and concentrations of macronutrients (carbs, protein, fats).
Since there are other calculations need that aren't relevant to main problem, I have abstracted it into the following word problem. Here it is:
Your job is to keep your store, Colorful Widgets, Inc., supplied with widgets. There are four suppliers that you can order from every month. There is a set ratio of colors that must be met as closely as possible to match sales expectations. The ratio is:
Target Color Ratios: 40% Red widgets 40% Blue widgets 20% Yellow widgets
The catch is that each supplier offers shipments of mixed colors in different ratios, with each company specializing in one color. Here are the ratios available from the suppliers:
Mostly Red Widgets, Inc. 86% Red 11% Blue 03% Yellow
Acme Widgets, Inc (Limit 3 boxes) 79% Red 09% Blue 20% Yellow
Mostly Blue Widgets, Inc. 15% Red 77% Blue 08% Yellow
Mostly Yellow Widgets, Inc. 10% Red 00% Blue 90% Yellow
All four companies sell their widgets in boxes containing 100 widgets each. Boxes cannot be split into smaller amounts. You need to order 24,000 widgets, with the total ratio of colors matching the targets laid out above.
Restrictions:
You have a contract with the first three companies - they must be ordered from every month, no exceptions. The fourth (Mostly Yellow Widgets, Inc.) is a stop gap - if your total ratio is low on yellow widgets, you can order from them.
Additionally, Acme Widget, Inc. makes the best widgets, but only in limited quantity. You must order 3 boxes from them each ordering cycle.
I understand that this problem probably will not have a neat and tidy catch-all formula. Even if there is no formula for this problem with it's restrictions, there should be a formula or something that will help with the problem of combining three different ratios in such a way to come as close as possible to the target ratio.
I also understand that if the target ratios or ratios of suppliers change too much, a solution may not be possible.