Probability distributions in pyomo

时光总嘲笑我的痴心妄想 提交于 2020-02-07 00:38:23

问题


I want to solve a constrained NLP in Pyomo. However, the objective function includes a normal distribution where the argument of the normal distribution contains the decision variable, e.g. an expression like - (norm.cdf(model.x[0])).

But I receive this error:

 Cannot convert object of type 'ndarray' (value = 1) to a numeric value. 

Is there a way of working with normal distributions in Pyomo?


回答1:


I think that you can't use the variable as parameter, because pyomo's variable isn't the python's variable. You could write the expression of the normal distribution, maybe this works.




回答2:


I have seen that pyomo isn't a fan of some of the typical math you might be used to wanting in pyton or black box functions (Optimizing Fortran function in pyomo and https://groups.google.com/forum/#!topic/pyomo-forum/dK71XrHlBIM).

I think in this case you probably will need to write out an approximation of the normal cdf in the object (gross, I know). Might I suggest:

1/(model.x[0]*2.50663)*(1-model.x[0]**-2+3*model.x[0]**-4+15*model.x[0]**-6-105*model.x[0]**-8)

which is based on this post: https://mathoverflow.net/questions/19404/approximation-of-a-normal-distribution-function

Here is a cool paper of other options: http://www.hrpub.org/download/20140305/MS7-13401470.pdf



来源:https://stackoverflow.com/questions/54037358/probability-distributions-in-pyomo

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!