24小时热门版块排行榜    

北京石油化工学院2026年研究生招生接收调剂公告
查看: 2503  |  回复: 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的回帖
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 工科求调剂 +15 11ggg 2026-04-03 15/750 2026-04-05 16:24 by zzx2138
[考研] 电子信息调剂交叉学科有推荐吗 +6 jhtfeybgj 2026-04-01 9/450 2026-04-05 11:13 by 猪会飞
[考研] 求调剂 +3 小沢 2026-04-03 3/150 2026-04-05 09:10 by sihailian3
[考研] 083200 333求调剂 +3 十二!! 2026-04-04 3/150 2026-04-05 08:28 by barlinike
[考研] 302分求调剂 一志愿安徽大学085601 +5 zyx上岸! 2026-04-04 5/250 2026-04-05 07:50 by 544594351
[考研] 286求调剂 +3 草木不言 2026-04-04 3/150 2026-04-04 22:40 by lbsjt
[考研] 341求调剂 +3 洛多罗 2026-04-02 4/200 2026-04-04 21:36 by 智能智慧
[考研] 求调剂 +4 压力??大 2026-04-03 4/200 2026-04-03 21:36 by 啵啵啵0119
[考研] 327求调剂 +9 小卡不卡. 2026-03-29 9/450 2026-04-03 19:48 by 百灵童888
[考研] 生物学硕341求调剂 +4 你笑起来像云朵 2026-04-03 4/200 2026-04-03 10:32 by macy2011
[考研] 326求调剂 +3 9ahye 2026-04-02 4/200 2026-04-03 08:43 by Jaylen.
[考研] 一志愿北京科技大学085601材料工程英一数二初试总分335求调剂 +8 双马尾痞老板2 2026-04-02 9/450 2026-04-02 14:45 by 5896
[考研] 08工科求调剂290分 +5 1314捧花 2026-04-02 8/400 2026-04-02 13:16 by 乔哒哒哒
[考研] 材料工程322分 +8 哈哈哈吼吼吼哈 2026-04-01 8/400 2026-04-02 11:53 by 3041
[考研] 材料调剂 +12 一样YWY 2026-04-01 12/600 2026-04-02 00:21 by 百秒光年
[考研] 296求调剂 +4 汪!?! 2026-03-31 7/350 2026-04-01 22:04 by 客尔美德
[考研] 生物与医药考研调剂 +5 铁憨憨123425 2026-03-31 5/250 2026-04-01 18:01 by syh9288
[考研] 288资源与环境专硕求调剂,不限专业,有学上就行 +25 lllllos 2026-03-30 26/1300 2026-04-01 09:52 by 一只好果子?
[考研] 313求调剂 +6 卖个关子吧 2026-03-31 6/300 2026-03-31 10:58 by Jaylen.
[考研] 本科211总分289,08工学真心求调剂 +3 utopiaE 2026-03-30 3/150 2026-03-30 23:42 by ms629
信息提示
请填处理意见