My dad asked me to write a program that calculates the optimal way to create a specific alloy by mixing other alloys based on price.
An example:
We have three elements in a certain alloy. An example of mixtures could be
80% iron, 19% carbon, 1% zinc : price 200 70% iron, 25% carbon, 5% zinc : price 300 90% iron, 8% carbon, 2% zinc : price 250 Lets say there are 50 more combinations available for different prices
My goal is to melt everything to an alloy. The alloy i want is 85% iron, 13% carbon, 2% zinc
How could I find the most optimal combinations(cheapest total price) of alloys to melt them into the alloy I want.
In the real world case there will be around 8 different elements with a maximum and minimum amount allowed in the final alloy. So there is a margin.
What would he the best way to calculate this?
Let $x_i,$ denote the type of alloy for all $i=1,2,\ldots,8$. For example, $x_1=iron, x_2=carbon $ etc. $UB_i$ denotes the upper bound possible for production of material $i$ (in percentage), $LB_i$ the lower bound. $c_i$ is the cost of producing one percent of type $i$. So the optimization model you will write will be a very simple LP:
$\min \sum_i c_ix_i$
$s.t \ \ LB_i\leq x_i \leq UB_i \quad \forall i\in\{1,2,\ldots,8\}$ (constraint of maximum-minimum production)
$\ \ \ \ \ \ \ \sum_i x_i \geq 1$ (constraint that satisfies 100% is produced)
Example YALMIP code in Matlab can be: