optimization - 数学 : Evaluation order during numerical optimisation of black box functions

标签 optimization wolfram-mathematica black-box operator-precedence

我正在尝试对 Mathematica 中的“黑盒”函数进行数值优化。原理图是这样的:

NMinimize[{comb[x,y,z], x > 0}, {x,y,z}]

其中 comb[x,y,z] 的定义与此类似:
comb[x_,y_,z_] := Module[{},
  Print[x,y,z];
  M = FindMaximum[SkewNormal[a,x,y,z], {a,x}] // First;
  val = f[x,y,z,M];
  Return[val];
];

然而,我尝试过的所有最小化函数似乎都没有立即为 comb[x,y,z] 提供数值,它最终试图用 x,y,z 的符号值来评估 FindMaximum(这很容易验证因为 Print[x,y,z] 也象征性地计算)。 Findmaximum 因此失败(FindMaximum::nrnum:函数值等等不是实数),因此最小化失败。

如何修复评估顺序,以便用数值评估 comb 的子功能?

最佳答案

FindMinimum 的评估顺序, FindMaximum , FindRootFindFit记录在 tutorial/UnconstrainedOptimizationSymbolicEvaluation 上文档页面。我认为非常相似的东西适用于 NMinimize功能。描述很长,所以我将在此处仅引用该页面中提出的解决方案:

If your function is such that symbolic evaluation will not keep the function as intended or will be prohibitively slow, you should define your function so that it only evaluates for numerical values of the variables. The simplest way to do this is by defining your function using PatternTest (?), as in f[x_?NumberQ]:=definition.

It may seem that symbolic evaluation just creates a bother since you have to define the function specifically to prevent it. However, without symbolic evaluation, it is hard for Mathematica to take advantage of its unique combination of numerical and symbolic power. Symbolic evaluation means that the commands can consistently take advantage of benefits that come from symbolic analysis, such as algorithm determination, automatic computation of derivatives, automatic optimization and compilation, and structural analysis.

关于optimization - 数学 : Evaluation order during numerical optimisation of black box functions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6990285/

相关文章:

c++ - 我如何在 C 中要求 "at least"一个 int 的大小

c - 有哪些重构方法可以减少编译代码的大小?

sql-server - 索引性能,集群与非集群

wolfram-mathematica - Mathematica中地 block 的标准颜色是什么?

jquery - 我可以使用 Safari 开发工具来忽略/黑盒 jQuery 脚本吗?

C# 与 C++ 的性能——为什么 .NET 不执行最基本的优化(如死代码消除)?

wolfram-mathematica - Mathematica 中的字符串验证

image-processing - 从图像中去除背景噪音

qa - QA 是否应该从严格的黑盒角度进行测试?

php - 如何保护容器即服务(caas)中的源代码和数据库结构?