24小时热门版块排行榜    

查看: 2415  |  回复: 7
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

free0121

木虫 (著名写手)

[求助] 关于全局最优法和遗传算法 已有2人参与

大家好,最近尝试了一下遗传算法,初始种群是系统随机抽取的,以致于每次算出来的结果都不太一样。本来想说通过遗传算法得到接近全局最优的解,结果这些解好像都是局部最优。于是尝试了一个全局最优的算法,先做了个小实验,但不成功。希望大侠们帮忙看看问题出在哪里了,不胜感激!
对于遗传算法很熟悉的朋友,也向大家请教一下在使用遗传算法时当注意什么问题,怎么使得到的解能比较接近全局最优。谢谢!

function main
    clear all
    close all
    clc

    A=[];b=[];
    Aeq=[];beq=[];
    lb=[0.2;0.1];
    ub=[4.0;1.6];
    x0=[2.5;1.0];
      
    opts1 = optimset('Algorithm','interior-point');
    opts2 = optimset('Algorithm','sqp');
    opts3 = optimset('Algorithm','trust-region-reflective');
    opts4 = optimset('Algorithm','active-set');
   
    problem1 = createOptimProblem('fmincon','objective',...
         @objfun,'x0',x0, 'Aineq', A, 'bineq', b, 'nonlcon', @mycon, 'options',opts1);
    problem2 = createOptimProblem('fmincon','objective',...
         @objfun,'x0',x0, 'Aineq', A, 'bineq', b, 'nonlcon', @mycon, 'options',opts2);
    problem3 = createOptimProblem('fmincon','objective',...
         @objfun,'x0',x0, 'Aineq', A, 'bineq', b, 'nonlcon', @mycon, 'options',opts3);
    problem4 = createOptimProblem('fmincon','objective',...
         @objfun,'x0',x0, 'Aineq', A, 'bineq', b, 'nonlcon', @mycon, 'options',opts4);
    gs = GlobalSearch;
    [x1,fval1] = run(gs,problem1);
    [x2,fval2] = run(gs,problem2);
    [x3,fval3] = run(gs,problem3);
    [x4,fval4] = run(gs,problem4);
end

% objective function
function f0=objfun(x)
f0=x(1)*sqrt(1.0+x(2)^2);
end

% constraint function
function [f,ceq]=mycon(x)
f=(0.124*(8.0/x(1)+1.0/(x(1)*x(2)))*sqrt(1.0+x(2)^2))-1.0;
ceq=[];
end

运行后得到

GlobalSearch stopped because it analyzed all the trial points.
1 out of 39 local solver runs converged with a positive local solver exit flag.
No solution found.

GlobalSearch did not find any solutions after 399 local solver runs.
Warning: The default trust-region-reflective algorithm does not solve problems
with the constraints you have specified. FMINCON will use the active-set
algorithm instead. For information on applicable algorithms, see Choosing the
Algorithm in the documentation.
> In fmincon at 486
  In C:\Program Files\MATLAB\R2011b\toolbox\globaloptim\globaloptim\private\globalsearchnlp.p>globalsearchnlp at 152
  In GlobalSearch>GlobalSearch.run at 330
  
GlobalSearch stopped with one or more of the local solver runs stopping prematurely.

15 out of 39 local solver runs exceeded the iteration limit (problem.options.MaxIter) or
the function evaluation limit (problem.options.MaxFunEvals).
None of the 39 local solver runs converged with a positive local solver exit flag.

GlobalSearch stopped with one or more of the local solver runs stopping prematurely.

13 out of 36 local solver runs exceeded the iteration limit (problem.options.MaxIter) or
the function evaluation limit (problem.options.MaxFunEvals).
None of the 36 local solver runs converged with a positive local solver exit flag.

这是为什么呢?
回复此楼

» 收录本帖的淘帖专辑推荐

计算机应用

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

冷烨000

新虫 (初入文坛)

引用回帖:
2楼: Originally posted by free0121 at 2014-01-20 21:46:47
哦,自己發現問題所在了~~

你好,我想问下,你这个是全局最优的程序吗?你能给我解释下这个程序的意思吗。我现在也在用遗传算法,进行系统结构和参数识别,但是我根据已知的样本数据得到的结果很不理想,而且参数的取值范围是未知的,这种情况下,怎么尝试设置参数的范围?
回首向来萧瑟处,归去,也无风雨也无晴
8楼2014-04-25 19:01:03
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 8 个回答

free0121

木虫 (著名写手)

哦,自己發現問題所在了~~
2楼2014-01-20 21:46:47
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

张天天__

铁虫 (初入文坛)

【答案】应助回帖

★ ★ ★ ★ ★ ★ ★ ★ ★ ★
感谢参与,应助指数 +1
free0121: 金币+10, ★★★很有帮助, 谢谢! 2014-02-04 03:43:20
我也是研究不久,遗传算法使用时应当在基本遗传算法的基础上附加一些避免算法早熟、不收敛的策略,进化过程中既要保持种群多样度,避免收敛于局部最优,又得保证每次迭代得到的优个体得到保存从而使得算法收敛。。。。总儿言之就是既要收敛又不能过早收敛,既要成熟由不要早熟。。。
3楼2014-01-20 21:50:37
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

张天天__

铁虫 (初入文坛)

引用回帖:
2楼: Originally posted by free0121 at 2014-01-20 21:46:47
哦,自己發現問題所在了~~

你怎样保证得到全局最优
4楼2014-01-20 21:54:56
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
信息提示
请填处理意见