@@ -52,7 +52,7 @@ func test0() {
5252
5353 d := 50
5454 w := 40
55- network .C = 10 //int(d)
55+ network .C = 4 //int(d)
5656 network .PeerCMS = network .InitCMS (uint (d ), uint (w ))
5757 //fmt.Println(network.PeerCMS.MatToString())
5858
@@ -62,7 +62,7 @@ func test0() {
6262 //var listpeers = []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
6363
6464 var output = []string {}
65- fmt .Println ("Memory" , network .Sample_memory )
65+ fmt .Println ("Memory" , network .Sample_memory , network . C )
6666
6767 for i , elm := range listpeers {
6868 println (">>>>>>>>>>>>> ELEMENT" , i + 1 , " " , elm )
@@ -106,8 +106,8 @@ func test_Knowledge_free() {
106106 n := network .Read_occurence (listpeers )
107107 /* CMS Parameters */
108108
109- // k := int(math.Ceil(0.01 * float64(n))) // other test to do
110- k := int (math .Ceil (math .Log (float64 (n )))) // round to the next integer
109+ k := int (math .Ceil (0.01 * float64 (n ))) // other test to do
110+ // k := int(math.Ceil(math.Log(float64(n)))) // round to the next integer
111111 s := 10
112112 network .C = 300
113113
@@ -253,3 +253,61 @@ func check_cms() {
253253
254254 return
255255}
256+
257+ func test_Knowledge_free_with_small_set () {
258+
259+ path := input_path
260+ var listpeers , err = readLines (path )
261+ if err != nil {
262+ log .Println ("(check) Unable to read config file " , path )
263+ return
264+ }
265+
266+ m := len (listpeers )
267+ log .Println ("Input of size " , m )
268+
269+ n := network .Read_occurence (listpeers )
270+ /* CMS Parameters */
271+
272+ k := int (math .Ceil (0.01 * float64 (n ))) // other test to do
273+ //k := int(math.Ceil(math.Log(float64(n)))) // round to the next integer
274+ s := 10
275+ network .C = 300
276+
277+ network .PeerCMS = network .InitCMS (uint (s ), uint (k ))
278+
279+ fmt .Println (network .PeerCMS .MatToString ())
280+
281+ /* Knowledge free algorithm */
282+ var output = []string {}
283+ trunk := 1000
284+ train := 100000
285+ begin := m - trunk - train
286+ fmt .Printf ("Read %d elements between from element %d \n " , trunk , begin )
287+ for _ , elm := range listpeers [begin : m - trunk ] {
288+ //println(">elmt", i)
289+ network .PeerCMS .UpdateString (elm , 1 )
290+
291+ }
292+ for _ , elm := range listpeers [m - trunk :] { //only trunk elements in the output
293+ //println(">elmt", i)
294+ network .PeerCMS .UpdateString (elm , 1 )
295+
296+ value := network .PeerCMS .Knowledge_free (elm )
297+ output = append (output , value )
298+
299+ }
300+ fmt .Println (network .PeerCMS .MatToString ())
301+ /* summary */
302+ fmt .Printf ("A matrix of size %d*%d with sample memory length of %d\n Output of size %d\n " ,
303+ s , k , len (network .Sample_memory ), len (output ))
304+
305+ out_path := "data/output" + strconv .Itoa (num_expe ) // path of the unbiaised output stream
306+ err = writeLines (output , out_path )
307+ if err != nil {
308+ log .Println ("(Write) Unable to read config file " , out_path )
309+ return
310+ }
311+
312+ return
313+ }
0 commit comments