24小时热门版块排行榜    

查看: 2747  |  回复: 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

新虫 (初入文坛)

引用回帖:
6楼: Originally posted by free0121 at 2014-02-04 03:42:36
是的,所谓全局最优也无法找到最优解,但是它可以搜索到很多局部最优解,然后从这些局部最优解中找出最优的解。这个方法不适合计算量大的问题。3楼说的遗传算法要注意的问题确实是那样,弄不好得到的解会很糟糕。

你好,我想问下全局最优用算法怎么实现啊?
回首向来萧瑟处,归去,也无风雨也无晴
7楼2014-04-25 18:57:51
已阅   回复此楼   关注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的回帖
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[基金申请] 建议基金发布提前给出明确的时间点 +7 kulium 2026-08-21 8/400 2026-08-21 18:38 by 陈晨晨陈啊
[基金申请] 看来今天不会放榜了? +8 chengyan1220 2026-08-21 11/550 2026-08-21 17:52 by dcqxinyang
[基金申请] 时间戳又变了 +13 wuchongjun 2026-08-20 19/950 2026-08-21 17:21 by 紫杉醇
[基金申请] 人气不行了 +7 fansofjerry 2026-08-21 7/350 2026-08-21 14:13 by Vivilian
[基金申请] 感觉是下周放榜了 +7 angus9576 2026-08-17 12/600 2026-08-21 13:38 by weiyin
[基金申请] 什么时候开奖? +7 CrisMessi 2026-08-18 7/350 2026-08-21 12:15 by weiyin
[基金申请] 时间戳又变了8-15 +15 archvillain 2026-08-15 27/1350 2026-08-21 11:32 by tim76
[论文投稿] 投稿咨询 +5 wwm09 2026-08-17 7/350 2026-08-21 10:11 by 期刊论文帮手
[基金申请] 今天放榜没戏了吧 +9 yuleib84 2026-08-19 11/550 2026-08-21 10:06 by gltch
[基金申请] 基金啊基金 +4 longfie172 2026-08-20 4/200 2026-08-21 08:58 by mark mao
[基金申请] 放榜前的不淡定 40+4 snowwithsea 2026-08-19 13/650 2026-08-21 08:30 by 北京莱茵编辑
[基金申请] 时间戳今天,20号变了 +4 archvillain 2026-08-20 4/200 2026-08-21 08:10 by gatelove
[基金申请] 重要消息,中午系统在维护 +11 yuleib84 2026-08-18 12/600 2026-08-20 11:09 by xskun
[教师之家] 为什么余额宝的年化利率越来越低?主要原因有哪些? +5 瞬息宇宙 2026-08-15 5/250 2026-08-19 20:23 by super2002521
[基金申请] 今天放榜吗? +14 布布和一二 2026-08-19 15/750 2026-08-19 18:07 by gltch
[基金申请] 朋友圈看到的 +6 wangzilk 2026-08-18 8/400 2026-08-19 10:55 by Haru815
[基金申请] 快农历七夕节了,轻松一下,男人悄悄话,女施主请不要进来。 +6 Tide man 2026-08-14 7/350 2026-08-19 09:56 by ZJTJZ
[基金申请] 明天放榜? +5 Shxjjxjkx 2026-08-18 5/250 2026-08-18 18:14 by -大大大大大-
[基金申请] 今天维护系统维护 祝所有人 高中 +8 gjjjzhong 2026-08-18 9/450 2026-08-18 13:01 by 家与远方
[基金申请] 93BebMhtakh前后11位开头都是大写 +4 且听虎啸 2026-08-17 5/250 2026-08-18 00:49 by 蔡棒棒菂
信息提示
请填处理意见