遗传算法求解非线型方程的问题
我用遗传算法解非线性方程,求解5个变量,其中系数矩阵非常大,总得不到理想的结果,
然后需要算出p(i)的值 i=1:10(其中 sum(p)=1)
麻烦各位大侠帮我看看哪里出问题了!
拜谢啊!!
fk =
1.0e+011 *
Columns 1 through 6
-0.000000001591165-0.000000001264206-0.000000000867055-0.000000000490284-0.000000000095361 0.000000000295842
0.000000253180606 0.000000160716363 0.000000076278847 0.000000025353490 0.000000002406974 0.000000010059968
-0.000040285211850-0.000020548657733-0.000006811826251-0.000001376812645-0.000000052694515 0.000000378191614
0.006410041911401 0.002642590128756 0.000617603691203 0.000078033470928 0.000001351497371 0.000015231521429
-1.019943433795469-0.341841290104528-0.056847878951163-0.004584811803819-0.000034955602952 0.000643265345850
Columns 7 through 10
0.000000000671125 0.000000001058743 0.000000001428334 0.000000001798466
0.000000046173895 0.000000113158376 0.000000204761177 0.000000323448103
0.000003257815446 0.000012215607411 0.000029469059452 0.000058171051345
0.000235631443805 0.001332500713797 0.004258937242707 0.010461867547892
0.017452977836325 0.146923470381716 0.618256416507724 1.881531621994822
lb=*(-1)
ub=
options=optimset('largescale','off')
=ga(@text1,5,[],[],[],...
[],lb,ub,[],options)
%目标函数
function funtionError=text1(X)
funtionError=...
[(sum(exp(-*fk))*F1...
-fk(1,:)*(exp(-*fk))').^2+...
(sum(exp(-*fk))*F1...
-fk(2,:)*(exp(-*fk))').^2+...
(sum(exp(-*fk))*F3...
-fk(3,:)*(exp(-*fk))').^2 + ...
(sum(exp(-*fk))*F4...
-fk(4,:)*(exp(-*fk))').^2+...
(sum(exp(-*fk))*F5...
-fk(5,:)*(exp(-*fk))').^2];
%理想的结果应该是
% X=[
%-0.01149493659894
% 0.00085613654997
%-0.00000088487795
%-0.00000000851687
% 0.00000000010986
%]
%求解p(1)-p(10)
p=exp(-*fk)/...
sum(exp(-*fk))
[ 本帖最后由 sigma665 于 2008-4-18 12:58 编辑 ] 非线型方程用1stopt求解会更好点 1stopt不是特别熟悉。。说明书也不详细
主要是数据从文件输入不知道怎么搞,有没有专门介绍1stopt的资料? 原帖由 kangtj 于 2008-4-18 16:39 发表 http://www.chinavib.com/forum/images/common/back.gif
1stopt不是特别熟悉。。说明书也不详细
主要是数据从文件输入不知道怎么搞,有没有专门介绍1stopt的资料? google一下,或者搜索版面,n多例子 麻烦帮我看一下这个是什么问题?
回复 5楼 的帖子
你把你的方程贴一下吧回复 楼主 的帖子
对于gads工具箱,你可以详细看看遗传操作及参数的选择等help文件,然后尝试不同的选项设置。对于GA,不同的遗传操作,不同的参数,会带来差别很大的效果。
每种优化方法都有其优缺点,并不是适合所有的优化问题,这个是已经被大家公认的了。我觉得GA是目前使用最广,理论最成熟的现代优化算法,通过合理的操作,得到的结果还是很理想的。 原帖由 sigma665 于 2008-4-18 18:21 发表 http://www.chinavib.com/forum/images/common/back.gif
你把你的方程贴一下吧
其中fk=[
-123.401986666667, 15309.8526427374, -1909789.96410041, 239549341.560198, -30214602491.039,
-87.6375305, 7741.2805593795, -689528.27440591, 61952373.811834, -5616144306.013,
-59.06265104918, 3586.5719185062, -223770.00498736, 14320890.485566, -937932650.125,
-28.439255018957, 879.2160346562, -29081.78717329, 1013450.252394, -36742842.333,
2.815480861073, 87.4964063986, 713.65902354, 16697.447204, 196487.477,
33.027548857143, 1173.1652538497, 44394.49294689, 1769229.311412, 7343630.493 ,
64.045056222222, 4201.7966978657, 282266.01166872, 19393922.004712, 1360598257.263,
93.538933217391, 8819.304635927, 838503.24465969, 80419975.012864, 7783014155.159,
127.24891, 16253.0044120957, 2083630.02919474, 268092890.315688, 34616841265.119,
173.02841, 29985.3187910965, 5204399.56611482, 904686543.289774, 157501253705.876]
= 我用1stOpt编了个程序(源码如下),可是调试运行的时候没反应
不知道怎么回事。。有用1stOpt的高手帮我看看啊。。
Title "maxtrix-qiujie";
Parameters x(1:5)[-1,1];
//Variable ;
Constant F(1:10,1:5)=[
-123.401986666667, 15309.8526427374, -1909789.96410041, 239549341.560198, -30214602491.039,
-87.6375305, 7741.2805593795, -689528.27440591, 61952373.811834, -5616144306.013,
-59.06265104918, 3586.5719185062, -223770.00498736, 14320890.485566, -937932650.125,
-28.439255018957, 879.2160346562, -29081.78717329, 1013450.252394, -36742842.333,
2.815480861073, 87.4964063986, 713.65902354, 16697.447204, 196487.477,
33.027548857143, 1173.1652538497, 44394.49294689, 1769229.311412, 7343630.493 ,
64.045056222222, 4201.7966978657, 282266.01166872, 19393922.004712, 1360598257.263,
93.538933217391, 8819.304635927, 838503.24465969, 80419975.012864, 7783014155.159,
127.24891, 16253.0044120957, 2083630.02919474, 268092890.315688, 34616841265.119,
173.02841, 29985.3187910965, 5204399.56611482, 904686543.289774, 157501253705.876];
Constant Fr(1:5)=[
1.05137753485,
1957.02063533292 ,
8214.58926666724 ,
12077012.3703088,
219286227.91329];
StartProgram;
Var i,j,k: integer;
sum,p,q,Z: double;
Begin
sum:=0 ;
i:= 1;
j:= 1;
k:= 1;
for k := 1 to 5 do
q(k):=0;
Z=0;
for i := 1 to 10 do
for j:=1 to 5 do
sum=F(i,j)*x(j)+sum;
End;
p(i)=exp(-sum);
q(k)=p(i)*F(k,i)+q(k);
Z=Z+exp(-sum);
End;
FunctionResult:= Fr(k)*Z-q(k);
End;
EndProgram; 1stOpt有高手嘛?帮忙看看吧
页:
[1]