1

I wish to solve a linear program with an objective function:

enter image description here

Here x[i][j] are decision variables and y[i][j] are already precomputed.

I was writing the code for this in CPLEX python (DOcplex) and was receiving the error that the denominator can only be a number. Is there a way to do this correctly?

This is my code:

l_model.minimize(l_model.sum(l_model.sum(x[i,j]*y[(i,j)] for j in A)/l_model.sum(x[i,j] for j in A) for i in B))
karel
  • 5,489
  • 46
  • 45
  • 50
flux
  • 13
  • 2

1 Answers1

0

In the code above, I see x variables in the denominator, which explains the error message; Docplex (and CPLEX too) expect a linear objective, with float coefficients.

Moreover, if y is also a decision variable dictionary, then the numerator expression is interpreted as a quadratic expression, whether or not variables in y are fixed. This in turn leads CPLEX to pick a QP algorithm, which is probably not what you want.

To summarize: you need to provide as objective a linear expression made exclusively from variables and Python numbers.

Philippe Couronne
  • 826
  • 1
  • 5
  • 6