I've got a problem where I need to optimize the allocation of some products. Each product has a weight (basically how much the client likes it), and a category (some clients don't accept every product)
my data look something like this
prod_name, category, weight
name1, c1, 10
name2, c1, 5
name3, c1, 1
name4, c2, 8
name5, c2, 7
name6, c2, 6
and I have another table saying that we have debt in different categories (the same categories as the above table)
category, debt
c1, 100
c2, 500
I want to maximize X*weight (which in this case would be the dot product of two six-dimensional vectors), under the constraint that x1 + x2 + x3 = 100
, (alternatively, think of it as saying the variables corresponding to category 1 must add up to the debt in category one) and x4 + x5 + x6 = 500
in reality, I have like 800 categories, so I want to do it programatically, but I have no idea how to start building this problem.
The objective is easy enough
Xxx = cvx.Variable(len(R))
objective = cvx.Maximize(cvx.sum_entries(Xxx.T*R))
Where R is just the 'weight' column as a numpy array
But I can't figure out how to build the contstraints. Also, I want to keep track of the names (that is, once I get a solution, I need to map all the elements of the solution array back to the names in the prod_name column)
Does cvxpy allow either of these things, or do I need to look at other packages?