您现在的位置:华中数学建模网 >> 数学实验 >> 软件学习 >> LINGO/LINDO >> 浏览文章
线性规划教材例题lingo程序实现代码一览表
作者:hzaushumo 日期:2007年04月20日 来源:不详 人气:  我要评论(2)
核心提示:
5.1例1 MODEL:TITLE EX050101;!第5章第一节例1;MAX=5*X1+2*X2;2*X1+X2<=8;X1<=3;X2<=4;END 5.1例2 MODEL:TITLE EX050102;SETS:LIANGKU/1,2/:A;LIANGZHAN/1,2,3/:B;YUNLIANG(LIANGKU,LIANGZHAN):JULI,X;ENDSETSDATA:A= 4 8;B= 2 4 5;JULI = 12 24  8    &

5.1例1

MODEL:
TITLE EX050101;!第5章第一节例1;
MAX=5*X1+2*X2;
2*X1+X2<=8;
X1<=3;
X2<=4;
END

5.1例2

MODEL:
TITLE EX050102;
SETS:
LIANGKU/1,2/:A;
LIANGZHAN/1,2,3/:B;
YUNLIANG(LIANGKU,LIANGZHAN):JULI,X;
ENDSETS
DATA:
A= 4 8;
B= 2 4 5;
JULI = 12 24  8
      30 12 24;

ENDDATA
[OBJ]MIN=@SUM(YUNLIANG:JULI*X);
@FOR(LIANGKU(I):[LK]
     @SUM(LIANGZHAN(J):X(I,J))<=A(I));
@FOR(LIANGZHAN(J):[LZ]
     @SUM(LIANGKU(I):X(I,J))<=B(J));
END

5.2例1

MODEL:
TITLE EX050201;
SETS:
HANG/1..3/:B;
LIE/1,2/:C,X;
XISHU(HANG,LIE):A;
ENDSETS
DATA:
A= 2 1
   1 0
   0 1;
C=5 2;
B=8 3 4;
ENDDATA
[OBJ]MAX=@SUM(LIE:C*X);
@FOR(HANG(I):[YUESHU]
     @SUM(LIE(J):A(I,J)*X(J))<=B(I));
END

5.4例1

MODEL:
TITLE EX050401;
!简单的线性规划只需要修改一下集合段和数据段;
SETS:
HANG/1..2/:B;
LIE/1..3/:C,X;
XISHU(HANG,LIE):A;
ENDSETS
DATA:
A= 1 2 3
   1 3 4;
C=1 3 2;
B=5 7;
ENDDATA
[OBJ]MIN=@SUM(LIE:C*X);
@FOR(HANG(I):[YUESHU]
     @SUM(LIE(J):A(I,J)*X(J))<=B(I));
END

6.2例1

MODEL:
TITLE EX060201;
!简单的线性规划只需要修改一下已有模型的集合段和数据段;
!直接输入为
 min=-5*x1-2*x2;
2*x1+x2+x3=8;
x1+x4=3;(为了避免中止说明语句,这里用的是文本格式的分号,在模型中是作为文本的)
x2+x5=4;
SETS:
HANG/1..3/:B;
LIE/1..5/:C,X;
XISHU(HANG,LIE):A;
ENDSETS
DATA:
A= 2 1 1 0 0 
   1 0 0 1 0
   0 1 0 0 1;
C=-5 -2 0 0 0;
B=8 3 4;
ENDDATA
[OBJ]MIN=@SUM(LIE:C*X);
@FOR(HANG(I):[YUESHU]
     @SUM(LIE(J):A(I,J)*X(J))=B(I));
END

6.2例2

MODEL:
TITLE EX060202;
SETS:
HANG/1..3/:B;
LIE/1..3/:C,X;
XISHU(HANG,LIE):A;
ENDSETS
DATA:
A= 1 0 1
   0 1 1
   1 1 2;
C=2 1 4;
B=2 3 6;
ENDDATA
[OBJ]MAX=@SUM(LIE:C*X);
@FOR(HANG(I):[YUESHU]
     @SUM(LIE(J):A(I,J)*X(J))<=B(I));
END

6.2例3

MODEL:
TITLE EX060203;
SETS:
HANG/1..3/:B;
LIE/1..5/:C,X;
XISHU(HANG,LIE):A;
ENDSETS
DATA:
A= 1 1 2 2 1
   1 2 3 1 2
   1 1 2 3 3 ;
C=1 2 2 1 3;
B=8 9 9 ;
ENDDATA
[OBJ]MIN=@SUM(LIE:C*X);
@FOR(HANG(I):[YUESHU]
     @SUM(LIE(J):A(I,J)*X(J))<=B(I));
END

7.1例1


 MODEL:
TITLE EX070101;
!灵敏度分析要打开选项卡中的开关,增加一个新变量就修改集合LIE,数据A,C,如果增加一个新约束就修改集合HANG,数据B,其它的不变;
SETS:
HANG/1..3/:B;
LIE/1..2/:C,X;
XISHU(HANG,LIE):A;
ENDSETS
DATA:
A= 1 2
   4 0
   0 4;
C=2 3;
B=8 16 12;
ENDDATA
[OBJ]MIN=@SUM(LIE:C*X);
@FOR(HANG(I):[YUESHU]
     @SUM(LIE(J):A(I,J)*X(J))<=B(I));
END
   
7.3例2

MODEL:
TITLE EX070302;
!灵敏度分析要打开选项卡中的开关,增加一个新变量就修改集合LIE,数据A,C,如果增加一个新约束就修改集合HANG,数据B,其它的不变;
SETS:
HANG/1..2/:B;
LIE/1..2/:C,X;
XISHU(HANG,LIE):A;
ENDSETS
DATA:
A= 1 1
   5 9;
C=5 8;
B=6 45;
ENDDATA
[OBJ]MAX=@SUM(LIE:C*X);
@FOR(HANG(I):[YUESHU]
     @SUM(LIE(J):A(I,J)*X(J))<=B(I));
@FOR(LIE:@GIN(X));
END
 

7.3例6

MODEL:
TITLE EX070306;
SETS:
HANG/1..4/:B;
LIE/1..3/:C,X;
XISHU(HANG,LIE):A;
ENDSETS
DATA:
A= 1 2 -1
   1 4  1
   1 1  0
   0 4  1;
C=3 -2 5;
B=2 4 3 6;
ENDDATA
[OBJ]MAX=@SUM(LIE:C*X);
@FOR(HANG(I):[YUESHU]
     @SUM(LIE(J):A(I,J)*X(J))<=B(I));
@FOR(LIE:@BIN(X));
END

 

8.2例1-1

MODEL:
TITLE EX070306;
SETS:
HANG/1..3/:B;
LIE/1..8/:C,X;
XISHU(HANG,LIE):A;
ENDSETS
DATA:
A= 2 1 1 1 0 0 0 0
   0 2 3 0 3 2 1 0
   1 0 1 3 0 2 3 4;
C=0.1 0.3 0.9 0 1.1 0.2 0.8 1.4;
B=100 100 100;
ENDDATA
[OBJ]MIN=@SUM(LIE:C*X);
@FOR(HANG(I):[YUESHU]
     @SUM(LIE(J):A(I,J)*X(J))>=B(I));
@FOR(LIE:@GIN(X));
END

8.2例1-2
     
 MODEL:
TITLE EX070306-2;
SETS:
HANG/1..3/:B;
LIE/1..8/:C,X;
XISHU(HANG,LIE):A;
ENDSETS
DATA:
A= 2 1 1 1 0 0 0 0
   0 2 3 0 3 2 1 0
   1 0 1 3 0 2 3 4;
C=1 1 1 1 1 1 1 1;!采用这个系数是所用的根数最少;
B=100 100 100;
ENDDATA
[OBJ]MIN=@SUM(LIE:C*X);
@FOR(HANG(I):[YUESHU]

 

8.2例1-3

MODEL:
TITLE EX080201-3;
SETS:
HANG/1..3/:B;
LIE/1..5/:C,X;
XISHU(HANG,LIE):A;
ENDSETS
DATA:
A= 2 1  1  0 0
   0 2  0  2 1
   1 0  3  2 3 ;         !去掉3,5,8三种方案后的模型,最优值和书上一样,最优解不一样,可见有多个最优解;
C=0.1 0.3  0  0.2 0.8 ;
B=100 100 100;
ENDDATA
[OBJ]MIN=@SUM(LIE:C*X);

8.2例2

title EX080202;
max=1.15*x4a+1.40*x2c+1.25*x3b+1.06*x5d;
x1a+x1d=100000;
x2a+x2c+x2d=1.06*x1d;
x3a+x3b+x3d=1.15*x1a+1.06*x2d;
x4a+x4d=1.15*x2a+1.06*x3d;
x5d=1.15*x3a+1.06*x4d;
x3b<=40000;
x2c<=30000;!计算后与书上的最优值一样,最优解不一样,那就是有多个最优解;


  

seo培训
上一篇:没有了
下一篇:没有了
相关文章列表
网友评论
关于我们 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助中心