func runAdaptiveSolver(file string, json string, chooseOnce bool, extraStats, quiet bool) { // Initialize the cdb and assignment cdb, a, err := initSolver(file) if err != nil { log.Fatal(err) } // Set the proper max db size manage.MaxLearned = cdb.NGiven() / 3 // Read the data from the file and make the adapter adapt := dpll.NewAdapter(json, chooseOnce, extraStats) // Use the adapter to set the initial state b := dpll.NewBrancher() adapt.Reconfigure(cdb, b, manage) g := dpll.Dpll(cdb, a, b, manage, adapt) printResults(g, cdb, adapt, !quiet) }
func runBench(file string, b dpll.BranchRule, d db.ClauseDBMS) *guess.Guess { runtime.GOMAXPROCS(3) timeout := time.After(20 * time.Minute) // Prepare the specific run br := dpll.NewBrancher() br.SetRule(b) ma := db.NewManager() ma.SetStrat(d) // Initialize the cdb and assignment cdb, a, err := initSolver(file) if err != nil { log.Fatal(err) } // Set the proper max db size ma.MaxLearned = cdb.NGiven() / 3 g := dpll.DpllTimeout(cdb, a, br, ma, nil, timeout) return g }
func runAdaptiveBench(file string, jsonFile string, chooseOnce bool, extraStats bool) (*guess.Guess, *dpll.Adapter) { runtime.GOMAXPROCS(3) timeout := time.After(20 * time.Minute) // Initialize the cdb and assignment cdb, a, err := initSolver(file) if err != nil { log.Fatal(err) } // Set the proper max db size manage.MaxLearned = cdb.NGiven() / 3 // Read the data from the file and make the adapter adapt := dpll.NewAdapter(jsonFile, chooseOnce, extraStats) // Use the adapter to set the initial state b := dpll.NewBrancher() m := db.NewManager() adapt.Reconfigure(cdb, b, m) g := dpll.DpllTimeout(cdb, a, b, m, adapt, timeout) return g, adapt }
"time" ) // flags var ( seed int64 file string logFile string cpuprof string quiet bool analyze bool extraStats bool chooseOnce bool benchmark bool adaptive string branch *dpll.Brancher = dpll.NewBrancher() manage *db.Manager = db.NewManager() ) func main() { flag.Int64Var(&seed, "seed", time.Now().Unix(), "random number generator seed") flag.StringVar(&file, "file", "", "dimacs file containing formula") flag.StringVar(&logFile, "log", "", "Log output file") flag.StringVar(&cpuprof, "cpuprofile", "", "write cpu profile to file") flag.BoolVar(&quiet, "q", false, "True for quiet output. States \"SAT\" or \"UNSAT\"") flag.BoolVar(&analyze, "e", false, "True for examination output. If true, will not actually run solver.") flag.BoolVar(&benchmark, "b", false, "True for benchmark output.") flag.BoolVar(&extraStats, "s", false, "True for extra statistics.") flag.BoolVar(&chooseOnce, "c", false, "True for choosing once, then not adapting.") flag.StringVar(&adaptive, "a", "", "Path to analysis json file. Enables adaptive solving")