필터 지우기
필터 지우기

minimization problem -using simplex method

조회 수: 5 (최근 30일)
muthu kumar
muthu kumar 2011년 5월 24일
sir i want to implement minimization problem using simplx method can i use matrix for this and how can i iterate each time the matrix as per simplex method rule, plz any one if know tell me (my question simply tells processing of simplex method )

채택된 답변

James Tursa
James Tursa 2011년 5월 24일
Which Simplex Method? Dantzig or Nelder-Mead?
  댓글 수: 5
James Tursa
James Tursa 2011년 5월 25일
@Walter: It was not clear to me from original post what problem was being solved and what the "matrix" was. I would also have assumed a Linear Programming problem as you did (which, btw, is also a "continuous" function problem ... not sure what you mean by "discrete") but was hoping for more clarification from OP. (Side Note: Neldor-Mead could also be used to solve a LP "matrix" problem, albeit I would expect not very efficiently)
Walter Roberson
Walter Roberson 2011년 5월 25일
With the question as given, I did not consider a Linear Programming problem: it looked to me like perhaps the poster might just be looking for a way to find the minima of an array (number of dimensions not specified.) Why they would want that, I don't know.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

antonio espejo
antonio espejo 2012년 3월 8일
Hello,
My name is Antonio, and I try to solve an optimization proble.
I have a mathematical model, Lines 1-82 of code, that calculate values of 'xp' and 'Pp' in time 'bucle j', assumming an initial values A,B, Pa(1) y Q, that I call with a vector 'x'. Finally, I calculate in each time 'L', and 'Ls', where Ls=sum(L(j)).
Now, I want minimice 'Ls' and to obtain the optimal values of 'x' vector. The state of the art indicates that use the multidimensional simplex method fo Nelder-M.
can anyone help?
I know that the optimal values should be approximately:
% A= 1.24 * 10-8
% B= 1.625
% Q= 2.413 * 10-2
% Pa(1)= 1.504 * 10-2
Thanks in advance,
clear all
close all
clc
%Data of paper:
%Katul y col. 1993. Estimation of in Situ Hydraulic Conductivity Function from Nonlinear Filtering Theory. Water Resources Research, 29: 1063-70.
%%Computational scheme (A Appendix)
%Observed measured
t=[0.01;0.09;0.1;0.1745;0.1745;0.4322;0.5194;0.8644;0.9516;1.3838;1.8993;2.4187;2.8509;3.4536;3.8858;4.318;5.0119;5.5274;5.9596;6.3045;6.8239;7.3434;7.9461;8.291;8.8977;9.5876;10.1071;10.5393;11.0547;11.4869;12.0936;12.4385;12.958;13.3862;13.9929;14.5956;14.8573;15.6344;16.4116;17.0143;17.4465;17.8787;18.4853;18.8303;19.5202;19.9524;20.4718;20.9873;21.5067;22.0262;22.2839;22.9738;23.4933;23.9255;24.5282;25.0476;25.3925;26.0825;26.4314;26.9469;27.4663;27.8985;28.4179;29.0206;29.3656;29.885;30.4877;31.0071;31.3521;31.8715;32.391;32.9937;33.5131;33.9453;34.6352;35.0674;35.4124;35.9318;36.709;36.9667;37.6566;38.0888;38.6955;39.1277;39.4726;40.0753;40.7653;41.027;41.6297;42.1491]; %time, days
z=[0.4765;0.4707;0.4691;0.4609;0.466;0.4495;0.4445;0.4484;0.4456;0.4362;0.4339;0.4339;0.4343;0.4284;0.4269;0.4202;0.4249;0.4175;0.4202;0.4131;0.4131;0.4135;0.4147;0.4081;0.4061;0.4061;0.4026;0.4061;0.3959;0.3999;0.3959;0.394;0.3995;0.3983;0.3967;0.3963;0.3928;0.3944;0.3959;0.3971;0.3936;0.3862;0.3944;0.3916;0.3905;0.392;0.3815;0.3823;0.3862;0.3795;0.3913;0.3838;0.3791;0.3811;0.3838;0.3807;0.3873;0.3779;0.3819;0.3799;0.3803;0.3779;0.3823;0.3756;0.3826;0.3815;0.3807;0.3693;0.3799;0.3736;0.3854;0.3725;0.3826;0.374;0.3748;0.3721;0.3748;0.374;0.3768;0.3752;0.376;0.3709;0.3811;0.3662;0.3658;0.3662;0.3697;0.3721;0.3701;0.3713]; %average soil moisture content, v/v
zmax=max(z);
H= [-1.0517;-2.0047;-2.3471;-1.9071;-2.2988;-2.1271;-2.2494;-2.1024;-2.0294;-2.4941;-1.9564;-0.9047;-2.0541;-2.4447;-1.9071;-2.2988;-1.9071;-2.3235;-1.9564;-2.2494;-2.0294;-2.1518;-1.9318;-1.9811;-2.0047;-1.9071;-2.2247;-1.9811;-1.9811;-2.0047;-1.4671;-2.1271;-2.15;-2.0788;-2.1024;-1.9564;-2.2247;-2.0047;-2.2011;-2.1024;-1.5647;-1.5647;-1.2471;-1.4917;-1.5894;-1.4917;-1.54;-1.9071;-1.7118;-1.7118;-1.3447;-1.8094;-1.9564;-1.7611;-0.9294;-1;-1.7847;-1.6871;-1.54;-1.6624;-1.54;-1.7118;-1.4671;-1.7611;-1.4188;-1.7611;-1.54;-1.6871;-1.4424;-1.5164;-1.3447;-1.29;-1.5647;-1.2471;-1.8588;-1.1988;-1.3447;-1.0517;-1.0764;-1.1988;-1.1741;-0.95;-0.9047;-1.0271;-0.807;-0.7824;-0.66;-0.8564;-0.4164;-0.587];%hidráulic gradient, mbar/cm
R=0.02; %calculated value, constant
%Create arrays of zeros
n=length(t);
xp=zeros(length(t),1); %Predicted value of x (xp is the value of z modeled with the additional application of Kalman filter)
xa=zeros(length(t),1); %Updated value of x, with use of observation 'z' and the gain of Kalman filter
Pp=zeros(length(t),1); %Predicted value of P (error)
Pa=zeros(length(t),1); %Updated value of P with use of observation 'z' and the gain of Kalman filter
L=zeros(length(t),1);
Kg=zeros(length(t),1); %Kalman gain obtained in each time with step 5
% h (meaurement time increment)neccesary to resolution of differential equations with Runge Kutta method (step 3)
for i=1:n-1
t0(i)=t(i);
tf(i)=t(i+1);
h(i)=tf(i)-t0(i);
end
% 1. initial conditions
x=[1,1,1,1];
x0=x;
% 1.a) xp;
xa(1)=z(1);
xp0(1)=xa(1);
xp(1)=xp0(1);
% 1.b) Pp;
Pa(1)=x(4); %Assume this value as A, B, Q, and after step 9 is to adjust A, B, Q, Pa (1) to be minimal Ls
Pp0(1)=Pa(1);
Pp(1)=Pp0(1);
% 2. Assume [A,B,Q]
A= x(1);
B= x(2);
Q= x(3); % I start assuming A, B, Q, Pa(1;
% 3. Numerically integrate dxp/dt and dPp/dt, Runge Kutta method with 'for' bucle in all times
% Press, W.H.; W.T. Vettering; S.A. Teukolsky and B.P. Flannery. 1992. Numerical recipes in Fortran. 963 págs. Cambridge University Press, New York.
% Page 701-740: Integration of ordinary differential equations
for j=2:n
%3.a) Resolution of dxp/dt=-A*(Xp^B)*H
xp0(j)=xa(j-1);
kx1(j)=-A*(xp0(j)^B)*H(j-1);
kx2(j)=-A*((xp0(j)+kx1(j)/2)^B)*H(j-1);
kx3(j)=-A*((xp0(j)+kx2(j)/2)^B)*H(j-1);
kx4(j)=-A*((xp0(j)+kx3(j))^B)*H(j-1);
xp(j)=xp0(j)+h(j-1)*((kx1(j)+2*(kx2(j)+kx3(j))+kx4(j))/6);
%3.b) Resolution of dPp/dt=-2*(h1*A*B*(xp1^(B-1)))*Pp+Q
Pp0(j)=Pa(j-1);
kP1(j)=-2*(H(j-1)*A*B*(xp(j)^(B-1)))*Pp0(j)+Q;
kP2(j)=-2*(H(j-1)*A*B*((xp(j)+kP1(j)/2)^(B-1)))*Pp0(j)+Q;
kP3(j)=-2*(H(j-1)*A*B*((xp(j)+kP2(j)/2)^(B-1)))*Pp0(j)+Q;
kP4(j)=-2*(H(j-1)*A*B*((xp(j)+kP3(j))^(B-1)))*Pp0(j)+Q;
Pp(j)=Pp0(j)+h(j-1)*((kP1(j)+2*(kP2(j)+kP3(j))+kP4(j))/6);
% 4. Estimate of L
% L(j)=((z(j)-xp(j))^2)/Pp(j);
%
% sumrosen=@(x)sum(L);
% 5. Estimate of Kg
Kg(j)=Pp(j)/(Pp(j)+R);
% 6. Updated: xa(t), Pa(t)
xa(j)=xp(j)+Kg(j)*(z(j)-xp(j));
Pa(j)=Pp(j)*(1-Kg(j));
end
% 7. Repeat steps 3-6 with the initial conditions xa1 y Pa1 (I do it for all time by introducing a loop)
% 8. Computo ahora el valor de Ls
% % FUNCIÓN A MINIMIZAR, paso 9
% 9. Repeat steps 1.b) - 8) until Ls is minimal. Thereby adjusting the initial values ??of A, B, Q y Pa(1).
% Simplex method for multidimensional cases, lsqnonlin matlab function
% Parameters obtained after optimization by the authors using multidimensional simplex method (Katul y col. 1993)
% A= 1.24 * 10-8
% B= 1.625
% Q= 2.413 * 10-2
% Pa(1)= 1.504 * 10-2
for i=2:length(xp)
var1=xp(i);
var2=z(i);
var3=Pp(i);
var4=H(i);
Ls=@(x)(((z(1)-(-x(1)*(xp(1)^x(2))*H(1)))^2)/(-2*(H(1)*x(1)*x(2)*(xp(1)^(x(2)-1)))*x(3)+x(4)))+(sum(((var2-(-x(1)*(var1^x(2))*var4))^2)/(-2*(var4*x(1)*x(2)*(var1^(x(2)-1)))*var3+x(4))));
end
% unconstrained fminsearch solution
[xopt,Ls]=fminsearch(Ls,x0);
Ls
Aopt=xopt(1)
Bopt=xopt(2)
Pa1opt=xopt(3)
Qopt=xopt(4)
  댓글 수: 1
Walter Roberson
Walter Roberson 2012년 3월 8일
Antonio, I recommend that you create a new Question for this.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by