-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsimplx.f
95 lines (95 loc) · 2.27 KB
/
simplx.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
SUBROUTINE SIMPLX(A,M,N,MP,NP,M1,M2,M3,ICASE,IZROV,IPOSV)
PARAMETER(MMAX=100,EPS=1.E-6)
DIMENSION A(MP,NP),IZROV(N),IPOSV(M),L1(MMAX),L2(MMAX),L3(MMAX)
IF(M.NE.M1+M2+M3)PAUSE 'Bad input constraint counts.'
NL1=N
DO 11 K=1,N
L1(K)=K
IZROV(K)=K
11 CONTINUE
NL2=M
DO 12 I=1,M
IF(A(I+1,1).LT.0.)PAUSE 'Bad input tableau.'
L2(I)=I
IPOSV(I)=N+I
12 CONTINUE
DO 13 I=1,M2
L3(I)=1
13 CONTINUE
IR=0
IF(M2+M3.EQ.0)GO TO 30
IR=1
DO 15 K=1,N+1
Q1=0.
DO 14 I=M1+1,M
Q1=Q1+A(I+1,K)
14 CONTINUE
A(M+2,K)=-Q1
15 CONTINUE
10 CALL SIMP1(A,MP,NP,M+1,L1,NL1,0,KP,BMAX)
IF(BMAX.LE.EPS.AND.A(M+2,1).LT.-EPS)THEN
ICASE=-1
RETURN
ELSE IF(BMAX.LE.EPS.AND.A(M+2,1).LE.EPS)THEN
M12=M1+M2+1
IF(M12.LE.M)THEN
DO 16 IP=M12,M
IF(IPOSV(IP).EQ.IP+N)THEN
CALL SIMP1(A,MP,NP,IP,L1,NL1,1,KP,BMAX)
IF(BMAX.GT.0.)GO TO 1
ENDIF
16 CONTINUE
ENDIF
IR=0
M12=M12-1
IF(M1+1.GT.M12)GO TO 30
DO 18 I=M1+1,M12
IF(L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