MATLAB优化工具箱如何得到每次迭代的目标函数值

 时间:2026-02-12 07:45:28

1、创建output function

%%% 代码

% state.Generation 当前代数

% state.Score 种群的目标函数值

function [state, options,optchanged] = outfun(options,state,flag)

optchanged = false;

switch flag

 case 'init'

        disp('Starting the algorithm');

    case {'iter','interrupt'}

        plot(state.Generation,min(state.Score(:,1)),'.');

        hold on;

        disp('Iterating ...');

        disp(state.Generation);

    case 'done'

        disp('Performing final task');

end

%%%

2、创建options

在optimset中加入'OutputFcn', @outfun

%%% 

options = optimset('OutputFcn', @outfun);

%%%

3、运行程序

[x,fval,flag,output,population] = gamultiobj(@objfun,nvars,...

                                             [],[],[],[],lb,ub,options);

  • Matlab数组输入与加减运算
  • Matlab输出数据如何到excel文件中
  • MathType怎么输入大括号
  • Matlab中如何查看绘制函数曲线各个数据点的坐标
  • 如何在matlab中使用元胞数组?
  • 热门搜索
    江苏信息职业技术学院怎么样 补漆笔效果怎么样 怎么修复硬盘坏道 如果生活不够慷慨 黄海汽车怎么样 如何找回六级准考证号 plc是什么 雅生活 如何切鱼片 小孩半夜哭闹怎么回事