.
3、在问题三方面我们对每一种DVD都满足95%的会员的观看,这样既能满足题目要求使DVD的总数要达到满足95%的会员的观看,又能使满足度达到最大;
附件一: model: sets:
dvd/1..100/:total;!total为网站现有
DVDj的数量;
huiyuan/1..1000/; !自定义0-1向量; pianai(huiyuan,dvd):data0; bianliang(huiyuan,dvd):data1;
Endsets
!目标函数(总体满意度最大);
max=@sum(pianai(i,j):data1(i,j)*data0(i,j));
! x (i,j) ,t (i)为0-1变量; @for(bianliang:@bin(data1)); ! 约束条件每人可租DVD数Yi=3或0;
@for(huiyuan(j):@sum(bianliang(j,i):data1(j,i))<=3); ! 所租
DVDj总数小于网站现有
DVDj的数量;
@for(dvd(i):@sum(bianliang(i,j):data1(i,j))<=total(i));
data:
total=10 40 15 20 20 12 30 33 35 25 29 31 28 61 2 28 28 26 31 38 34 29 35 22 29 81 1 19 25 41 29 35 1 40 39 5 106 30 29 2 110 6 15 36 34 11 32 25 2 64 40 26 33 26 61 2 11 38 44 36 27 31 42 44 12 81 10 35 33 30 2 40 15 11 28 24 20 88 9 28 31 8 22 3 70 21 34 4 38 27 39 28 24 15 50 24 36 55 2 40 ; ! 网站现有
DVDj的数量;
data0=
6 0 0 0 0 0 8 1 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
.
.
0 7 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 9 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0
0 0 0 0 5 1 0 0 0 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 7 0 0 0 3 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 0 0 ...... ......
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ;
enddata end
.
0 0 0 0 0 0 2 0 0 0 4 3 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 5 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 9 0 0 0 0 0 0 0 0
0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 9 8 0 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 0 0 3 0 0 0 0 0 0 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 7 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 8 0 1 0 0 0 0 0 0 0 0 6 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 7 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 7 0 0 1 0 0 0 0 10 0 0 0 0 0 0 0 6 3 0 0 0 0 0 0 0 0 8 0 10 0 0 0 0 0 0 0 0 0 5 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 0 0 .
附录二: #include
int x[1000][100]={6,0 ,0 ,0 ,0 ,0 , 8 ,1 ,0 ,0 ,4 ,0 ,0 ,0 ,0 ,0................}; //输入每位会员的的在线订单 int maxB,i,j,c[1000][100],b[100],k=0,y=0,n[100]={0}; for(i=0;i<1000;i++){ for(j=0;j<100;i++){ if(x[i][j]==0) c[i][j]=0;
else c[i][j]=1/x[i][j];}
//得出偏爱度,当1/x[i][j]不为0时;c[i][j]=1/x[i][j];当当1/x[i][j]为0时c[i][j]=0; }
//进行0—1规划; for(i=0;i<1000;i++){
for(j=0;j<100;i++){ if(x[i][j]==0) x[i][j]=0;
else if(x[i][j]<=3) x[i][j]=1; else x[i][j]=0;} }
//求出需要第j种DVD的人数 for(j=0;j<100;i++ ){
for(i=0;i<1000;i++){ n[j]=n[j]+x[i][j]; } }
//得出第j种DVD需采购数量 for(j=0;j<100;i++){ b[j]=0.7*0.95*n[j]; }
//再次进行0-1规划 for(j=0;j<100;i++){
for(i=0;i<1000;i++){ if(k
k=k+x[i][j];} else
x[i][j]=0;
} }
.
.
for(i=0;i<1000;i++){ for(j=0;j<100;i++){ if(y!=3)
y=y+x[i][j]; else
x[i][j]=0;} }
//输出需要购买j种DVD的数量,并且求出满意度。 for(j=0;j<100;i++){ printf(\ for(i=0;i<1000;i++){
maxB=maxB+c[i][j]*x[i][j]; } }
//输出满意度
printf(\ return 0; }
附录三: model: sets:
dvd/1..100/:total;!total为网站现有
DVDj的数量;
huiyuan/1..1000/; !自定义0-1向量; pianai(huiyuan,dvd):data0; bianliang(huiyuan,dvd):data1;
Endsets
!目标函数(总体满意度最大);
max=@sum(pianai(i,j):data1(i,j)*data0(i,j));
! x (i,j) ,t (i)为0-1变量; @for(bianliang:@bin(data1)); ! 约束条件每人可租DVD数Yi=3或0;
@for(huiyuan(j):@sum(bianliang(j,i):data1(j,i))<=3); ! 所租
DVDj总数小于网站现有
DVDj的数量;
@for(dvd(i):@sum(bianliang(i,j):data1(i,j))<=total(i));
.