A factory has $A$ and $B$ products. $A$ is made with $4X + 2Y$ raw materials. $B$ is made $2X + 4Y$ raw materials.
We want to maximize total profit.
- amount of profit $A$ per item, amount of profit $B$ per item and
- number of $X$ and number of $Y$ raw materials.
- Number of A which will be produced,
- number of B which will be produced,
- total profit.
Input: profitA = $8, profitB = $6, numberOfX = 600, numberOfY = 480, Output: numberOfA = 120, numberOfB = 60, totalprofit = $1320.
My solution is brute force algorithm. I find maximum number of $A$ will can produce and I decrease it one by one then compare result and get maximum profit. But this is not efficient. Is there a algorithm that solve this problem?
Formula = mA*pA + mB*pB => maximum pA: profit A, pB: profit B, mA: number of product A, mB: number of product B, Producing mA number A are required 4*mA number X and 2*mB number Y, producing mB number B are required 2*mB number X and 4*mB number Y.