Problem with lsqnonlin: Optimization completed because the size of the gradient at the initial point is less than 1e-4 times the value of the function tolerance.
14 views (last 30 days)
Show older comments
Hi,
I have a function "fun103r" and it's output is "ER". I am transforming this function to an optimization expression using "fcn2optimexpr" to optimize "ER" with a coouple of variables including "k". The optimization variable is k (8x1). And to define extra (non-optimized) parameters, I'm using an anonymus function "f". Unfortunately, no iteration is performed when I try to use "lsqnonlin" and I receive this message: "Optimization completed because the size of the gradient at the initial point is less than 1e-4 times the value of the function tolerance".
I'll be glad if you could help.
clear;
clc;
%run('Fun103r');
Pa =216;
sp=7;
L=0.2;
Lb=[13.2 14.0 14.0 14.0 14.0 14.0 13.2];
N=zeros(sp);
ss=0;
E = 3.4342e10;
J = 0.9028 ;
na=6;
d1=[2.0 4.0 6.2 15.2 17.4 19.4];
opts = detectImportOptions('AppBR.xlsx');
preview('AppBR.xlsx',opts);
opts.Sheet = 'D1-3BR';
opts.SelectedVariableNames = [1:9];
opts.DataRange = '2:484';
Rtr3=readmatrix('AppBR.xlsx',opts);
k = optimvar('k',8,1); % 8-by-1 optimization variable
[ER] = fcn2optimexpr(@Fun103r,k); % transformation of function "Fun103r"
k0=[100000; 200000; 100000; 200000; 200000; 100000; 200000; 100000]; % starting point for k
f = @(k)Fun103r(ss,Pa,sp,L,Lb,N,E,J,na,d1,k,Rtr3); % anonymus function to consider extra (non-optimized) parameters
options = optimoptions('lsqnonlin','Display','iter','FiniteDifferenceStepSize',1e-3);
options.StepTolerance = 1e-10;
options.Algorithm = 'levenberg-marquardt';
k=lsqnonlin(f,k0,options);
4 Comments
Torsten
on 29 Jan 2023
Edited: Torsten
on 29 Jan 2023
It's necessary that the functions ER you return to lsqnonlin from "Fun103r" are differentiable with respect to the parameters k. If statements and round commands are forbidden. So there is no hope you will get reasonable results for k.
Did you call Fun103r with your initial values for k and inspected the results returned from your function ?
Answers (0)
See Also
Categories
Find more on Get Started with Optimization Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!