I am trying to use PuLp for a Blending problem with different Elements (Iron, Mercury..). But instead of max/min some profit/cost I need to maximize the utilization of my constraints. So in Excel I had something like this (in pseudocode):
max Sum (for each Element: (Sumproduct([DecisionVariables] * [Values]) / [MaximumAllowedValueForThisElement]))
I never used an objective function like this but it seems to work in Excel.
Now I want to model the same problem in PuLP. I think what I would need is somethink like this:
for Element in ELEMENTS:
prob += lpSum(DecisionVariable[Concentrate]*dic[Element][Concentrate]/ MaxAmount[Element] for Concentrate in CONCENTRATES)
Where ELEMENTS is a List containing all Elements, CONCENTRATES is a List of Values from 0 to 100 and dic[Element][Concentrate] stores the values from each Element and all its concentrates.
Now with the code above, the objective function is overwritten in each loop. Instead of overwriting the old objective function I'd need something like append() or alike to add each of the loops=lpSums to my prob variable?class?
I am rather new to programming in general and I guess my problem is more related to my lack of python programming skills than my (also lacking :D) PuLP skills. But I could not find anything in the PuLP documentation, atleast nothing I could connect it to.
Edit: Included a small table to showcase the problem:
+------------------------------+-------------------------------------------+----+------------------------------+---------------+----------------------+---------------+---------------+-------------------------------+
| Utilization [%] | Sumproduct[Quantity] = [LHS] | | Constrains[Quantity] = [RHS] | Concentrate | Element 1 [%] | Element 2 [%] | Element 3 [%] | Decision Variables [Quantity] |
+------------------------------+-------------------------------------------+----+------------------------------+---------------+----------------------+---------------+---------------+-------------------------------+
| u1 = z1 / MaxAmount Element1 | z1 = Col Element1 * Col Decison Variables | <= | MaxAmount Element1 | Concentrate 1 | % Element 1 in Con 1 | | | X1 |
| u2 = z2 / MaxAmount Element2 | z2 = Col Element2 * Col Decison Variables | <= | MaxAmount Elemen2 | Concentrate 2 | % Element 1 in Con 2 | | | X2 |
| u3 = z3 / MaxAmount Element3 | z3 = Col Element3 * Col Decison Variables | <= | MaxAmount Elemen3 | Concentrate 3 | % Element 1 in Con 3 | | | X3 |
+------------------------------+-------------------------------------------+----+------------------------------+---------------+----------------------+---------------+---------------+-------------------------------+
The columns "Element 2" and "Element 3" store the same information as the column "Element 1": the % share of the respective Element in Concentrate 1/2/3.
The objective function is to maximize the sum over all utilizations (u1+u2+u3). So I am trying to determine how much of each concentrate I should use, to utilize as much of the given constraints for each element, as possible. Coming back to my PuLp code, I think I am able to add the equivalent of "u1" to my PuLp "LpProblem Class", but I can't figure out how to add multiple of these LpSums to my "LpProblem Class" in a loop.