Advertisement
jargon

basTgMath_Constellation.bas

Feb 23rd, 2013
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Attribute VB_Name = "basTgMath_Constellation"
  2. Public Type typeTgStat
  3.     Name As String
  4. End Type
  5. Public Type typeTgTelemetry
  6.     Stat() As Double
  7. End Type
  8. Public Type typeTgItem
  9.     Name As String
  10.     Stat() As Double
  11.     Link() As Double
  12. End Type
  13. Public Type typeTgData
  14.     StatFile As String
  15.     ItemFile As String
  16.     LinkFile As String
  17.     StatCount As Long
  18.     ItemCount As Long
  19.     Stat() As typeTgStat
  20.     Item() As typeTgItem
  21.     Telemetry(1 To 4) As typeTgTelemetry
  22.     PTotal As Double
  23.     PCount As Double
  24. End Type
  25. Sub redimdata(Tgdata As typeTgData)
  26.    
  27.     Tgdata.PCount = 0
  28.     Tgdata.PTotal = 4 + Tgdata.ItemCount + 1
  29.    
  30.     'frmTgProgress.Show
  31.    'frmTgProgress.Caption = "Allocating Memory"
  32.    'frmTgProgress.Refresh
  33.  
  34.     ReDim Tgdata.Stat(0 To Tgdata.StatCount)
  35.     For t = 1 To 4
  36.         ReDim Tgdata.Telemetry(t).Stat(0 To Tgdata.StatCount)
  37.         pdisp Tgdata
  38.     Next t
  39.     ReDim Tgdata.Item(0 To Tgdata.ItemCount)
  40.     For t = 0 To Tgdata.ItemCount
  41.         ReDim Tgdata.Item(t).Stat(0 To Tgdata.StatCount)
  42.         ReDim Tgdata.Item(t).Link(0 To Tgdata.ItemCount)
  43.         pdisp Tgdata
  44.     Next t
  45.    
  46.     'frmTgProgress.Hide
  47.    
  48. End Sub
  49. Sub loaddata(Tgdata As typeTgData)
  50.    
  51.     Open Tgdata.StatFile For Input As 1
  52.     Open Tgdata.ItemFile For Input As 2
  53.     Input #1, tmpstr, Tgdata.StatCount
  54.     Input #2, tmpstr, Tgdata.ItemCount
  55.    
  56.     redimdata Tgdata
  57.    
  58.     resetptotal Tgdata
  59.     CIncr Tgdata.PTotal, Tgdata.ItemCount + Tgdata.StatCount
  60.        
  61.     Input #1, tmpstr
  62.     Input #2, tmpstr
  63.    
  64.     For t = 1 To StatCount
  65.         Input #1, Tmp, Tgdata.Stat(t).Name
  66.         pdisp Tgdata
  67.     Next t
  68.    
  69.     For t = 1 To ItemCount
  70.         Input #2, Tmp, Tgdata.Item(t).Name
  71.         pdisp Tgdata
  72.     Next t
  73.    
  74.     Input #1, tmpstr
  75.     Input #2, tmpstr
  76.    
  77.     Close 1
  78.     Close 2
  79. End Sub
  80. Sub resetptotal(Tgdata As typeTgData)
  81.    
  82.     Tgdata.PCount = 0
  83.     Tgdata.PTotal = Tgdata.ItemCount * (Tgdata.StatCount + (Tgdata.StatCount + (Tgdata.ItemCount - 1) * (Tgdata.StatCount + (Tgdata.ItemCount - 2#) * 2# * Tgdata.StatCount)))
  84.    
  85. End Sub
  86. Sub algorithm(Tgdata As typeTgData)
  87.    
  88.     'frmTgProgress.Show
  89.    'frmTgProgress.Caption = "Taktikosgenesis"
  90.    'frmTgProgress.Refresh
  91.    
  92.     'resetptotal Tgdata
  93.        
  94.     For t = 1 To Tgdata.ItemCount
  95.         For tt = 1 To Tgdata.StatCount
  96.             Tgdata.Telemetry(1).Stat(tt) = Tgdata.Item(t).Stat(tt)
  97.             pdisp Tgdata
  98.         Next tt
  99.         For t2 = 1 To Tgdata.ItemCount
  100.             If t2 <> t Then
  101.                 telradius = 0
  102.                 For tt = 1 To Tgdata.StatCount
  103.                     Tgdata.Telemetry(2).Stat(tt) = Tgdata.Item(t2).Stat(tt)
  104.                     CIncr telradius, (Tgdata.Item(t).Stat(tt) - Tgdata.Item(t2).Stat(tt)) ^ 2
  105.                     pdisp Tgdata
  106.                 Next tt
  107.                 For t3 = 1 To Tgdata.ItemCount
  108.                     If t3 <> t1 And t3 <> t2 Then
  109.                         For ttel = 1 To 2
  110.                             telspan = 0
  111.                             For tt = 1 To Tgdata.StatCount
  112.                                 CIncr telspan, (Tgdata.Telemetry(ttel).Stat(tt) - Tgdata.Item(t3).Stat(tt)) ^ 2
  113.                                 pdisp Tgdata
  114.                             Next tt
  115.                             If telspan > telradius Then
  116.                                 CIncr Tgdata.Item(t).Link(t2), 1
  117.                             End If
  118.                         Next ttel
  119.                     End If
  120.                 Next t3
  121.             End If
  122.         Next t2
  123.     Next t
  124.     'frmTgProgress.Hide
  125.    
  126. End Sub
  127. Sub dumpdata(Tgdata As typeTgData)
  128.  
  129.     Open Tgdata.LinkFile For Output As 1
  130.     For t = 1 To Tgdata.ItemCount
  131.         Print #1, "item(" & t & "):" & Tgdata.Item(t).Name
  132.         Print #1, "{"
  133.         Print #1, "statistics:"
  134.         For t2 = 1 To Tgdata.StatCount
  135.             Print #1, Tgdata.Stat(t2).Name & ":" & Tgdata.Item(t).Stat(t2)
  136.         Next t2
  137.         Print #1, "classification:"
  138.         For t2 = 1 To Tgdata.ItemCount
  139.             If t2 <> t Then
  140.                 Print #1, "#" & t2 & "(" & Tgdata.Item(t2).Name & "):" & Fix(Tgdata.Item(t).Link(t2) / ((Tgdata.ItemCount - 2) * 2) * 100) & "%"
  141.             End If
  142.         Next t2
  143.         Print #1, "}"
  144.     Next t
  145.     Close 1
  146.  
  147. End Sub
  148.  
  149. Sub pdisp(Tgdata As typeTgData)
  150.     'Tgdata.PCount = Tgdata.PCount + 1
  151.    'If (Fix((Tgdata.PCount / Tgdata.PTotal) * 100) & "%") <> frmTgProgress.lblp(0).Caption Then
  152.    '    frmTgProgress.lblp(0).Caption = Fix((Tgdata.PCount / Tgdata.PTotal) * 100) & "%"
  153.    '    frmTgProgress.lblp(1).Caption = Tgdata.PCount & " of " & Tgdata.PTotal
  154.    '    frmTgProgress.Refresh
  155.    'End If
  156. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement