标题:
整数规划
[打印本页]
作者:
coldzhang
时间:
2009-4-7 15:29
标题:
整数规划
谁能帮我把下面这个整数规划(fortran)子程序,转换成为C或者C++,不胜感激!
SUBROUTINE SUB0906(M,N,A,IX)
INTEGER M,N,A(M,N),R,C,T,S,LAN,LAD,IX(N)
INTEGER FUN931
N1=N-1
20 DO 25 I=2,M
IF(A(I,N).GE.0) GOTO 25
R=I
GOTO 30
25 CONTINUE
GOTO 100
30 DO 35 K=1,N1
IF(A(R,K).LT.0) GOTO 40
35 CONTINUE
GOTO 105
40 L=K
K1=K+1
IF(K1.EQ.N) GOTO 46
DO 45 J=K1,N1
IF(A(R,J).GE.0) GOTO 45
I=1
50 IF(A(I,J).GE.A(I,L)) GOTO 53
L=J
GOTO 45
53 IF(A(I,J).NE.A(I,L)) GOTO 45
I=I+1
GOTO 50
45 CONTINUE
46 S=1
55 IF(A(S,L).NE.0) GOTO 60
S=S+1
GOTO 55
60 LAN=-A(R,L)
LAD=1
NS=S-1
DO 65 J=1,N1
IF(J.EQ.L) GOTO 65
IF(A(R,J).GE.0) GOTO 65
IF(NS.EQ.0) GOTO 66
DO 70 I=1,NS
IF(A(I,J).NE.0) GOTO 65
70 CONTINUE
66 T=FUN931(A(S,J),A(S,L))
IF(T*A(S,L).NE.A(S,J).OR.T.LE.1) GOTO 80
I=S
75 I=I+1
IF(T*A(I,L).EQ.A(I,J)) GOTO 75
IF(T*A(I,L).GT.A(I,J)) T=T-1
80 IF(-A(R,J)*LAD.LE.T*LAN) GOTO 65
LAN=-A(R,J)
LAD=T
65 CONTINUE
DO 85 J=1,N
IF(J.EQ.L) GOTO 85
C=FUN931(A(R,J)*LAD,LAN)
IF(C.EQ.0) GOTO 85
DO 90 I=1,M
A(I,J)=A(I,J)+C*A(I,L)
90 CONTINUE
85 CONTINUE
GOTO 20
100 IX0=-A(1,N)
DO 110 I=1,N1
110 IX(I)=A(M-N+I+1,N)
WRITE(108,115) IX0
115 FORMAT(1X,4HIX0=,I4)
WRITE(108,120) (IX(I),I=1,N1)
120 FORMAT(1X,3HIX=,20(2X,I4))
WRITE(108,121)
121 FORMAT(///)
GOTO 130
105 WRITE(108,135)
135 FORMAT(1X,4HFAIL)
WRITE(108,122)
122 FORMAT(///)
130 RETURN
END
INTEGER FUNCTION FUN931(U,V)
INTEGER U,V,W
W=U/V
140 IF(W*V.LE.U) GOTO 145
W=W-1
GOTO 140
145 IF(V*(W+1).GT.U) GOTO 150
W=W+1
GOTO 145
150 FUN931=W
RETURN
END
如果有人有整数规划的C或者C++程序给我也行!!
欢迎光临 编程开发论坛 (http://bbs.lihuasoft.net/)
Powered by Discuz! 6.0.0