Parameter optimization! Need Help!
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello everyone,
I'm trying to optimizate some parameter by using the following function:
options=optimset('Algorithm','levenberg-Marquardt', 'LargeScale','off', 'DiffMaxChange',0.01, 'DiffMinChange',0.0001, 'TolFun',1e-5, 'TolX',0.001)
I already have the code and the optimization function complete, having the code starts from data which is read from an Excel book. Data is composed by two variables: strain and stress (two columns in the Excel book). I'm obtaining the results of the parameters successfully, but just from two variables in the mentioned Excel book, and I need to add another two (2), it is to say, I need to add more data to the same code in order to achieve more complete optimization results. It would be great if some of you can help me.
Here it is the code:
%% Optimization command
x0=[0.05, 1.2, 0.15]; %% Initial value of the parameters
% Vectors of lower and upper bounds on the design variables in x. Then, lb ? x ? ub
% For Levenberg-Marquardt algorithm use lb=[-inf] and ub=[inf]
lb=[0, 0, 0];
ub=[inf, inf, inf];
%lb=[0.1, 0.5];
%ub=[1, 1];
% optimization options:
options=optimset('Algorithm','levenberg-Marquardt', 'LargeScale','off', 'DiffMaxChange',0.01, 'DiffMinChange',0.0001, 'TolFun',1e-5, 'TolX',0.001);
[x,resnorm,residual,exitflag,output,lambda,jacobian]=lsqnonlin(@HSfun,x0,lb,ub,options);
%% Show Results and Optimization Details
dim=[1 1 1];
X=x.*dim;
resnorm;
exitflag;
output;
%% Read and plot observed data
Labdata=dlmread('C:\Hypoplastic Model Optimisation\Labdata.csv');
strain=Labdata(:,1);
qobserved=Labdata(:,2);
plot(strain,qobserved,'rx')
hold on
%% Read and plot calculated data
CalculatedData=xlsread('C:\Hypoplastic Model Optimisation\CalculatedData.xls');
strain=CalculatedData(:,1)*-100; % strain in percentage
qcalculated=CalculatedData(:,2);
plot(strain,qcalculated)
The script counts with an auxiliary function which is the one that really makes the optimization process:
%% Read observed data
Labdata=dlmread('C:\Hypoplastic Model Optimisation\Labdata.csv');
strain=Labdata(:,1);
qobserved=Labdata(:,2);
%% Calculated values
X=x.*dim;
u=X(1);
X1=X(2);
br=X(3);
%%%%%%% write parameters in files !!THIS DOES NOT MATTER FOR MATLAB COMMUNITY WHO ARE READING!!
dlmwrite('C:\Hypoplastic Model Optimisation\u.txt',u,'newline','pc','precision','%15.10f');
dlmwrite('C:\Hypoplastic Model Optimisation\X1.txt',X1,'newline','pc','precision','%15.10f');
dlmwrite('C:\Hypoplastic Model Optimisation\Br.txt',br,'newline','pc','precision','%15.10f');
%%% Macro to write parameters into PLAXIS project ! THIS DOES NOT MATTER FOR MATLAB COMMUNITY WHO ARE READING!!
!C:\Hypoplastic Model Optimisation\WriteParameters.exe
%%% Macro to run PLAXIS and extract calculated data into CalculatedData.xls file !!THIS DOES NOT MATTER FOR MATLAB COMMUNITY WHO ARE READING!!
!C:\Hypoplastic Model Optimisation\RunPlaxis.exe
%% Read Calculated raw data from CalculatedData.xls file
CalculatedData=xlsread('C:\Hypoplastic Model Optimisation\CalculatedData.xls');
strainraw=CalculatedData(:,1)*-100; % strain in percentage
qcalculatedraw=CalculatedData(:,2);
%%% Interpolate Calculated data to get values at same strain as observed data
strain_transp = transpose(strain); % sames strain values as observed data
qcalculated = interp1(strainraw,qcalculatedraw,strain_transp,'spline');
%% calculate the difference between observed and calculated response
F=qobserved-qcalculated';
end
I know this might be not so clear, but if somebody wanna help a suffering soul, thanks in advance.
4 comentarios
ziyue zhong
el 20 de En. de 2021
sorry,but I don't really understand what your trouble is...What is your optimise function?What's the relation between varibles(strain etc) and x?
Respuestas (0)
Ver también
Categorías
Más información sobre Stress and Strain 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!