Free cookie consent management tool by TermsFeed Policy Generator

Changeset 16183 for branches


Ignore:
Timestamp:
09/25/18 11:28:51 (6 years ago)
Author:
hmaislin
Message:

#2929: Adapted PGE Go code to work as dll

Location:
branches/2929_PrioritizedGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.PGE/3.3/go-code/go-pge/problems
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2929_PrioritizedGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.PGE/3.3/go-code/go-pge/problems/data.go

    r16080 r16183  
    88  "math/rand"
    99  "os"
     10  "C"
     11  "unsafe"
    1012)
    1113
     
    126128}
    127129
     130func (trainData *PointSet) InitTrainData(indepNames []string, depndNames []string, matrix unsafe.Pointer, nEntries int) {
     131  trainData.indepNames = indepNames  //First line in .trn file
     132  trainData.numDim = len(trainData.indepNames)
     133  trainData.depndNames = depndNames //Second line in .trn file
     134  fmt.Printf("Var Names = %v | %v\n", trainData.depndNames, trainData.indepNames)
     135  var nClum int = len(indepNames) + len(depndNames)
     136
     137  for i := 0; i < nEntries; i++ {
     138    var pnt Point
     139    for j := 0; j < len(trainData.indepNames); j++ {
     140      elemNr := i * nClum + j
     141      item := (*float64) (unsafe.Pointer( uintptr(unsafe.Pointer(matrix)) + unsafe.Sizeof(float64(0)) * uintptr(elemNr) ))
     142      pnt.indep = append(pnt.indep, *item)
     143    }
     144
     145    for j := len(trainData.indepNames); j < (len(trainData.indepNames) + len(trainData.depndNames)); j++ {
     146      elemNr := i * nClum + j
     147      item := (*float64) (unsafe.Pointer( uintptr(unsafe.Pointer(matrix)) + unsafe.Sizeof(float64(0)) * uintptr(elemNr) ))
     148      pnt.depnd = append(pnt.depnd, *item )
     149    }
     150
     151    if len(pnt.indep) > 0 {
     152      trainData.dataPoints = append(trainData.dataPoints, pnt)
     153    }
     154  }
     155  fmt.Printf("Num Points: %v\n", len(trainData.dataPoints))
     156}
     157
    128158func (d *PointSet) ReadPointSet(filename string) {
    129159  ftotal, err := os.OpenFile(filename, os.O_RDONLY, 0)
  • branches/2929_PrioritizedGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.PGE/3.3/go-code/go-pge/problems/problem.go

    r16080 r16183  
    166166  return list[0:i]
    167167}
     168
     169
     170func (ep *ExprProblem) CreatePS(Name string, MaxIter int, HitRatio float64, SearchVar int, ProblemTypeString string) {  //IndepNames []string, DepndNames []string, SysNames []string
     171  ep.SearchType = ProblemTypeFromString(ProblemTypeString)
     172  ep.Name = Name
     173 
     174  ep.TrainFns = append(ep.TrainFns, "dummy")
     175  ep.TestFns = append(ep.TestFns, "dummy")
     176   
     177  ep.MaxIter = MaxIter
     178  ep.HitRatio = HitRatio
     179  ep.SearchVar = SearchVar
     180}
  • branches/2929_PrioritizedGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.PGE/3.3/go-code/go-pge/problems/treeparams.go

    r16080 r16183  
    297297  tp.TmpMinSize, tp.TmpMinDepth = tp.MinSize, tp.MinDepth
    298298}
     299
     300
     301func (TP *TreeParams) CreateTreeParams(Roots string, Nodes string, NonTrig string, Leafs string, UsableVars []int, MaxSize int, MinSize int, MaxDepth int, MinDepth int) {
     302  TP.RootsS = strings.Fields(Roots)
     303  TP.RootsT, TP.Roots = fillExprStuff(TP.RootsS)
     304 
     305  TP.NodesS = strings.Fields(Nodes)
     306  TP.NodesT, TP.Nodes = fillExprStuff(TP.NodesS)
     307 
     308  TP.NonTrigS = strings.Fields(NonTrig)
     309  TP.NonTrigT, TP.NonTrig = fillExprStuff(TP.NonTrigS)
     310 
     311  TP.LeafsS = strings.Fields(Leafs)
     312  TP.LeafsT, TP.Leafs = fillExprStuff(TP.LeafsS)
     313
     314  TP.UsableVars = UsableVars
     315
     316  TP.MaxSize = MaxSize
     317  TP.MinSize = MinSize
     318  TP.MaxDepth = MaxDepth
     319  TP.MinDepth = MinDepth
     320}
Note: See TracChangeset for help on using the changeset viewer.