I'm working with OR Tools in Python and I need to define the objective function an expression of the variables. In particular, the objective function is


with $c_j$ constants and $s_j$ the model's variables.

I read there is a MakePower(exp,float) function that makes a IntExp ($exp^{float}$) in C++ but I havent found an equivalent for Python, there exist such a function that allow to create these expresssions of variables? (I found sum and product, but nothing else implemented for Python).

  • $\begingroup$ First, you cannot use floats and floating point values. Second, make sure you use the CP-SAT solver. Third, if the ange of the variables are not too big, you can precompute everything, and use either an element constraint, or an allowed assignment constraint. $\endgroup$ Jan 14, 2020 at 16:53
  • $\begingroup$ thanks for the recomendatons, I already implement a model with everything precompute and only binary variables, now I want to model in this way to compare formulations (and realize if is even possible this formulatio in CP). $\endgroup$
    – Clopen
    Jan 14, 2020 at 17:52
  • $\begingroup$ It is not possible. There are no floating point variables, nor floating point constraints. $\endgroup$ Jan 15, 2020 at 12:14
  • $\begingroup$ thanks. Just to be sure, with an int constant also there isn't possible? I mean 5^{s_j} $\endgroup$
    – Clopen
    Jan 16, 2020 at 13:11
  • $\begingroup$ Not on the CP-SAT solver. I believe the original has it. But is is deprecated for non routing applications. $\endgroup$ Jan 16, 2020 at 15:01


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.