I want to solve a problem in python with integer programming (cvxpy librairy), but I am a little confuse about the definition of my constraints.
Here is my problem. I have two databases. 1 contains food products (name of the product/quantity (g/L/piece)/ quantity (how many units)). The other contains recipes (name of the recipe/name of the product/quantity needed (g/L/piece)). I want to know how many of each recipe I have to make in order to minimize my food products left quantity. So my "selection" variable would be :
selection = cvxpy.Variable(number_of_recipes, integer = True)
I have 2 constraints. The first is that I can't chose more products than the quantity I have. So I have something like :
supply_constraint = cvxpy.sum_entries(selection, axis=0) <= max_quantity
I see a first problem here. "selection" has the len of the number of recipes, and "max_quantity" the len of the number of ingredients. That does not match. Do I have to define 2 variables to solve, one for the recipes and one for the products ? For my tests I have few recipes and products, but my databases are supposed to have thousands of each.
My second constraint is that a product is allocated to a recipe only if all the ingredients of the recipe are allocated to it too. I don't even know how to express this constraint with cvxpy.
Thank you for those who will help me !