def yield_runs(): # build solvers and train / test sets if live: domain = borg.get_domain(domain_name) else: domain = FakeDomain(borg.get_domain(domain_name)) paths = list(cargo.files_under(tasks_root, domain.extensions)) examples = int(round(len(paths) * 0.50)) logger.info("found %i tasks", len(paths)) if tests_root is not None: tests_root_paths = list(cargo.files_under(tests_root, domain.extensions)) # build validation runs for _ in xrange(runs): split = uuid.uuid4() shuffled = sorted(paths, key = lambda _ : numpy.random.rand()) train_paths = shuffled[:examples] if tests_root is None: test_paths = shuffled[examples:] else: test_paths = tests_root_paths for name in borg.portfolios.named: yield (run_validation, [name, domain, train_paths, test_paths, budget, split])
def __call__(self, task, stm_queue=None, solver_id=None): try: cnf_path = task.support_paths.get("cnf-g") if cnf_path is None: (fd, cnf_path) = tempfile.mkstemp(suffix=".cnf") task.support_paths["cnf-g"] = cnf_path with contextlib.closing(os.fdopen(fd)) as cnf_file: with open(task.path, "rb") as asp_file: borg.domains.asp.run_lp2sat(self._domain.binaries_path, asp_file, cnf_file) except borg.domains.asp.LP2SAT_FailedException: return borg.solver_io.EmptySolver(None) else: with borg.get_domain("sat").task_from_path(cnf_path) as sat_task: return self._sat_factory(sat_task)
def yield_runs(): if os.path.exists(domain_name): domain = borg.load_solvers(domain_name).domain else: domain = borg.get_domain(domain_name) paths = list(borg.util.files_under(instances_root, domain.extensions)) count = 0 for path in paths: if skip_existing and os.path.exists(path + suffix): continue count += 1 yield (features_for_path, [domain, path]) logger.info("collecting features for %i instances", count)
def yield_runs(): domain = borg.get_domain(domain_name) paths = list(cargo.files_under(tasks_root, domain.extensions)) for path in paths: yield (features_for_path, [domain, path])