Fsolve stops fsolve stopped because the sum of squared function values, r, has gradient with relative norm 0; this is less than options.OptimalityTolerance
조회 수: 20 (최근 30일)
이전 댓글 표시
Fsolve not converging:
FUNCTION:
%%Defines all inputs and then goes into a for loop with anonymous functions for the unknown parameters
%%Equation has 7 unknown variables, No. of equations = 8
SCRIPT TO RUN THE FUNCTION:
x = @reactCoil_tuning_rev1
x0 = [ 0.023,0.8,0.4,0.64,0.57,-0.0363,0.42,-.104]
x = fsolve(fun,x0,optimset( 'Algorithm','trust-region-reflective','Display', 'final-detailed'))
ERROR:
fsolve stopped because the sum of squared function values, r, has gradient with
relative norm 0.000000e+00; this is less than options.OptimalityTolerance = 1.000000e-06.
However, r = 1.596198e+03, exceeds sqrt(options.FunctionTolerance) = 1.000000e-03.
Optimization Metric Options
norm(grad r) = 0.00e+00 OptimalityTolerance = 1e-06 (default)
r = 1.60e+03 sqrt(FunctionTolerance) = 1.0e-03 (default)
x =
0.4836 1.4093 3.1116 5.1671 7.3562 -1.4461 -7.1655 -4.6443
fval =
-2.2000 -19.2098 -6.4000 -14.7215 -6.9000 -14.6362 -3.0000 -19.1888 -4.0000 -17.5961
exitflag =
-2
댓글 수: 0
답변 (4개)
Walter Roberson
2018년 6월 6일
The function output looks constant in the area that was examined, but the function value was not 0
You need to double-check that fun is not producing a constant value.
But first you might want to check to see what fun is, since
x = @reactCoil_tuning_rev1
is putting the function handle into x rather than into fun.
댓글 수: 0
Roshni Khetan
2018년 6월 7일
댓글 수: 3
Walter Roberson
2018년 6월 7일
There is no solution near that x0.
My probes so far suggest that some of the outputs have no zeros (but some of them do have singularities, and some of them can go complex valued.)
Roshni Khetan
2018년 6월 7일
편집: Walter Roberson
2018년 6월 7일
댓글 수: 2
Walter Roberson
2018년 6월 7일
You have
for i = 1:5
but i cannot exceed 4 when you have 4 items in those vectors you initialize at the beginning.
I am having a look at the function; it might take a while.
DHABALESWAR MOHAPATRA
2023년 9월 29일
How to fix the following error while using fsolve,
fsolve stopped because the sum of squared function values, r, is changing by less
than options.FunctionTolerance = 1.000000e-05 relative to its initial value.
However, r = 1.085832e+01, exceeds sqrt(options.FunctionTolerance) = 3.162278e-03.
댓글 수: 1
Walter Roberson
2023년 9월 29일
Your search has found a location where the function is somewhat close to "flat" but which is not close enough to zero. For example if the function where @(x) x.^2 + 1 then if you are searching over real values the function cannot be less than 1.0 .
Sometimes you can get around that by using better initial starting points --- that is, sometimes the problem is that you have hit a local minima.
But sometimes it can be very difficult to find a starting point that works, if the function is badly scaled or is very "bumpy". Sometimes rescaling can help but sometimes there just isn't any practical numeric solution that you would be able to find using these methods.
And sometimes... there just isn't any solution.
참고 항목
카테고리
Help Center 및 File Exchange에서 Nonlinear Optimization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!