用NSGA-II 做简单多目标优化实例,出现—输入参数的数目不足—。
23 ビュー (過去 30 日間)
古いコメントを表示
真人百家家乐app下载【gb2032 .com】
2022 年 10 月 14 日
回答済み: 真人百家家乐网址【359663.tv】
2022 年 10 月 14 日
小白,用NSGA-II 做简单多目标优化实例。在网上找了个例子(附图),一步一步来。出现 (输入参数的数目不足)问题?请大佬帮忙解答下,感谢。网上例子用R2009a,windows7,我用R2016a,windows7。
function [ y1,y2 ] =my_target( a,b )
%UNTITLED 此处显示有关此函数的摘要
% 此处显示详细说明
y1=a^4-10.*(a^2)+a.*b+b^4-(a^2).*(b^2)
y2=b^4-(a^2).*(b^2)+a^4+a.*b;
主程序
clear
clc
fitnessfcn = @my_target; % Function handle to the fitness funct ion
nvars = 2; % Number of decision variables
lb = [-5,-5]; % Lower bound
ub = [5, 5];
A= []; b= []; % No linear inequality constraints
Aeq= []; beq= []; % No linear equality constraints
options = gaoptimset ('ParetoFraction',0.3,'PopulationSize ',100,'Generations',200,'StallGenLimit',200,'TolFun',le-100,'PlotFcns',@gaplotpareto);
[x, fval]=gamultiobj(fitnessfcn,nvars, A, b, Aeq, beq, lb, ub, options);
出现问题的语句——
options = gaoptimset ('ParetoFraction',0.3,'PopulationSize ',100,'Generations',200,'StallGenLimit',200,'TolFun',le-100,'PlotFcns',@gaplotpareto);
—出现错误,提示输入参数的数目不足。
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1156163/image.png)
0 件のコメント
採用された回答
真人百家家乐网址【359663.tv】
2022 年 10 月 14 日
改成
clear;clc;close all;
nvars = 2; % Number of decision variables
lb = [-5,-5]; % Lower bound
ub = [5, 5];
A= []; b= []; % No linear inequality constraints
Aeq= []; beq= []; % No linear equality constraints
my_target = @(x) [x(1).^4 - 10.*x(1).^2 + x(1).*x(2) + x(2).^4 - x(1).^2.*x(2).^2;
x(2).^4 - x(1).^2.*x(2).^2 + x(1).^4 + x(1).*x(2)];
options = optimoptions('gamultiobj','ParetoFraction',0.3,...
'PopulationSize',100,'Generations',200,'StallGenLimit',200,...
'TolFun',1e-100,'PlotFcn',@gaplotpareto);
[x, fval] = gamultiobj(my_target, nvars, A, b, Aeq, beq, lb, ub, options );
'PopulationSize ',100,
你的代码这里PopulationSize后面多了一个空格,导致无法识别参数
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で 基于问题的优化设置 についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!