Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2929_PrioritizedGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.PGE/3.3/go-code/src/go-pge/main_datagen.go @ 16666

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

#2929: Modified make / folder structure to build original app, added x86 dll

File size: 1.8 KB
Line 
1package main
2
3import (
4  "fmt"
5  "strings"
6
7  probs "go-pge/problems"
8  expr "go-symexpr"
9)
10
11func genBenchmark(probname string) {
12  fmt.Printf("Generating files for %s\n", probname)
13  bname := probname[strings.Index(probname, ":")+1:]
14  fmt.Printf("bname:  '%s'\n", bname)
15  benches := probs.BenchmarkList
16  switch bname {
17  case "all":
18    for i := 0; i < len(benches); i++ {
19      fmt.Printf("bm: %v\n", benches[i])
20      bname = benches[i].Name
21      symprob := probs.GenBenchmark(benches[i])
22      symprob.Train[0].WritePointSet("data/benchmark/" + bname + ".trn")
23      symprob.Test[0].WritePointSet("data/benchmark/" + bname + ".tst")
24      fmt.Println()
25    }
26  case "list":
27    printBenchNames()
28  default:
29    i := 0
30    for ; i < len(benches); i++ {
31      if benches[i].Name == bname {
32        fmt.Printf("bm: %v\n", benches[i])
33        symprob := probs.GenBenchmark(benches[i])
34        symprob.Train[0].WritePointSet("data/benchmark/" + bname + ".trn")
35        symprob.Test[0].WritePointSet("data/benchmark/" + bname + ".tst")
36        fmt.Println()
37        return
38      }
39    }
40    if i == len(benches) {
41      fmt.Printf("benchmark problem not found:  %s\n", probname)
42      printBenchNames()
43    }
44  }
45
46}
47
48func printBenchNames() {
49  benches := probs.BenchmarkList
50  fmt.Printf("Available Benchmarks:  |%d|\n[ %s", len(benches), benches[0].Name)
51  for i := 0; i < len(benches); i++ {
52    fmt.Printf(", %s", benches[i].Name)
53  }
54  fmt.Println(" ]")
55}
56
57func printBenchLatex() {
58
59  for _, B := range probs.BenchmarkList {
60
61    varNames := make([]string, 0)
62    for _, v := range B.TrainVars {
63      // fmt.Printf("  %v\n", v)
64      varNames = append(varNames, v.Name)
65    }
66    eqn := expr.ParseFunc(B.FuncText, varNames)
67    sort := eqn.Clone()
68    rules := expr.DefaultRules()
69    rules.GroupAddTerms = false
70    sort = sort.Simplify(rules)
71
72    latex := sort.Latex(varNames, nil, nil)
73
74    fmt.Println(B.Name, " \t&\t $", latex, "$ \\\\")
75  }
76}
Note: See TracBrowser for help on using the repository browser.