예제 #1
0
func (PS *PgeSearch) ParseConfig(filename string) {
	fmt.Printf("Parsing PGE Config: %s\n", filename)
	data, err := ioutil.ReadFile(filename)
	if err != nil {
		log.Fatal(err)
	}
	err = config.ParseConfig(data, pgeConfigParser, &PS.cnfg)
	if err != nil {
		log.Fatal(err)
	}
}
예제 #2
0
func (DS *MainSearch) ParseConfig(filename string) {
	fmt.Printf("Parsing Main Config: %s\n", filename)
	data, err := ioutil.ReadFile(filename)
	if err != nil {
		log.Fatal(err)
	}

	err = config.ParseConfig(data, mainConfigParser, &DS.cnfg)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%v\n", DS.cnfg)
}
예제 #3
0
func (DS *MainSearch) Init(done chan int, input interface{}) {
	fmt.Printf("Init'n PGE1\n----------\n")

	DC := DS.cnfg

	// read and setup problem
	eprob := new(probs.ExprProblem)

	fmt.Printf("Parsing Problem Config: %s\n", DC.probCfg)
	data, err := ioutil.ReadFile(DC.cfgDir + DC.probCfg)
	if err != nil {
		log.Fatal(err)
	}
	err = config.ParseConfig(data, probs.ProbConfigParser, eprob)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("Prob: %v\n", eprob)
	fmt.Printf("TCfg: %v\n\n", eprob.TreeCfg)

	// setup log dir and open main log files
	DC.logDir += eprob.Name + "/"
	if DC.srchCfg[0][:4] == "pge1" {
		DC.logDir += "pge1/"
	} else if DC.srchCfg[0][:3] == "pge" {
		DC.logDir += "pge/"
	}

	os.MkdirAll(DC.logDir, os.ModePerm)

	now := time.Now()
	fmt.Println("LogDir: ", DC.logDir)
	os.MkdirAll(DC.logDir, os.ModePerm)
	DS.initLogs(DC.logDir)

	DS.mainLog.Println(DC.logDir, now)

	// // setup data
	fmt.Printf("Setting up problem: %s\n", eprob.Name)

	eprob.Train = make([]*probs.PointSet, len(eprob.TrainFns))
	for i, fn := range eprob.TrainFns {
		fmt.Printf("Reading Trainging File: %s\n", fn)
		eprob.Train[i] = new(probs.PointSet)
		if strings.HasSuffix(fn, ".dataF2") || strings.HasSuffix(fn, ".mat") {
			eprob.Train[i].ReadLakeFile(DC.dataDir + fn)
		} else {
			eprob.Train[i].ReadPointSet(DC.dataDir + fn)
		}
	}
	eprob.Test = make([]*probs.PointSet, len(eprob.TestFns))
	for i, fn := range eprob.TestFns {
		fmt.Printf("Reading Testing File: %s\n", fn)
		eprob.Test[i] = new(probs.PointSet)
		if strings.HasSuffix(fn, ".dataF2") || strings.HasSuffix(fn, ".mat") {
			eprob.Test[i].ReadLakeFile(DC.dataDir + fn)
		} else {
			eprob.Test[i].ReadPointSet(DC.dataDir + fn)
		}
	}

	DS.prob = eprob
	fmt.Println()

	// read search configs
	for _, cfg := range DC.srchCfg {
		if cfg[:4] == "pge1" {
			GS := new(pge.PgeSearch)
			GS.ParseConfig(DC.cfgDir + cfg)
			DS.srch = append(DS.srch, GS)
		} else if cfg[:3] == "pge" {
			PS := new(pge.PgeSearch)
			PS.ParseConfig(DC.cfgDir + cfg)
			DS.srch = append(DS.srch, PS)

			/************/
			// temporary hack
			DS.prob.MaxIter = PS.GetMaxIter()
			/************/
			if *arg_pge_iter >= 0 {
				DS.prob.MaxIter = *arg_pge_iter
				PS.SetMaxIter(*arg_pge_iter)
			}
			if *arg_pge_peel >= 0 {
				PS.SetPeelCount(*arg_pge_peel)
			}
			if *arg_pge_init != "" {
				PS.SetInitMethod(*arg_pge_init)
			}
			if *arg_pge_grow != "" {
				PS.SetGrowMethod(*arg_pge_grow)
			}
			PS.SetEvalrCount(*arg_pge_evals)

		} else {
			log.Fatalf("unknown config type: %v  from  %v\n", cfg[:4], cfg)
		}
	}

	// setup best results
	DS.eqns = make(probs.ExprReportArray, 32)
	DS.per_eqns = make([]*probs.ExprReportArray, len(DS.srch))

	// setup communication struct
	DS.comm = make([]*probs.ExprProblemComm, len(DS.srch))
	for i, _ := range DS.comm {
		DS.comm[i] = new(probs.ExprProblemComm)
		DS.comm[i].Cmds = make(chan int)
		DS.comm[i].Rpts = make(chan *probs.ExprReportArray, 64)
		DS.comm[i].Gen = make(chan [2]int, 64)
	}

	DS.iter = make([]int, len(DS.srch))

	fmt.Println("\n******************************************************\n")

	// initialize searches
	sdone := make(chan int)
	for i, _ := range DS.srch {
		DS.srch[i].Init(sdone, eprob, DC.logDir, DS.comm[i])
	}
	fmt.Println("\n******************************************************\n")

}