0

I am trying to maximize the division of two quantities in PySCIPOpt. Since it is a division of two linear metrics, it becomes a nonlinear optimization.

My code is somewhat like this:

model = Model()
x={}
for i in range(0,len(data)):
    x[i] = model.addVar(vtype = 'B',name = 'x(%s)'%i)
    
data['Index'] = range(0,len(data))
profit = 0
volume = 0
for index in data['Index']:
    profit += x[index] * data['Predicted.Profit'][index]
    volume += x[index] * data['Predicted.Liters.Sold'][index]

   
model.setObjective(profit/volume,"maximize")

As soon as I hit the setObjective command, my kernel gets busy for more than 20 minutes and just keeps working. I want to know is there something wrong with my definition of Objective function? Could I be doing something else? Something more efficient?

By the way, my dataset's shape is 178848x36

edit

The function ran after twenty minutes! But gave an error saying : AssertionError: given coefficients are neither Expr or number but ProdExpr

How do i Bypass this error? Since I wish to optimize the division of decisionVariables! As well as make this objective function declaration more efficient?

Edit2

Is there a way to cast ProdExpr as Expr??

Community
  • 1
  • 1
  • @mattmitten any insights?? – linearprogrammer Nov 25 '18 at 08:20
  • In general, SCIP does not work with nonlinear objective functions. They are converted into a constraint and a new auxiliary variable works as objective. See here: https://github.com/SCIP-Interfaces/PySCIPOpt/issues/167 – mattmilten Nov 25 '18 at 13:41

0 Answers0