Unconstrained optimization problem fminunc with modified least squares

1 Ansicht (letzte 30 Tage)
Vinay PRAKASH
Vinay PRAKASH am 30 Jun. 2021
Bearbeitet: Matt J am 30 Jun. 2021
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 Kommentar
Matt J
Matt J am 30 Jun. 2021
Bearbeitet: Matt J am 30 Jun. 2021
Since it is an unconstrained least squares problem, you might see performance advantages if you use lsqcurvefit() or lsqnonlin() instead.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Matt J
Matt J am 30 Jun. 2021
The exit message looks fine. It's not an error.
  2 Kommentare
Vinay PRAKASH
Vinay PRAKASH am 30 Jun. 2021
Hey Matt, thanks for your reply. But the problem is I get the same exit message for any value initial input value. It means the optimizer is not even trying to optimize the parameters and at the end I get the same output that I initially provided. Perhaps, I am going wrong somewhere.
Matt J
Matt J am 30 Jun. 2021
Bearbeitet: Matt J am 30 Jun. 2021
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)
Initial point is a local minimum. Optimization completed because the size of the gradient at the initial point is less than the value of the optimality tolerance.
x = 1.3000
x=fminunc(@floor,1.5)
Initial point is a local minimum. Optimization completed because the size of the gradient at the initial point is less than the value of the optimality tolerance.
x = 1.5000
x=fminunc(@floor,2.7)
Initial point is a local minimum. Optimization completed because the size of the gradient at the initial point is less than the value of the optimality tolerance.
x = 2.7000

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by