Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2929_PrioritizedGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.PGE/3.3/src/go-pge/pge/pge_expand_method_3.go

Last change on this file was 16620, checked in by hmaislin, 5 years ago

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

File size: 1.3 KB
Line 
1package pge
2
3import (
4  // "fmt"
5  "sort"
6
7  expr "go-symexpr"
8)
9
10func (PS *PgeSearch) ExpandMethod3(O expr.Expr) (ret []expr.Expr) {
11  O.Sort()
12  ret = make([]expr.Expr, 0)
13  // fmt.Printf("Expanding expression:  %v\n", O)
14
15  add := O.(*expr.Add)
16
17  // adding term to addition
18  for _, B := range PS.ffxBases {
19    found := false
20    for _, C := range add.CS {
21      // fmt.Printf("checking %v in %v\n", B, add)
22      if C.AmISame(B) {
23        // fmt.Println("found\n\n")
24        found = true
25        break
26      }
27    }
28    if !found {
29      e := O.Clone()
30      a := e.(*expr.Add)
31      a.Insert(B.Clone())
32      sort.Sort(a)
33      a.CalcExprStats()
34      good := PS.cnfg.treecfg.CheckExpr(a)
35      if good {
36        ret = append(ret, a)
37      }
38      // fmt.Printf("grew  %v\n\n", a)
39      // ret = append(ret, a)
40    }
41  }
42
43  // extending terms in addition
44  for _, B := range PS.ffxBases {
45    for i, C := range add.CS {
46      if C.ExprType() == expr.MUL {
47        m := C.(*expr.Mul)
48        if len(m.CS) > 3 {
49          continue
50        }
51      }
52      e := O.Clone()
53      a := e.(*expr.Add)
54      mul := expr.NewMul()
55      mul.Insert(a.CS[i])
56      mul.Insert(B.Clone())
57      a.CS[i] = mul
58      sort.Sort(a)
59      a.CalcExprStats()
60      good := PS.cnfg.treecfg.CheckExpr(a)
61      if good {
62        ret = append(ret, a)
63      }
64      // fmt.Printf("grew  %v\n\n", a)
65      ret = append(ret, a)
66    }
67  }
68
69  // fmt.Println("Len of ret = ", len(ret))
70  return ret
71}
Note: See TracBrowser for help on using the repository browser.