Clear Filters
Clear Filters

object function iteration gets stuck

4 views (last 30 days)
Sheng Liu
Sheng Liu on 5 Mar 2012
Help!!!I'm comfused!!! why it always get stuck when I tried a iteration of the object function ?both in the optimization tool and command window?
As in the title,I'm calculating the minimum values of a 6 parameters-function with the
fminsearch function, both tried in the tool box and the commmand window,and it always get seized up and be no responsible at all, and the 'stop'and 'pause' buttons will not work at all. Did anyone has met the same problem?
Thank you!
And part of the function codes:
options=optimset('OutputFcn',@outf,'Display','iter','MaxIter',20);
hold on
objfun=@fitmeson;
[x,fval,exitflag,output]=fminsearch(objfun,[0.0021,0.062,0.329,0.875,0.394,10.009],options)
hold off
and the results screenshots:
>> OutputFcn
r = 0.0021 0.0698836 0.289626 0.8604 0.4159 10
Iteration Func-count min f(x) Procedure
0 1 0.102388
r = 0.0021 0.0698836 0.289626 0.8604 0.4159 10
1 7 0.0980085 initial simplex
r = 0.0021 0.0698836 0.304107 0.8604 0.4159 10
2 9 0.0832537 reflect
r = 0.002135 0.0710483 0.294453 0.87474 0.395105 10.1667
3 10 0.0832537 reflect
r = 0.002135 0.0710483 0.294453 0.87474 0.395105 10.1667
4 11 0.0832537 reflect
r = 0.002135 0.0710483 0.294453 0.87474 0.395105 10.1667
5 13 0.0753749 expand
r = 0.00196194 0.0685895 0.306789 0.911387 0.397416 10.0093
6 15 0.0753749 contract inside
r = 0.00196194 0.0685895 0.306789 0.911387 0.397416 10.0093
7 16 0.0753749 reflect
r = 0.00196194 0.0685895 0.306789 0.911387 0.397416 10.0093
8 17 0.0753749 reflect
r = 0.00196194 0.0685895 0.306789 0.911387 0.397416 10.0093
9 19 0.0753621 reflect
r = 0.0021031 0.0678226 0.305696 0.896988 0.386462 10.0147
10 20 0.0753621 reflect
r = 0.0021031 0.0678226 0.305696 0.896988 0.386462 10.0147
11 28 0.0743308 shrink
r = 0.00203252 0.068206 0.306243 0.904187 0.391939 10.012
12 30 0.0743308 contract outside
r = 0.00203252 0.068206 0.306243 0.904187 0.391939 10.012
13 31 0.0743308 reflect
r = 0.00203252 0.068206 0.306243 0.904187 0.391939 10.012
14 33 0.0736525 reflect
r = 0.00207703 0.0665389 0.305426 0.895153 0.391695 10.1499
15 35 0.0729338 reflect
r = 0.0020862 0.066819 0.30623 0.89782 0.39315 9.9468
16 37 0.0729338 contract inside
r = 0.0020862 0.066819 0.30623 0.89782 0.39315 9.9468
17 38 0.0729338 reflect
r = 0.0020862 0.066819 0.30623 0.89782 0.39315 9.9468
18 39 0.0729338 reflect
r = 0.0020862 0.066819 0.30623 0.89782 0.39315 9.9468
And whatever I set the iteration as 100 or 40 or some other values,it will stuck here at 18th iteration~!!!!

Answers (2)

Titus Edelhofer
Titus Edelhofer on 5 Mar 2012
Hi,
what happens If you hit Ctrl-C? Do you see an error message that tells you, where you interupted the calculation? If yes, set a breakpoint there and start again. When you come to the 18th iteration, take a look at the sizes of variables ...
Titus
  2 Comments
Sheng Liu
Sheng Liu on 5 Mar 2012
thank you so much!I will try!
Sheng Liu
Sheng Liu on 7 Mar 2012
hello,Thank you for your good advice,I've already tried for several times,and I get the same result.
After Ctrl-C,it appears in the command window like this:
Operation terminated by user during prufer
In propagate_solution (line 193)
[theta0,theta1] = prufer(y(1),y(2),y1(1),y1(2),e,vbar,h,S);
In locate_eigenvalue (line 39)
[yr,yer,theta] =
propagate_solution(eold,yf,yef,part.imatch+1,truncb,part,Vmatch,false);
In calculate_eigenvalues>init_ev (line 454)
[prufc,enew] = locate_eigenvalue(ec,part,vmin,trunca,truncb);
In calculate_eigenvalues>calculate_eigenvalue (line 303)
[e,varargout{2},varargout{3},varargout{4},varargout{5},small]...
In calculate_eigenvalues (line 171)
[ev,e1,pruf1,e2,pruf2,pruf,fail] =
calculate_eigenvalue(e1,pruf1,e2,pruf2,n,bp,Vmin,Vmax,trunca,truncb);
In cpm/get_ppm (line 12)
varargout{1} = calculate_eigenvalues(varargin{3:end});
In ppm/get_eigenvalues (line 130)
E=get_ppm(ppm_child,'eigenvalues',emin,emax,nmin,nmax);
In massp (line 43)
E=get_eigenvalues(cp,0,4,true);
In fitmeson>@(r)sum(abs(massp(r)-mp)./mp) (line 23)
Ep=@(r) sum(abs(massp(r)-mp)./mp);%sums of the average error
In fitmeson (line 29)
E=(Ef(r)+Ep(r))/N;%calculating average error
In fminsearch (line 362)
x(:) = v(:,j); fv(:,j) = funfcn(x,varargin{:});
In OutputFcn (line 2)
[x,fval,exitflag,output]=fminsearch(@fitmeson,[0.0021,0.062,0.329,0.875,0.394,10.009],options)
K>>
and when it get stuck all the other applications have response except MATLAB,and the occupancy rate of CPU were not very high,just about 30~40 percent.
I have no idea about what the error message mean,so please help me,thank you!!!

Sign in to comment.


Titus Edelhofer
Titus Edelhofer on 7 Mar 2012
Hi,
what you see is the stack trace, i.e., fminsearch calls fitmeson, fitmeson calls massp etc. Take a look at the top most lines:
In propagate_solution (line 193)
[theta0,theta1] = prufer(y(1),y(2),y1(1),y1(2),e,vbar,h,S);
In locate_eigenvalue (line 39)
[yr,yer,theta] =
propagate_solution(eold,yf,yef,part.imatch+1,truncb,part,Vmatch,false);
In calculate_eigenvalues>init_ev (line 454)
[prufc,enew] = locate_eigenvalue(ec,part,vmin,trunca,truncb);
What happens here in the functions? Is there perhaps some loop in the locate_eigenvalue function that does not terminate? Or in propage_solution? When you stopped there, use the debugger to identify loop counters (if there) or other variables that might diagnose what happens ...
Titus

Community Treasure Hunt

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

Start Hunting!