how to get global optimum with Multistart?
    7 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Khadija
 el 11 de Dic. de 2024
  
    
    
    
    
    Comentada: Walter Roberson
      
      
 el 21 de Dic. de 2024
            I used lsqcurvfit to give an estimate to the parameters, but certainly the initial condition does not give a good fit, I implemented Multistart, and here is the error that appears:
Error using lsqcurvefit (line 289)
Function value and YDATA sizes are not equal.
Error in globaloptim.multistart.fmultistart
Error in MultiStart/run (line 257)
               globaloptim.multistart.fmultistart(problem,startPointSets,msoptions);
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in rectifModel (line 51)
[k,fval,Exitflag,Output,Solutions] = run(ms,problem,5);
                                     ^^^^^^^^^^^^^^^^^
Caused by:
    Failure in call to the local solver with supplied problem structure.
>> 
2 comentarios
  Star Strider
      
      
 el 11 de Dic. de 2024
				I do not know what you are doing, so I cannot comment with respect to your code.  
This can occur when a differential equation solver encounters a singularity and stops the integration before finishing it, so the data and model vectors do not have the same number of elemenets, or if the model results are the transpose of the data to be fitted, even though the number of elements in the two vectors (or matrices) are the same.  
Respuesta aceptada
  Walter Roberson
      
      
 el 12 de Dic. de 2024
        tdata = specific_data(:, 1);
Hdata = specific_data(:, 2);
HSdata = specific_data(:, 3);
tdata is an 11 x 1 column vector formed from the first column of the input. Similarly for HData and HSdata
tforward = 2009:0.1:2019; 
That is a 1 x 101 row vector
problem = createOptimProblem('lsqcurvefit','x0',k0,'objective',@simulatedhs,...
    'lb',[0 0 1 1 1 1 0 0 1 1 1 1],'ub',[1 1 inf inf inf inf 1 1 inf inf inf inf],'xdata',tforward ,'ydata',[Hdata,HSdata] );
So the lsqcurvefit is to pass in a 1 x 101 vector (tforward) as the xdata. And according to the problem creation, it expects back ydata which is [11 x 1, 11x1] for an overall solution of 11 x 2.
function simulated_data = simulatedhs(k,tdata)
The tdata received here will be the same as xdata -- a 1 x 101 vector.
[T, Y] = ode15s(@(t,y)modelhs(t,y,k),tdata,[ 12280000.0 100.0 2.0  0.0  6.0 2.0  0.0 ],odeset('RelTol',1e-10,'AbsTol',1e-10));
The tdata gets passed to ode15s as time data. It is a vector with length greater than 2, so the output of ode15s will normally have length(tdata) time entries (unless ode15s aborts early.)
M = Y(:,1);
S = Y(:,2);
H1 = Y(:,3);
H2 = Y(:,4);
H1S=Y(:,5);
H2S=Y(:,6);
Those will each be length(tdata) x 1.
H=phi_H * ( H1 + c1 *  H1S ).*M + rho1 * gamma * H1S + alpha.* H2+rho4*beta.* H1;
HS=theta1*phi_S .* ( S + c2 .*  H1S ).*H1 + theta2*phi_H .* ( H1 + c1 .*  H1S ).*S+ rho2*alpha.*H1S+rho5*beta.*H1S;   
H and HS are calculated in terms of length(tdata) x 1 vectors, so they will each be length(tdata) x 1 results.
simulated_data = [H,HS];
so simulated_data will be length(tdata) x 2.
But this does not match ydata, which is 11 x 2.
The fix is to use 'xdata', tdata and get rid of tforward 
16 comentarios
  Walter Roberson
      
      
 el 21 de Dic. de 2024
				You can always try genetic algorithm.
My personal experience is that ga() does not work especially well on most curve fitting tasks
Más respuestas (0)
Ver también
Categorías
				Más información sobre Linear Least Squares en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!