Azzera filtri
Azzera filtri

用NSGA-II 做简单多目标优化实例​,出现—输入参数的数​目不足—。

23 visualizzazioni (ultimi 30 giorni)
小白,用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);
—出现错误,提示输入参数的数目不足。

Risposta accettata

真人百家家乐网址【359663.tv】
改成
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后面多了一个空格,导致无法识别参数

Più risposte (0)

Categorie

Scopri di più su 基于问题的优化设置 in Help Center e File Exchange

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!