问题描述
我想在 Pyomo 中解决受约束的 NLP.然而,目标函数包括一个正态分布,其中正态分布的参数包含决策变量,例如像 - (norm.cdf(model.x[0]))
这样的表达式.
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]))
.
但我收到此错误:
Cannot convert object of type 'ndarray' (value = 1) to a numeric value.
有没有办法在 Pyomo 中处理正态分布?
Is there a way of working with normal distributions in Pyomo?
推荐答案
我已经看到 pyomo 不喜欢某些您可能习惯于在 pyton 或黑盒函数中使用的典型数学(在 pyomo 中优化 Fortran 函数 和 https://groups.google.com/forum/#!topic/pyomo-forum/dK71XrHlBIM).
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).
我认为在这种情况下,您可能需要写出对象中正常 cdf 的近似值(粗略,我知道).我可以建议:
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)
基于这篇文章:https://mathoverflow.net/questions/19404/近似正态分布函数
这是其他选项的很酷的论文:http://www.hrpub.org/download/20140305/MS7-13401470.pdf
Here is a cool paper of other options: http://www.hrpub.org/download/20140305/MS7-13401470.pdf
这篇关于pyomo 中的概率分布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!