我尝试使用accord.net提供的NelderMead解算器进行优化,如下所示:
var solution = new NelderMead(vecCMrIni.Length, CMOpt);
// CMOpt is the function to be minimized
for (int m = 0; m < vecCMrIni.Length; m++) // set lower and upper bound
{ solution.LowerBounds[m] = vecCMrLB[m];
solution.UpperBounds[m] = vecCMrUB[m];}
bool success = solution.Minimize(vecCMrIni);// minimize CMOpt, with vecCMrIni as initial.
不幸的是,事实证明解算器会产生一个与初始向量vecCMrIni完全相同的解决方案。有没有办法克服这个问题?谢谢
答案 0 :(得分:1)
我遇到了同样的问题,在我的情况下,它解决了设置“最大值”的价值:
// (this value depends on your function, but try to put a huge negative value)
solution.MaximumValue = -1e6;
在此更改之前,“最小化”方法返回状态:MinimumAllowedValueReached