matlab程序如下:
c=[-0.4 -0.28 -0.32 -0.72 -0.64 -0.6];
A=[0.01 0.01 0.01 0.03 0.03 0.03;0.02 0 0 0.05 0 0;0 0.02 0 0 0.05 0;0 0 0.03 0 0 0.08];
b=[850;700;100;900];
Aeq=[]; beq=[];
vlb=[0;0;0;0;0;0]; vub=[];
[x,fval]=linprog(c,A,b,Aeq,beq,vlb,vub)
R程序如下:
c<-c(-0.4, -0.28, -0.32, -0.72, -0.64, -0.6);
A<-matrix(c(0.01, 0.01 ,0.01 ,0.03, 0.03, 0.03,0.02 ,0 ,0, 0.05, 0, 0,
0, 0.02, 0, 0, 0.05, 0, 0, 0, 0.03, 0, 0, 0.08
),nrow = 4,byrow="F");
A1<- matrix(c(1,0,0,0,0,0,
0,1,0,0,0,0,
0,0,1,0,0,0,
0,0,0,1,0,0,
0,0,0,0,1,0,
0,0,0,0,0,1),nrow=6,byrow="F") ;
Anew=rbind(A,A1);
library(lpSolve);
eg.lp<-lp(direction="max",objective.in=c,const.mat=Anew,const.rhs=b,const.dir=c(rep("<=",4),rep(">=",6)));
eg.lp$solution
|