数学建模社区-数学中国

标题: 一个最优连线的问题运行不出结果望各位高手帮忙看看 [打印本页]

作者: shumoeven    时间: 2011-8-27 23:41
标题: 一个最优连线的问题运行不出结果望各位高手帮忙看看
本帖最后由 shumoeven 于 2011-8-27 23:42 编辑

这是我按书上一个最优连线问题的源程序改出来的,不知道哪出错了,每次运行就出现错误“unexpected jacobian overflow. contat lindo systems for patch availability(1)."
我编的源程序见下:
MODEL:
     sets:
       stations/1..7/:number;!mumber(i)=the number of station;
       link(stations,stations):
           distance,!The distance matrix;
           x;       !x(i,j)=1 if we use link i,j;
endsets
data:!distance matrix,it need not symmetirc;
   distance= 0  8  5  9 12 14 12
             8  0  9 15 16  8 11
             5  9  0  7  9 11 7
             9 15  7  0  3 17 10
            12 16  9  3  0  8 10
            14  8 11 17  8  0  9
            12 11  7 10 10  9  0;
enddata
n=@size(stations);
min=@sum(link(i,j)|i#ne#j:distance(i,j)*x(i,j));
!there must be an arc out of station 1;
@sum(stations(i)|i#gt#1:x(1,i))>=1;
!for station i,except the base (station 1);
@for(stations(i)|i#gt#1:
!it must be entered;
@sum(station(j)|j#ne#i:x(j,i))=1;
!number(j)=number(i)+1,if we link j and i;
@for(stations(j)|j#gt#1#and#j#ne#i:
   number(j)>=number(i)+x(i,j)
           -(n-2)*(1-x(i,j)+(n-3)*x(j,i);
);
@bnd(1,number(i),999999);
  number(i)<=n-1-(n-2)*x(1,i);
);
@for(linkbin(x));
end




望各位高手帮帮忙哈!谢谢啦!赶紧啊!!
作者: shumoeven    时间: 2011-8-28 01:19
帮帮忙啊。。。
作者: 丶界    时间: 2011-8-31 16:22
MODEL:
    sets:
      cities/1..7/:level; !level(i)= the level of city;
      link(cities, cities):
         distance, !The distance matrix;
         x;        ! x(i,j)=1 if we use link i,j;
    endsets
    data:  !Distance matrix, it need not be symmetirc;
      distance =  0  8  5  9 12 14 12
             8  0  9 15 16  8 11
             5  9  0  7  9 11 7
             9 15  7  0  3 17 10
            12 16  9  3  0  8 10
            14  8 11 17  8  0  9
            12 11  7 10 10  9  0;
   enddata
   n=@size(cities); !The model size;
   ! Minimize total distance of the links;
   min=@sum(link(i,j)|i #ne# j: distance(i,j)*x(i,j));
   !There must be an arc out of city 1;
   @sum(cities(i)|i #gt# 1: x(1,i))>=1;
   !For city i, except the base (city 1);
   @for(cities(i) | i #gt# 1 :
!  It must be entered;
      @sum(cities(j)| j #ne# i: x(j,i))=1;
   !  level(j)=levle(i)+1, if we link j and i;
      @for(cities(j)| j #gt# 1 #and# j #ne# i :
        level(j) >= level(i) + x(i,j)
                 - (n-2)*(1-x(i,j)) + (n-3)*x(j,i);
     );
  !  The level of city is at least 1 but no more n-1,
     and is 1 if it links to base (city 1);
    @bnd(1,level(i),999999);
     level(i)<=n-1-(n-2)*x(1,i);
  );
  ! Make the x's 0/1;@
  for(link : @bin(x));
END


自己对.........
作者: shumoeven    时间: 2011-9-9 21:16
虽然已经弄出来了  还是谢谢啦
作者: shumoeven    时间: 2011-9-9 21:16
虽然已经弄出来了  还是谢谢啦
作者: hejia88    时间: 2011-11-27 14:44
忽然发生法第三方发送到奥德赛




欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) Powered by Discuz! X2.5