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, "$ \\\\") } }
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 }