| 查看: 1599 | 回复: 0 | |||
zongshengl木虫 (小有名气)
|
[求助]
遗传算法整数规划中变量取整的设置
|
|
本人在用遗传算法求解非线性整数规划问题,关于变量整数的约束前面看到一个有关的帖子,我发现中间有错误(红色部分),但是不知道怎么修改,请指点。 源程序如下: function [x,fval] = gainteger_demo % Fitness function and numver of variables fitnessFcn = @(x) norm(x); numberOfVariables = 15; % If decision variables are bounded provide a bound e.g, LB and UB. LB = -5*ones(1,numberOfVariables); UB = 5*ones(1,numberOfVariables); Bound = [LB;UB]; % If unbounded then Bound = [] % Create an options structure to be passed to GA % Three options namely 'CreationFcn', 'MutationFcn', and % 'PopInitRange' are required part of the problem. options = gaoptimset('CreationFcn',@int_pop,'MutationFcn',@int_mutation, ... 'PopInitRange',Bound,'Display','iter','StallGenL',40,'Generations',150, ... 'PopulationSize',60,'PlotFcns',{@gaplotbestf,@gaplotbestindiv}); [x,fval] = ga(fitnessFcn,numberOfVariables,options); %--------------------------------------------------- % Mutation function to generate childrens satisfying the range and integer % constraints on decision variables. function mutationChildren = int_mutation(parents,options,GenomeLength, ... FitnessFcn,state,thisScore,thisPopulation) shrink = .01; scale = 1; scale = scale - shrink * scale * state.Generation/options.Generations; range = options.PopInitRange; lower = range(1, ;upper = range(2, ;scale = scale * (upper - lower); mutationPop = length(parents); % The use of ROUND function will make sure that childrens are integers. mutationChildren = repmat(lower,mutationPop,1) + ... round(repmat(scale,mutationPop,1) .* rand(mutationPop,GenomeLength)); % End of mutation function %--------------------------------------------------- function Population = int_pop(GenomeLength,FitnessFcn,options) totalpopulation = sum(options.PopulationSize); range = options.PopInitRange; lower= range(1, ;span = range(2, - lower;% The use of ROUND function will make sure that individuals are integers. Population = repmat(lower,totalpopulation,1) + ... round(repmat(span,totalpopulation,1) .* rand(totalpopulation,GenomeLength)); % End of creation function |
» 猜你喜欢
全日制(定向)博士
已经有5人回复
假如你的研究生提出不合理要求
已经有10人回复
萌生出自己或许不适合搞科研的想法,现在跑or等等看?
已经有4人回复
Materials Today Chemistry审稿周期
已经有4人回复
参与限项
已经有3人回复
实验室接单子
已经有4人回复
对氯苯硼酸纯化
已经有3人回复
求助:我三月中下旬出站,青基依托单位怎么办?
已经有12人回复
所感
已经有4人回复
要不要辞职读博?
已经有7人回复

找到一些相关的精华帖子,希望有用哦~
结构优化参数设置
已经有6人回复
遗传算法 GA
已经有6人回复
matlab最小二乘问题求助 怎么定义多变量
已经有3人回复
一个关于matlab的遗传算法的问题
已经有3人回复
反向遗传资料求助
已经有3人回复
做过木霉菌和除草剂的请帮忙解答一下,除草剂的浓度梯度怎么设置
已经有4人回复
【分享】火狐高手设置大揭密【已搜索无重复】
已经有3人回复
新材料十二五规划哪里能下载
已经有3人回复
求助伴性遗传的一道问题
已经有3人回复
【讨论】中国式管理境界:规划管理
已经有3人回复
【求助】遗传算法求解eil51.tsp问题,离最优解还很远。怎么办?
已经有26人回复
【求助】有关固定设计变量的一个疑问
已经有3人回复
【求助】遗传算法
已经有3人回复
使用NTSYSpc计算遗传相似系数的方法步骤(中文表述)
已经有4人回复
【求助】遗传算法中 intensification和diversification 两个词怎么翻译?
已经有4人回复
科研从小木虫开始,人人为我,我为人人












;
回复此楼
点击这里搜索更多相关资源