线性规划求解报错:The number of columns in A must be the same as the number of elements of f.

clc;
clear all;
c=[5;6;7;8;8;9;5;7;11;9;12;10];
A=[0.35 0.25 0.85;
0.30 0.35 0.65;
0.25 0.25 0.65;
0.25 0.30 0.55];
b=[3200;2600;3400;3800];
Aeq=[1,0,0,1,0,0,1,0,0,1,0,0;
0,1,0,0,1,0,0,1,0,0,1,0;
0,0,1,0,0,1,0,0,1,0,0,1];
beq=[6000;8000;4000];
[x,fval]=linprog(c,A,b,[],[],zeros(12,1));
fval=-fval;
% error:The number of columns in A must be the same as the number of elements of f.

你的规划模型和你自己敲的代码不一致,你的c有12个变量,但是你的 A 只有c中的3个变量

这是数学模型

img

img