f=[42*40,42*40, 48*50,50*48, 36*45,36*45, 36*48, 36*45,36*40,36*45,27*40,75* 45,48*48,50*50,... 42*40, 42*40, 48*50, 50*48, 36*45,36*45, 36*48, 36*45, 36*40, 36*45,27*40, 75*45,48 *48,50*50,... 48*48,50*50,36*40,36*45,27*40,75*45,48*48,50*50,48*48,48*48,50*50,48*48,.. 50*50,48*48,48*48,25*50,45*48]; D=[64, 88, 193 ,193, 128 ,120,120, 120, 110, 120 ,64, 247,190 ,210, 70,85,192,195,128.. 120,120, 120, 110, 160, 70,256,190, 210,190,205,110, 160, 70, 256,190,210... 190 ,190,210,200,150 ,150, 180, 70, 120]: M=-0. 9*D;m=0. 9*D; N=0.8*D; A=[N;M;m]; b=[5320;-5320;5600];[x, fval]=bintprog(f,A, b)Optimization terminated.里面的bintprog换成intlinprog再写出代码
时间: 2023-07-23 20:12:49 浏览: 190
好的,根据你的要求,以下是使用intlinprog函数来进行优化的代码:
```matlab
f=[42*40,42*40, 48*50,50*48, 36*45,36*45, 36*48, 36*45,36*40,36*45,27*40,75* 45,48*48,50*50,... 42*40, 42*40, 48*50, 50*48, 36*45,36*45, 36*48, 36*45, 36*40, 36*45,27*40, 75*45,48 *48,50*50,... 48*48,50*50,36*40,36*45,27*40,75*45,48*48,50*50,48*48,48*48,50*50,48*48,.. 50*50,48*48,48*48,25*50,45*48];
D=[64, 88, 193 ,193, 128 ,120,120, 120, 110, 120 ,64, 247,190 ,210, 70,85,192,195,128.. 120,120, 120, 110, 160, 70,256,190, 210,190,205,110, 160, 70, 256,190,210... 190 ,190,210,200,150 ,150, 180, 70, 120];
M=-0.9*D;
m=0.9*D;
N=0.8*D;
A=[N;M;m];
b=[5320;-5320;5600];
% 将bintprog函数替换为intlinprog函数
intcon = 1:length(f);
[x, fval] = intlinprog(f, intcon, A, b);
% 输出结果
disp(x);
disp(fval);
```
需要注意的是,intlinprog函数需要指定整数变量,因此我们将所有的变量都设置为整数变量。在本例中,我们可以将变量的索引作为整数变量,并将它们放在intcon向量中。
阅读全文