当我尝试使用 MATLAB R2014a 中的优化函数时出现错误。错误消息是:
未定义的函数"gaoptimset",用于类型为"cell"的输入参数
谁能告诉我如何解决问题?非常感谢!
请更彻底地研究文档。我敢猜测您将一些值放入大括号中,因为它们在文档中位于大括号中。但是,Matlab明确指出:
{} 中的值表示默认值
因此,首先您需要删除它们。然后,您需要删除参数中的tournamentSize
、0.1
和0.8
,因为'SelectionFcn'
、'MutationFcn'
和'CrossoverFcn'
后面的值应该只是一个函数句柄。所以,你最终会得到:
options = gaoptimset('CreationFcn', @PopFunction,...
'PopulationSize',50,...
'Generations',100,...
'PopulationType', 'bitstring',...
'SelectionFcn',@selectiontournament,...
'MutationFcn',@mutationuniform,...
'CrossoverFcn', @crossoverarithmetic,...
'EliteCount',2,...
'StallGenLimit',100,...
'PlotFcns',@gaplotbestf,...
'Display', 'iter');
希望有帮助