0

I am trying to solve a variant of the multidimensional multiple knapsack problem which tries to optimize the values in each knapsack so that a percentage of each of them can be “taken” and added to create a “final knapsack” with the ideal values. See this question below. https://cs.stackexchange.com/questions/14163/linear-programming-algorithm-to-check-if-ratios-can-be-combined-with-n-bottles

The problem I linked to says "given n bottles find a solution where you can take a ratio of every bottle and add them to equal the predetermined values (A, B, C)." The problem I have is "given a set of values organize them in the n bottles in such a way that there is a solution where you can take a ratio of every bottle and add them to equal the predetermined values (A, B, C)."

Essentially I would like to create an algorithm that organizes incoming values knapsacks (or bottles as they call it in the question above) so that they could be combined in a way that could guarantee the desired result.

The main difference between the multiple multidimensional knapsack problem and what I am trying to do is what I am trying to maximize. Instead of trying to maximize the total value of all the knapsacks, I want to first multiply each knapsack by a variable Lambda[i] and add them together so that they equal the item F which is a vector with constants (A, B, C, D). I want the knapsacks optimized in such a way that the combination gives back the most amount of item F.

Here are the variables

  • I: number of bottles
  • J: set of items
  • v[j] =[a(j), b(j), c(j), d(j)]: value of item j
  • p[i] = [a(i), b(i), c(i), d(i)]: value of bottle after items added to it
  • n[i] = weight of each bottle after items are added to it
  • m[i]: capacity of bottle i
  • Lambda[i]: lambda variable to multiply each bottle by
  • F =[A, B, C, D]: Optimal bottle value
  • N: Weight of final blend
  • M: Weight capacity of final bottle

The objective function I am trying to maximize N = Σ n(i) * Lambda(i)

some constraints I have are

n[i] <= m[i]

Σ a(i) * Lambda[i] = A

Σ b(i) * Lambda[i] = B

Σ C(i) * Lambda[i] = C

Σ D(i) * Lambda[i] = D

0 <= Lambda[i] <= 1

I have tried implementing this solution in Gurobi and OR-Tools but the problem I'm having is that the weight of each bin is only found after optimizing so there is no way for me to maximize the function I need.

Ultimately I would like to solve an Online version of this problem where the algorithm wouldn't be able to reject any item coming in but I figured starting with the offline version with a dataset would be easier.

Does this mean this algorithm is not a linear programming problem or I am just missing a step? If it isn't a linear program is there any other method like machine learning that could help me solve this?

Any help would be greatly appreciated.

imsorry
  • 1
  • 2
  • I don't understand. Is your problem the same as the one at the link, which has already been asked and answered on SO? – Cary Swoveland Feb 22 '22 at 07:06
  • @CarySwoveland Sorry I could have been clearer. I updated the post with more information. The problem I have is "given a set of values, organize them in the n bottles in such a way that there is a solution where you can take a ratio of every bottle and add them to equal the predetermined values (A, B, C)." – imsorry Feb 22 '22 at 13:28
  • I've re-read your question several times but can't understand it. You say, "I want to first multiply each knapsack by a variable Lambda[i]". Do you mean multiply the *weight or value* of each knapsack (aka bottle)? Then you say, "and add them together". Do you mean sum all the weights or values obtained in the previous step?... – Cary Swoveland Feb 23 '22 at 10:49
  • ... Then, "so that they equal the item F which is a vector with constants (A, B, C, D)". How can a total weight or value (a single number) be compared with a four-element vector?. "I want the knapsacks optimized in such a way that the combination gives back the most amount of item F." What is "most amount" of a vector? I've had a lot of experience with math programming but neither I nor anyone else can help you until you provide a clear and precise statement of the problem. – Cary Swoveland Feb 23 '22 at 10:57
  • @CarySwoveland So since it is a multiple-dimensional knapsack problem every knapsack has multiple values. Every item that comes in has a vector of values (a,b,c,d) and a weight. These values and weight are added to whatever knapsack is going to optimize the objective function. The Lambda variables are going to be multiplied by both the values of the knapsack and the weight of the knapsack. The Lambda variables will be multiplied by the values of the knapsack to satisfy the constraints that I posted above (and are in the question that I linked to) Σ a(i) * Lambda[i] = A etc – imsorry Feb 23 '22 at 19:40
  • And the Lambda variables will also be multiplied by the weight of each knapsack so that the objective function (N = Σ n(i) * Lambda(i)) is maximized. Essentially this problem is two problems combined. The first part is the multidimensional multiple knapsack problem and the second part is in the question I linked to above. I can solve both separately but I am having trouble combining both. – imsorry Feb 23 '22 at 19:44
  • When answering questions asking for clarification it's best to edit your question rather than to elaborate in comments. Questions should be stand-alone, in part because not all readers read all comments. In editing, please clarify "These values and weight are added to whatever knapsack is going to optimize the objective function." I'll look at your edit later today to see if I now understand the question. – Cary Swoveland Feb 23 '22 at 19:45

1 Answers1

0

It looks to me to be probably a linear programming problem, but you are having a problem with the objective being not-linear? There are ways to reformulate some of these not-linear terms to make them solveable: See for example Erwin Kalvelagen's excellent mathematical programming examples such as http://yetanothermathprogrammingconsultant.blogspot.com/2017/05/linearizing-average.html which is probably not quite the same as you need but may give you enough ideas to help.

TimChippingtonDerrick
  • 2,042
  • 1
  • 12
  • 13
  • Thank you for the resource, there might be something here for me. Is this objective function not linear? Is it because the unknown values that are trying to be optimized are being multiplied? – imsorry Feb 23 '22 at 19:46
  • Basically yes. Linear programming and its variants do not normally accept expressions where any of your decision variables are multiplied (or divided) by other decision variables. – TimChippingtonDerrick Feb 25 '22 at 08:53