We have Stocks in several discrete positions, let say:
A B C 40 20 80
And Demand, which may be satisfied by one or more Stock positions (if no specified then it would accept any Stock).
Demand for A=20 may be satisfied from A Stock only, and depletes 20 units from it. Demand for AB=20 may be satisfied from any of the A abd B Stocks, and may take partially from both, without any proportion limitations.
So for the Stocks example above:
This Demand may be satisfied (10 strict from A, 20 strict from B, and 30 AB would take from both)
AB B A 30 10 20
And this may not (insufficient B Stocks)
AB B B 30 10 20
This sounds like a more or less common problem which should have a known solution. I would be happy with any reference or idea. Also if the solution is resource heavy a cheaper approximation would be great.