1. 首页
  2. 人工智能
  3. 论文/代码
  4. MATLAB多目标规划fgoalattain代码下载

MATLAB多目标规划fgoalattain代码下载

上传者: 2023-08-31 15:23:28上传 ZIP文件 14.05KB 热度 20次

这里提供MATLAB多目标规划fgoalattain代码的下载。该代码包含两个目标函数和约束函数,并给出了程序运行结果。运行过程中可能会出现Solver stopped prematurely的提示,这是因为超过了函数评估的限制。具体代码如下:

% myfun.m
function [f] = myfun(x)
    f(1) = cos(x(1)) + x(2)^2 + x(3);
    f(2) = x(2)/x(3);

% mycon.m
function [c, ceq] = mycon(x)
    c = x(1)^2 - x(2);
    ceq = [];

% 主程序
options = optimoptions('fgoalattain','MaxFunctionEvaluations',400);
x0 = [0;0;0];
[x, fval, exitflag] = fgoalattain(@myfun, x0, [], @mycon,[],[],[],[],[],options);

程序运行结果如下:

Solver stopped prematurely. fgoalattain stopped because it exceeded the function evaluation limit, options.MaxFunctionEvaluations = 400 (the default value).
x = 0.0123764041883559 6.60270284335016e-05 6.60195797535719e-05
fval = 0.999989437226613 1.00011282531572
exitflag = 0 >>
下载地址
用户评论