source: branches/2929_PrioritizedGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.PGE/3.3/src/go-symexpr/expr_test.go @ 16620

Last change on this file since 16620 was 16620, checked in by hmaislin, 9 months ago

#2929: Reorganized folder structure for make script, removed explicit marshalling, erased go-side logging

File size: 2.9 KB
Line 
1package symexpr
2
3import (
4  "testing"
5 
6  "fmt"
7)
8
9
10func Test_Print(t *testing.T) {
11  fmt.Printf( "Testing: Print                " )
12 
13  c := NewConstantF(1.57)
14  s := NewSin(c)
15  t.Logf( "Hello Me!   %v\n", s )
16
17  c.F = 90.0
18  t.Logf( "Hello Me!   %v\n", c )
19 
20  fmt.Printf( "Passed\n" )
21}
22
23
24
25// func TEST() {
26//   A1 := SE.NewAdd()
27//   A2 := SE.NewAdd()
28//
29//   M1 := SE.NewMul()
30//   M2 := SE.NewMul()
31//   M3 := SE.NewMul()
32//
33//   c1 := new(SE.Constant)
34//   c1.P = 0
35//   c2 := new(SE.Constant)
36//   c2.P = 1
37//   c3 := new(SE.Constant)
38//   c3.P = 1
39//
40//   x1 := new(SE.Var)
41//   x1.P = 0
42//   x2 := new(SE.Var)
43//   x2.P = 0
44//
45//   M1.Insert(c1)
46//   M1.Insert(x1)
47//   M2.Insert(c2)
48//   M2.Insert(x2)
49//   M3.Insert(c3)
50//   M3.Insert(x1)
51//
52//   A1.Insert(M1)
53//   A1.Insert(M2)
54//
55//   A2.Insert(M2)
56//   A2.Insert(M3)
57//
58//
59//   m12 := M1.AmIAlmostSame(M2)
60//   m13 := M1.AmIAlmostSame(M3)
61//   m23 := M2.AmIAlmostSame(M3)
62//
63//   fmt.Printf( "m12: %v\n", m12 )
64//   fmt.Printf( "m12: %v\n", m13 )
65//   fmt.Printf( "m12: %v\n", m23 )
66//   fmt.Printf( "\n" )
67//
68//   fmt.Printf( "A1:  %v\n", A1 )
69//   fmt.Printf( "A2:  %v\n", A2 )
70//   A1.Sort()
71//   A2.Sort()
72//   fmt.Printf( "A1:  %v\n", A1 )
73//   fmt.Printf( "A2:  %v\n", A2 )
74// }
75/*
76
77func TestAmIAlmostSame() {
78  var add1,add2,add3,add4 Add
79  add1.CS[0] = &ConstantF{F: 4.20}
80  add1.CS[1] = &Var{P:1}
81  add2.CS[0] = &ConstantF{F: 4.20}
82  add2.CS[1] = &Var{P:1}
83  add3.CS[0] = &ConstantF{F: 4.20}
84  add3.CS[1] = &Var{P:2}
85  add4.CS[0] = &ConstantF{F: -4.20}
86  add4.CS[1] = &Var{P:1}
87
88  var a1,a2,a3,a4 Expr
89  a1,a2,a3,a4 = &add1,&add2,&add3,&add4
90
91  fmt.Printf( "Testing Almost\n\n" )
92
93  fmt.Printf( "a1: %v\na2: %v\na3: %v\na4: %v\n", a1,a2,a3,a4 )
94
95  fmt.Printf( "a1->a2 = %v (true)\n", a1.AmIAlmostSame(a2) )
96  fmt.Printf( "a1->a3 = %v (false)\n", a1.AmIAlmostSame(a3) )
97  fmt.Printf( "a1->a4 = %v (true)\n", a1.AmIAlmostSame(a4) )
98
99}
100
101func testAddSimp(srules SimpRules) {
102  var add,bdd,cdd Add
103  var mul Mul
104  mul.CS[0] = &ConstantF{F: 4.20}
105  mul.CS[1] = &Var{P:1}
106  add.CS[0] = &ConstantF{F: 4.20}
107  add.CS[1] = &cdd
108  add.CS[2] = &bdd
109  add.CS[3] = &mul
110  bdd.CS[0] = &Var{P:1}
111  bdd.CS[1] = &Var{P:0}
112  cdd.CS[0] = &Var{P:1}
113  cdd.CS[1] = &Var{P:1}
114
115  var e Expr
116  e = &add
117//   f = &cdd
118
119  fmt.Printf( "Orig:  %v\n", e )
120  es := e.Simplify( srules )
121  fmt.Printf( "Simp:  %v\n\n\n", es )
122  es.CalcExprStats(0)
123
124/*  for i:= 0; i < es.Size(); i++ {
125    p,q := i,i
126    fmt.Printf( "%v: %v\n", i, es.GetExpr(&p) )
127    et := es.Clone()
128    fmt.Printf( "Orig:  %v\n", et )
129    f := cdd.Clone()
130    eu := SwapExpr( et, f, q )
131    if eu != nil {
132      et = eu
133    } else {
134      fmt.Printf( "nil\n" )
135    }
136    fmt.Printf( "Swap:  %v\n", et )
137    ev := et.Simplify(srules)
138    fmt.Printf( "Simp:  %v\n\n", ev )
139  }*/
140
141
142
143//}*/
144
145
Note: See TracBrowser for help on using the repository browser.