0

Could you please help me to find a way to linearize this equation?

Cost = sum(CV[i]*Q[i] for i in range(10)) / sum(Q[i] for i in range(10))

The above-mentioned equation is a constraint of an MILP model in which, the CV is a parameter (a constant value) and Q is an integer variable. The value of Cost is used in an Objective Function so that it multiplies by another integer variable. But I know how to linearize the product of two integer variables. I just want to know how to linearize the division above. I'm using Python and the Docplex package for optimization.

  • How do you linearize a product ? – Yves Daoust May 07 '23 at 08:47
  • This cost expression introduces a degeneracy: you can freely multiply all variables by a constant factor. It would be tempting to enforce Σq=1, but that does not take the constraints into account. – Yves Daoust May 07 '23 at 08:51
  • @Yves Daoust Thank you for your comment. Could you please explain more? A part of the objective function includes . . .+Cost* QC+. . . and QC is an integer variable. As it is mentioned before, the Cost as a constraint includes a division. As I found out about your comment, there is no need to linearize the cost. is that true? – Nasser Tarin May 07 '23 at 09:33
  • No, this is not what I said. I said that the solution is degenerate, not unique. – Yves Daoust May 07 '23 at 09:35
  • I would appreciate that you anwered my first question. – Yves Daoust May 07 '23 at 09:36
  • About your first answer, I provided a link below. But could you please guide me on what should I do? https://or.stackexchange.com/questions/7293/how-to-linearize-the-product-of-two-integer-variables – Nasser Tarin May 07 '23 at 09:43
  • This linearization is based on a decomposition of the variables into bits. It would turn your problem in a Binary Linear Program and make it completely intractable, I guess. And even less usable in the case of a division. – Yves Daoust May 07 '23 at 09:46
  • I am afraid that this cost function is essentially nonlinear and linearization is elusive. – Yves Daoust May 07 '23 at 09:48
  • Thank you for your comment. Maybe I should try another way to calculate the cost. – Nasser Tarin May 07 '23 at 09:51
  • 1
    Mh, usually you don't choose the cost function for personal convenience. It derives from the problem to be solved. – Yves Daoust May 07 '23 at 10:04
  • X/Y problem. Describe what the cost represents in the real world and what you're attempting to achieve. – Reinderien May 07 '23 at 20:08
  • @Reinderien The total cost of a certain activity in the real world is calculated through the average cost of different products with different related costs. As you can see in the abovementioned code, I've considered the total cost as Cost, and Q[i] as a decision variable shows the number of products [ i ] entered into the activity. I defined the cost as a constraint in the model, but the value of cost in the objective function multiply by another decision variable. To get more explanation, in the objective function we have . . . +Cost*XR+ . . . – Nasser Tarin May 09 '23 at 12:59
  • Please let me know if there is a solution for that. ( Linearization I mean) – Nasser Tarin May 09 '23 at 12:59
  • Rather than minimizing the average cost, can you not just minimize the total cost? – Reinderien May 10 '23 at 02:47
  • Unfortunately not. – Nasser Tarin May 11 '23 at 20:24

0 Answers0