怎么用matlab求解不等式组,求给个例子 5
用matlab求解不等式组,可以用非线性规划优化函数fmincon求解。例如,下列不等式方程组
20x1+76x2+100x3+197x4+12x5+155x6+400x7+50x8+350x9<555
x1+x2+x3+x4+x5+x6+x7+x8+x9=3
0<=x1<=1
0<=x2<=1
0<=x3<=1
0<=x4<=1
0<=x5<=1
0<=x6<=1
0<=x7<=1
0<=x8<=1
0<=x9<=1
其实现方法:
x0=[0,0,0,0,0,0,0,0,0];
A=[];b=[];
Aeq=[1,1,1,1,1,1,1,1,1];beq=[3];
lb=[0,0,0,0,0,0,0,0,0];
ub=[4,4,3,3,5,4,2,6,1];
x=fmincon(@(x)myfunc(x),x0,A,b,Aeq,beq,lb,ub,@(x)myconc(x));
x1=x(1),x2=x(2),x3=x(3),x4=x(4),x5=x(5),x6=x(6),x7=x(7),x8=x(8),x9=x(9)
A=20*x1+76*x2+100*x3+197*x4+12*x5+155*x6+400*x7+50*x8+350*x9
B=x1+x2+x3+x4+x5+x6+x7+x8+x9
运行结果
2024-10-28 广告