-
Notifications
You must be signed in to change notification settings - Fork 0
/
PRM_C.bas
128 lines (120 loc) · 2.27 KB
/
PRM_C.bas
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
! ///////////////////////////////////////
!
! Permutation Matrix Generator
!
! (c) 2023 by Dietmar G. Schrausser
!
INPUT "n", n_, 6
INPUT " m", m_, 3
dat$="READ.DATA "
theta =1
zlr=0
sw=0
DIM vi[100]
DIM c_wert[n_]
DIM c1_wert[n_,2]
TEXT.OPEN w, dat, "datP.txt"
FOR i= 1 TO n_
c_wert[i]=i
NEXT
FOR i= 1 TO 100
vi[i]=1
NEXT
vi[1]=0
st:
! // general index generation
FOR i=1 TO m_
IF i=1 THEN vi[1]= vi[1]+1
IF i=m_ & vi[i] > n_ THEN GOTO brk
IF vi[i] > n_
vi[i] = 1
vi[i+1] = vi[i+1] +1
ENDIF
NEXT i
! // endcriterion
IF i =m_ & vi[i] > n_ THEN GOTO brk
! // element repeat test at C, V, P, wP
IF theta =1 | theta=3 | theta=5 | theta=6
FOR i=1 TO m_
FOR j=i+1 TO m_
IF vi[i]=vi[j] THEN sw=1
NEXT j
NEXT i
ENDIF
! // arrangement repeat test at C, wC, wP
IF sw=0 & (theta=1 | theta=2 | theta=6)
FOR i=1 TO m_
FOR j = i+1 TO m_
IF vi[i]>vi[j] THEN sw=1
NEXT j
NEXT i
ENDIF
! // line vector output to file
IF sw=0
!// C, wC, V, wV, P
IF theta<6
FOR i =1 TO m_
! // PRINT INT$(c_wert[vi[i]]);CHR$(9);
c1_wert[i,1]=c_wert[vi[i]]
c1_wert[i,2]=1
NEXT
zl1=1
FOR i=1 TO n_
swv=0
FOR j=1 TO m_
IF vi[j]=i
swv=1
ENDIF
NEXT
IF swv=0
c1_wert[m_+zl1,1]=c_wert[i]
c1_wert[m_+zl1,2]=2
zl1=zl1+1
ENDIF
NEXT
PRINT INT$(zlr+1);CHR$(9); CHR$(9);
FOR i=1 TO m_
PRINT INT$(c1_wert[i,1]);CHR$(9);
dat$=dat$+ INT$(c1_wert[i,1])+","
NEXT
PRINT CHR$(9);
FOR i= 1 TO n_-m_
PRINT INT$(c1_wert[m_+i,1]);CHR$(9);
dat$=dat$+ INT$(c1_wert[m_+i,1])
IF i < n_- m_ THEN dat$=dat$+","
NEXT
PRINT CHR$(10) % lf
TEXT.WRITELN dat, dat$
dat$="READ.DATA "
ENDIF
! // wP
IF theta=6
FOR i=1 TO m_
PRINT c_wert[vi[i]]
c1_wert[i]=c_wert[vi[i]]
NEXT
PRINT " " % // k1
FOR i=1 TO n_
FOR j=1 TO m_
IF vi[j]=i THEN sw=1 %// k1 k2 element comparison
NEXT
IF sw=0 THEN PRINT c_wert[i] % //k2
sw=0
NEXT
ENDIF
zlr = zlr+1
ENDIF
sw=0
GOTO st
brk:
wp=1: FOR i=1 TO n_:wp=wp*i:NEXT
wp1=1:FOR i=1 TO m_:wp1=wp1*i:NEXT
wp2=1:FOR i=1 TO n_-m_:wp2=wp2*i:NEXT
wp=wp/(wp1*wp2)
PRINT "WP=C"+INT$(n_)+"("+INT$(m_)+")="INT$(wp)
pmin=1/wp
pmin2=pmin*2
p2$= FORMAT$("(%.###",pmin2)
PRINT FORMAT$("pmin=%.###",pmin)+p2$;")"
TEXT.CLOSE dat
END