用NSGA-II 做简单多目标优化实例,出现—输入参数的数目不足—。
조회 수: 11 (최근 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!