%程序如下:
tic; %begin time
c=[];
A=[];
b=[];
Aeq=[1 1];
beq=[10];
vlb=[0 0];
vub=[7 6];
[x,fval]=linprog(c,A,b,Aeq,beq,vlb,vub)
time=toc %end time
说白了也就是x1+x2=10;
0<=x1<=7;
0<=x2<=6;
但是为什么每次只返回 x1=5.25, x2=4.75 这一个解呢,这个解不应该是有无数个,然后每次返回的解都不一样的吗。求救!!!!!

 Réponse acceptée

0 votes

改改算法,可以得到[4 6]
options = optimoptions('linprog','Algorithm','interior-point');
[x,fval]=linprog(c,A,b,Aeq,beq,vlb,vub,options)
算法使用的是默认的初值,一般不能改变。

Plus de réponses (0)

Catégories

En savoir plus sur 编程 dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!