简体   繁体   English

Matlab fmincon不产生全局最大值/最小值

[英]Matlab fmincon Not Yielding Global Maximum/Minimum

I am new to matlab, apologies if the question is silly. 我是Matlab的新手,如果这个问题很傻,我深表歉意。 I am using the fmincon function to derive the elements of a 我正在使用fmincon函数来导出a的元素 × matrix (X) which will maximize the following objective function subject to the non-negativity constraint and: 矩阵(X),它将在非负约束的约束下最大化以下目标函数和:

总和(x_ {ij})<100

{f(x(1,1))+(f(x(1,2))+ ... + f(x(1,n))} + Beta * {f(x(2,1))+ (f(x(2,2))+ ... + f(x(2,n))} + ... +(Beta ^(m-1))* {f(x(m,1)) +(f(x(m,2))+ ... + f(x(m,n))}

where 哪里

f(xij)= zeta * [(((alpha * pf *(xij ^ delta))-(pw * xij))^ gamma]

In the code I used to do this fmincon was used, as the objective function is non-linear: 在我用来执行此代码的代码中,使用了fmincon ,因为目标函数是非线性的:

function optim = optim(m,n)
A= ones(1,m*n);
b = 100;
z = zeros(m,n);
in = inf(m,n);
X = ones(m,n);

[x, bestval] = fmincon(@myfun2,X,A,b,[],[],z,in,[])

  function f = myfun2(x)
  Alpha = 5;
  %kappa = 5;
  zeta = 5;
  beta = 0.90909;
  delta = 0.4;
  gamma = 0.4;
  pf = 1;
  pw = 1;

  for i= 1:m
     f=0;
     sum(i)=0;
        for j=1:n
        sum(i) = sum(i) +((beta^(i-1))*(-1)*(zeta)*(((Alpha*pf.*((x(i,j)).^delta))- 
                 (pw.*x(i,j)))^gamma));

         end
     f = f+sum(i)
   end

 end
end

When the code was run for a 5x5 matrix (optim(5,5)), the resulting solution was x = 当代码针对5x5矩阵(optim(5,5))运行时,所得解决方案为x =

1.5439    1.5439    1.5439    1.5439    1.5439
1.5439    1.5439    1.5439    1.5439    1.5439
1.5439    1.5439    1.5439    1.5439    1.5439
1.5439    1.5439    1.5439    1.5439    1.5439
3.1748    3.1748    3.1748    3.1748    3.1748


bestval =

-31.8780 

But this is not a global minimum - as the marginal conditions specify at the global minimum we would have (for 1st row): 但这不是全局最小值-正如边际条件在全局最小值中指定的那样(对于第一行):

f'(x11)= ... = f'(x1n)

And so on for each row. 以此类推。 Also we would have for each column: 同样,我们将为每一列:

f'(x11)= beta * f'(x21)= ... =(beta ^ m-1)* f'(xm1)

For the first column and so on. 对于第一列,依此类推。 None of these conditions are satisfied by the resulting matrix. 这些条件都不满足所产生的矩阵。 I have looked at the the related questions in stack overflow and also the documentation and I have no inkling of how to get better results. 我已经看过堆栈溢出中的相关问题以及文档,并且我对如何获得更好的结果一无所知。 Is there a problem with the code? 代码有问题吗? Can the code be tweaked to get better results? 可以对代码进行调整以获得更好的结果吗?

Can I make the marginal conditions the stopping conditions and how could i go about doing that. 我可以将边际条件作为停止条件吗?我该如何去做。 or Can I use the Jacobian in some way? 或可以以某种方式使用雅可比行列式吗? Any help would be appreciated. 任何帮助,将不胜感激。 Thank You. 谢谢。

No optimization technique is guaranteed to return the global minimum. 没有任何优化技术可以保证返回全局最小值。 Some algorithms are guaranteed to find a local minimum if the Hessian is positive definite, however there is no mathematical way to determine only from the function values and its nth derivatives if a local minimum is the global minimum. 如果Hessian是正定的,则​​可以保证某些算法找到局部最小值,但是,如果局部最小值是全局最小值,则没有数学方法只能从函数值及其n阶导数中确定。

Now as for your termination conditions. 现在,您的终止条件。 You can pass in an options structure to fmincon, which has parameters to control the operation of fmincon. 您可以将选项结构传递给fmincon,该结构具有控制fmincon操作的参数。 You can choose a different algorithm to best suit your problem. 您可以选择其他算法以最适合您的问题。 I would read the docs for this options structure, and see if anything there fits what you are trying to do. 我将阅读有关此选项结构的文档,然后查看是否有任何适合您尝试执行的操作。

http://www.mathworks.com/help/optim/ug/optimoptions.html http://www.mathworks.com/help/optim/ug/optimoptions.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM