How to define an Integral as an objective function in pyomo?

后端 未结 2 1293
长发绾君心
长发绾君心 2021-01-23 10:46

I want to be able to define an integral in pyomo as part of an objective function.

I cannot figure out what kind of expression is needed for the integral.<

相关标签:
2条回答
  • 2021-01-23 11:11

    This looks like a bug. You should open up a ticket here: https://github.com/Pyomo/pyomo/issues

    0 讨论(0)
  • 2021-01-23 11:17

    Gabe is right, this is indeed a bug in the Integral class and it has been fixed on the github repository. One other error in your example model is the specification of the Objective component. You should be using the 'rule' keyword instead of 'expr'

    def myobjective(model):
         return model.n
    model.obj = Objective(rule=myobjective)
    

    Also, I want to reiterate something mentioned in the online documentation for pyomo.dae. The Integral component is a prototype and not fully developed. I do not recommend using it for complex integrals or models that require high accuracy solutions. The Integral class uses the trapezoid rule for numerical integration. I would recommend converting any integrals in your problem to differential equations and solving them using the provided automatic discretization transformations.

    0 讨论(0)
提交回复
热议问题