Ejemplo n.º 1
0
func printBenchLatex() {

	for _, B := range probs.BenchmarkList {

		varNames := make([]string, 0)
		for _, v := range B.TrainVars {
			// fmt.Printf("  %v\n", v)
			varNames = append(varNames, v.Name)
		}
		eqn := expr.ParseFunc(B.FuncText, varNames)
		sort := eqn.Clone()
		rules := expr.DefaultRules()
		rules.GroupAddTerms = false
		sort = sort.Simplify(rules)

		latex := sort.Latex(varNames, nil, nil)

		fmt.Println(B.Name, " \t&\t $", latex, "$ \\\\")
	}
}
Ejemplo n.º 2
0
func GenBenchmark(b Benchmark) (p *ExprProblem) {
	p = new(ExprProblem)
	p.Name = b.Name

	// set the function
	varNames := make([]string, 0)
	for _, v := range b.TrainVars {
		// fmt.Printf("  %v\n", v)
		varNames = append(varNames, v.Name)
	}
	eqn := expr.ParseFunc(b.FuncText, varNames)
	sort := eqn.Clone()
	rules := expr.DefaultRules()
	rules.GroupAddTerms = false
	sort = sort.Simplify(rules)
	p.VarNames = varNames
	p.FuncTree = sort

	trn := new(PointSet)
	trn.SetFN(b.Name + "_train")
	trn.SetID(0)
	trn.SetNumDim(len(varNames))
	trn.SetIndepNames(varNames)
	trn.SetDepndNames([]string{"f(xs)"})
	trn.SetPoints(GenBenchData(eqn, b.TrainVars, b.TrainSamples))
	p.Train = make([]*PointSet, 1)
	p.Train[0] = trn

	tst := new(PointSet)
	tst.SetFN(b.Name + "_test")
	tst.SetID(0)
	tst.SetNumDim(len(varNames))
	tst.SetIndepNames(varNames)
	tst.SetDepndNames([]string{"f(xs)"})
	tst.SetPoints(GenBenchData(eqn, b.TestVars, b.TestSamples))
	p.Test = make([]*PointSet, 1)
	p.Test[0] = tst

	return p
}
Ejemplo n.º 3
0
func (PS *PgeSearch) Init(done chan int, prob *probs.ExprProblem, logdir string, input interface{}) {
	fmt.Printf("Init'n PGE\n")
	// setup data

	// open logs
	PS.initLogs(logdir)

	// copy in common config options
	PS.prob = prob
	if PS.cnfg.treecfg == nil {
		PS.cnfg.treecfg = PS.prob.TreeCfg.Clone()
	}
	srules := expr.DefaultRules()
	srules.ConvertConsts = true
	PS.cnfg.simprules = srules

	fmt.Println("Roots:   ", PS.cnfg.treecfg.RootsS)
	fmt.Println("Nodes:   ", PS.cnfg.treecfg.NodesS)
	fmt.Println("Leafs:   ", PS.cnfg.treecfg.LeafsS)
	fmt.Println("NonTrig: ", PS.cnfg.treecfg.NonTrigS)

	PS.GenRoots = make([]expr.Expr, len(PS.cnfg.treecfg.Roots))
	for i := 0; i < len(PS.GenRoots); i++ {
		PS.GenRoots[i] = PS.cnfg.treecfg.Roots[i].Clone()
	}
	PS.GenNodes = make([]expr.Expr, len(PS.cnfg.treecfg.Nodes))
	for i := 0; i < len(PS.GenNodes); i++ {
		PS.GenNodes[i] = PS.cnfg.treecfg.Nodes[i].Clone()
	}
	PS.GenNonTrig = make([]expr.Expr, len(PS.cnfg.treecfg.NonTrig))
	for i := 0; i < len(PS.GenNonTrig); i++ {
		PS.GenNonTrig[i] = PS.cnfg.treecfg.NonTrig[i].Clone()
	}

	PS.GenLeafs = make([]expr.Expr, 0)
	for _, t := range PS.cnfg.treecfg.LeafsT {
		switch t {
		case expr.TIME:
			PS.GenLeafs = append(PS.GenLeafs, expr.NewTime())

		case expr.VAR:
			fmt.Println("Use Vars: ", PS.cnfg.treecfg.UsableVars)
			for _, i := range PS.cnfg.treecfg.UsableVars {
				PS.GenLeafs = append(PS.GenLeafs, expr.NewVar(i))
			}

		case expr.SYSTEM:
			for i := 0; i < PS.prob.Train[0].NumSys(); i++ {
				PS.GenLeafs = append(PS.GenLeafs, expr.NewSystem(i))
			}

		}
	}
	/*** FIX ME
	PS.GenLeafs = make([]expr.Expr, len(PS.cnfg.treecfg.Leafs))
	for i := 0; i < len(PS.GenLeafs); i++ {
		PS.GenLeafs[i] = PS.cnfg.treecfg.Leafs[i].Clone()
	}
	***/

	fmt.Println("Roots:   ", PS.GenRoots)
	fmt.Println("Nodes:   ", PS.GenNodes)
	fmt.Println("Leafs:   ", PS.GenLeafs)
	fmt.Println("NonTrig: ", PS.GenNonTrig)

	// setup communication struct
	PS.commup = input.(*probs.ExprProblemComm)

	// initialize bbq
	PS.Trie = new(IpreNode)
	PS.Trie.val = -1
	PS.Trie.next = make(map[int]*IpreNode)

	PS.Best = probs.NewReportQueue()
	PS.Best.SetSort(probs.GPSORT_PARETO_TST_ERR)
	PS.Queue = PS.GenInitExpr()
	PS.Queue.SetSort(probs.PESORT_PARETO_TST_ERR)

	PS.neqns = PS.Queue.Len()

	PS.minError = math.Inf(1)

	PS.eval_in = make(chan expr.Expr, 4048)
	PS.eval_out = make(chan *probs.ExprReport, 4048)

	for i := 0; i < PS.cnfg.evalrCount; i++ {
		go PS.Evaluate()
	}
}