Python Forum
Oil Refinery - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Oil Refinery (/thread-23330.html)



Oil Refinery - refineryuser - Dec-22-2019

Dear all,

An oil refinery processes a total of 20 types of crude oil over 2 years. At any one time, the refinery runs a mixture of 3-5 types crude oils. Because each crude oil is different, each crude oil mixture yields a different ratio of 4 refined products. Also, each type of crude is featured in more than one crude run.

Data available are: (1) mixture of the crude oils for each run and (2) the yield of 4 different products (A,B,C,D).

Objective: To find out the yield of each type of crude.

My question is: what class of problem is this? Is there a feature in Python that can give a good guess to this type of problem?

Thank you in advance!


RE: Oil Refinery - Gribouillis - Dec-22-2019

It looks like a linear system of equations, for example suppose that the crude C_k produces the unknown quantities a_k, b_k, c_k, d_k of each product. If we mix together 3 crudes C_1, C_2, C_3 in proportions x, y, z and we observe the quantities q_a, q_b, q_c, q_d of each product, it gives 4 linear equations for the a_k, ..., namely
Output:
x * a_1 + y * a_2 + z * a_3 = q_a x * b_1 + y * b_2 + z * b_3 = q_b x * c_1 + y * c_2 + z * c_3 = q_c x * d_1 + y * d_2 + z * d_3 = q_d
If you have the result for various mixes of the crudes, it gives a large system of equations involving the a_k, ....

Modules like numpy.linalg contain tools to solve systems of linear equations. When exact solutions cannot be found, you can also try to get 'best fit' solutions using Moore-Penrose pseudo inverses of matrices and the like. Again, numpy and scipy contain tools to tackle these problems.