用matlab进行线性规划的时候出现问题了 求解决
在进行线性规划的时候出了问题目标函数中只有y但是限制条件中出现了xx与y是有关系的,但是也不能完全用y表示x这样还能用matlab做么...
在进行线性规划的时候出了问题 目标函数中只有y但是限制条件中出现了x x与y是有关系的,但是也不能完全用y表示x 这样还能用matlab做么
展开
展开全部
>> f=[0;0;0;-0.77;-0.63;-0.70;-0.575];
A=[-1 0 0 0 0 0 0
1 0 0 0 0 0 0
0 -1 -1 0 0 0 0
0 1 1 0 0 0 0
0.2 0.85 1 0 0 0 0
0 0 0 7.5 6.1 9.0 7.35
0 0 0 1.4 0 1.65 0];
b=[0;8.2;0;3.5;9;96.5;7.5];
Aeq=[1 1 0 -1 -1 0 0
1 0 -1 0 0 1 1];
beq=[-2.5;8.2];
[x,fval,exitflag,output] = linprog(f,A,b,Aeq,beq)
Exiting: One or more of the residuals, duality gap, or total relative error
has stalled:
the dual appears to be infeasible (and the primal unbounded).
(The primal residual < TolFun=1.00e-008.)
x =
1.0e+021 *
0.0000
4.9454
-4.9454
4.9454
-0.0000
-4.1961
-0.7493
fval =
-4.3984e+020
exitflag =
-3
output =
iterations: 19
algorithm: 'large-scale: interior point'
cgiterations: 0
message: [1x217 char]
constrviolation: 9.1668e+005
firstorderopt: 8.7498e+019
应该还加个x,y>0
否则解有点问题
代码如下
>> f=[0;0;0;-0.77;-0.63;-0.70;-0.575];
A=[-1 0 0 0 0 0 0
1 0 0 0 0 0 0
0 -1 -1 0 0 0 0
0 1 1 0 0 0 0
0.2 0.85 1 0 0 0 0
0 0 0 7.5 6.1 9.0 7.35
0 0 0 1.4 0 1.65 0];
b=[0;8.2;0;3.5;9;96.5;7.5];
Aeq=[1 1 0 -1 -1 0 0
1 0 -1 0 0 1 1];
beq=[2.5;8.2];
lb=zeros(7,1);
[x,fval,exitflag,output] = linprog(f,A,b,Aeq,beq,lb)
Optimization terminated.
x =
8.2000
3.5000
0.0000
5.3571
8.8429
0.0000
0.0000
fval =
-9.6960
exitflag =
1
output =
iterations: 8
algorithm: 'large-scale: interior point'
cgiterations: 0
message: 'Optimization terminated.'
constrviolation: 4.4409e-014
firstorderopt: 1.2641e-009
max w+2=9.6960
w=7.6960
A=[-1 0 0 0 0 0 0
1 0 0 0 0 0 0
0 -1 -1 0 0 0 0
0 1 1 0 0 0 0
0.2 0.85 1 0 0 0 0
0 0 0 7.5 6.1 9.0 7.35
0 0 0 1.4 0 1.65 0];
b=[0;8.2;0;3.5;9;96.5;7.5];
Aeq=[1 1 0 -1 -1 0 0
1 0 -1 0 0 1 1];
beq=[-2.5;8.2];
[x,fval,exitflag,output] = linprog(f,A,b,Aeq,beq)
Exiting: One or more of the residuals, duality gap, or total relative error
has stalled:
the dual appears to be infeasible (and the primal unbounded).
(The primal residual < TolFun=1.00e-008.)
x =
1.0e+021 *
0.0000
4.9454
-4.9454
4.9454
-0.0000
-4.1961
-0.7493
fval =
-4.3984e+020
exitflag =
-3
output =
iterations: 19
algorithm: 'large-scale: interior point'
cgiterations: 0
message: [1x217 char]
constrviolation: 9.1668e+005
firstorderopt: 8.7498e+019
应该还加个x,y>0
否则解有点问题
代码如下
>> f=[0;0;0;-0.77;-0.63;-0.70;-0.575];
A=[-1 0 0 0 0 0 0
1 0 0 0 0 0 0
0 -1 -1 0 0 0 0
0 1 1 0 0 0 0
0.2 0.85 1 0 0 0 0
0 0 0 7.5 6.1 9.0 7.35
0 0 0 1.4 0 1.65 0];
b=[0;8.2;0;3.5;9;96.5;7.5];
Aeq=[1 1 0 -1 -1 0 0
1 0 -1 0 0 1 1];
beq=[2.5;8.2];
lb=zeros(7,1);
[x,fval,exitflag,output] = linprog(f,A,b,Aeq,beq,lb)
Optimization terminated.
x =
8.2000
3.5000
0.0000
5.3571
8.8429
0.0000
0.0000
fval =
-9.6960
exitflag =
1
output =
iterations: 8
algorithm: 'large-scale: interior point'
cgiterations: 0
message: 'Optimization terminated.'
constrviolation: 4.4409e-014
firstorderopt: 1.2641e-009
max w+2=9.6960
w=7.6960
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
f=[0;0;0;-0.77;-0.63;-0.70;-0.575];
Aeq=[1 1 0 -1 -1 0 0;-1 0 1 0 0 -1 -1];
Beq=[-2.5;-8.2];
A=[0 1 1 0 0 0 0;
0 -1 -1 0 0 0 0;
0.2 0.85 1 0 0 0 0;
0 0 0 7.5 6.1 9.0 7.35;
0 0 0 1.4 0 1.65 0];
B=[3.5;0;9;96.5;7.5];
lb=[0;0;0;0;0;0;0];%下限都应该大于零吧?
ub=[8.2;inf ;inf; inf ;inf;inf;inf];
[x,fval,exitflag]=linprog(f,A,B,Aeq,Beq,lb,ub)
Max=-fval-2
zd0412_1
Optimization terminated.
x =
8.2000
3.5000
0.0000
5.3571
8.8429
0.0000
0.0000
fval =
-9.6960
exitflag =
1
Max =
7.6960
>>
Aeq=[1 1 0 -1 -1 0 0;-1 0 1 0 0 -1 -1];
Beq=[-2.5;-8.2];
A=[0 1 1 0 0 0 0;
0 -1 -1 0 0 0 0;
0.2 0.85 1 0 0 0 0;
0 0 0 7.5 6.1 9.0 7.35;
0 0 0 1.4 0 1.65 0];
B=[3.5;0;9;96.5;7.5];
lb=[0;0;0;0;0;0;0];%下限都应该大于零吧?
ub=[8.2;inf ;inf; inf ;inf;inf;inf];
[x,fval,exitflag]=linprog(f,A,B,Aeq,Beq,lb,ub)
Max=-fval-2
zd0412_1
Optimization terminated.
x =
8.2000
3.5000
0.0000
5.3571
8.8429
0.0000
0.0000
fval =
-9.6960
exitflag =
1
Max =
7.6960
>>
追问
恩恩 是的 少了个负号 不过后来私下聊过了的
也谢谢您的热心帮助哈
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询