如何在MATLAB中使用优化工具箱

时间:2016-02-06 22:01:37

标签: matlab

当我尝试使用MATLAB R2014a的优化函数时出错。错误消息是:

  

未定义函数'gaoptimset'用于'cell'类型的输入参数

有谁能告诉我如何解决这个问题?非常感谢!

1 个答案:

答案 0 :(得分:0)

请更彻底地研究documentation。我敢说你把一些值放在大括号中,因为它们在文档中用大括号括起来。但是,Matlab明确指出:

  

{}中的值表示默认值

所以,首先你需要删除它们。然后,您需要删除参数中的tournamentSize0.10.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');

希望有所帮助