Unconstrained optimization problem fminunc with modified least squares
이전 댓글 표시
Hello, I am trying an unconstrained optimization problem with 5 design variables (each design variable is a vector). The function evaluation is of the form (written as a separate function file):
funcVal = sumsqr(Z-z_tilde) + (1/k0)*norm(b-b0).^2 + (1/k1)*norm(c-c0).^2
Here, "b0" and "c0" are the known values and I want the optimizer to optimize the values for b and c so that they are as close as possible to b0 and c0, respectively.
z_tilde is the function that takes the data point along with 8 Gaussians with parameters (a,b,c).
The optimization setup is as shown below:
x_ = rand(30,1);
x_ (1:8) = theta_ (1:3:end) -10;
x_ (9:16) = mus - 10;
x_ (17:24) = vars - 10;
funcVal = @(x_)evalObjFunc(X, Y, Z,...
x_ (1:8), reshape(x_ (9:16),1,8), reshape(x_ (17:24),1,8), reshape(x_(25:28),1,4), reshape(x_(29:30),1,2), ...
mus,vars);
opts = optimoptions(@fminunc,'MaxIterations',10000,'MaxFunctionEvaluations',50000,'CheckGradients',true);
opts.OptimalityTolerance = 1.000000e-16;
opts.StepTolerance = 1.000000e-11;
[theta,fval,grad] = fminunc(funcVal,x_, opts);
The error I'm getting is "fminunc stopped because it cannot decrease the objective function along the current search direction."
P.S: The function definition is correct, I have checked it several times and for different values of x_ the function returns different values.
댓글 수: 1
답변 (1개)
Matt J
2021년 6월 30일
0 개 추천
The exit message looks fine. It's not an error.
댓글 수: 2
Vinay PRAKASH
2021년 6월 30일
The exit message means fminunc thinks it succeeded. If it is terminating with every inital point that you choose, it means that it thnks every initial point is optimum. This can happen in functions that are locally flat everywhere, for example,
x=fminunc(@floor,1.3)
x=fminunc(@floor,1.5)
x=fminunc(@floor,2.7)
카테고리
도움말 센터 및 File Exchange에서 Choose a Solver에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!