发布网友 发布时间:2022-04-24 04:29
共1个回答
热心网友 时间:2023-10-28 03:59
f = @(x) sum(x); % 目标函数
A=[-6,-4,-4,-2,-1,-1,0;0,-1,0,-2,-1,0,-1;0,0,-1,0,-1,-2,0]; % 线性约束
B = [-100,-100,-100];
lb=zeros(1,7); % 下限为0
ub=inf*ones(1,7); % 上限为无穷大
op = optimset('Algorithm','interior-point'); % 约束算法
x0 = 10*ones(1,7); % 假设初始值为每个变量都是10
[x,fval] = fmincon(f,x0,A,B,[],[],lb,ub,[],op) % 约束极值
Local minimum found that satisfies the constraints.
Optimization completed because the objective function is non-decreasing in
feasible directions, to within the default value of the function tolerance,
and constraints were satisfied to within the default value of the constraint tolerance.
<stopping criteria details>
x =
0.0000 0.0000 0.0000 33.3211 33.3579 33.3211 0.0000
fval =
100.0000
热心网友 时间:2023-10-28 03:59
f = @(x) sum(x); % 目标函数
A=[-6,-4,-4,-2,-1,-1,0;0,-1,0,-2,-1,0,-1;0,0,-1,0,-1,-2,0]; % 线性约束
B = [-100,-100,-100];
lb=zeros(1,7); % 下限为0
ub=inf*ones(1,7); % 上限为无穷大
op = optimset('Algorithm','interior-point'); % 约束算法
x0 = 10*ones(1,7); % 假设初始值为每个变量都是10
[x,fval] = fmincon(f,x0,A,B,[],[],lb,ub,[],op) % 约束极值
Local minimum found that satisfies the constraints.
Optimization completed because the objective function is non-decreasing in
feasible directions, to within the default value of the function tolerance,
and constraints were satisfied to within the default value of the constraint tolerance.
<stopping criteria details>
x =
0.0000 0.0000 0.0000 33.3211 33.3579 33.3211 0.0000
fval =
100.0000
热心网友 时间:2023-10-28 03:59
f = @(x) sum(x); % 目标函数
A=[-6,-4,-4,-2,-1,-1,0;0,-1,0,-2,-1,0,-1;0,0,-1,0,-1,-2,0]; % 线性约束
B = [-100,-100,-100];
lb=zeros(1,7); % 下限为0
ub=inf*ones(1,7); % 上限为无穷大
op = optimset('Algorithm','interior-point'); % 约束算法
x0 = 10*ones(1,7); % 假设初始值为每个变量都是10
[x,fval] = fmincon(f,x0,A,B,[],[],lb,ub,[],op) % 约束极值
Local minimum found that satisfies the constraints.
Optimization completed because the objective function is non-decreasing in
feasible directions, to within the default value of the function tolerance,
and constraints were satisfied to within the default value of the constraint tolerance.
<stopping criteria details>
x =
0.0000 0.0000 0.0000 33.3211 33.3579 33.3211 0.0000
fval =
100.0000