def build_planning_exp(): parser = experiments.ExpArgParser() parser.add_argument("-s", "--suite", default=[], required=True, nargs='+', help="tasks, domains or suites") exp = experiments.build_experiment(parser) problems = downward_suites.build_suite(exp.suite) for opt in optimizations: planner_name = 'downward-' + opt planner = os.path.join(main_dir, opt, planner_name) planner_var = 'PLANNER_' + opt exp.add_resource(planner_var, planner, planner_name) for config_name, config in configs: for problem in problems: run = exp.add_run() run.require_resource(planner_var) domain_file = problem.domain_file() problem_file = problem.problem_file() run.add_resource("DOMAIN", domain_file, "domain.pddl") run.add_resource("PROBLEM", problem_file, "problem.pddl") translator_path = os.path.abspath( '../downward/translate/translate.py') assert os.path.exists(translator_path) translate_cmd = '%s %s %s' % (translator_path, domain_file, problem_file) preprocessor_path = '../downward/preprocess/preprocess' preprocessor_path = os.path.abspath(preprocessor_path) assert os.path.exists(preprocessor_path) preprocess_cmd = '%s < %s' % (preprocessor_path, 'output.sas') run.set_preprocess('%s; %s' % (translate_cmd, preprocess_cmd)) run.set_command("$%s %s < output" % (planner_var, config)) run.declare_optional_output("*.groups") run.declare_optional_output("output") run.declare_optional_output("output.sas") run.declare_optional_output("sas_plan") ext_config = opt + '-' + config_name run.set_property('opt', opt) run.set_property('config', ext_config) run.set_property('domain', problem.domain) run.set_property('problem', problem.problem) run.set_property('id', [ext_config, problem.domain, problem.problem]) return exp
def __init__(self, combinations, parser=None): self.combinations = combinations parser = parser or experiments.ExpArgParser() parser.add_argument("--preprocess", action="store_true", help="build preprocessing experiment") parser.add_argument("--complete", action="store_true", help="build complete experiment (overrides -p)") compact_help = ( "link to preprocessing files instead of copying them. " "Only use this option if the preprocessed files will " "NOT be changed during the experiment. This option " "only has an effect if neither --preprocess nor " "--complete are set." ) parser.add_argument("--compact", action="store_true", help=compact_help) parser.add_argument("-s", "--suite", default=[], type=tools.csv, required=True, help=downward_suites.HELP) parser.add_argument( "-c", "--configs", default=[], type=tools.csv, required=False, dest="config_nicks", help=downward_configs.HELP, ) experiments.Experiment.__init__(self, parser) config_needed = self.complete or not self.preprocess if config_needed and not self.config_nicks: logging.error("Please specify at least one planner configuration") sys.exit(2) # Save if this is a compact experiment i.e. preprocess files are copied compact = self.compact and not self.preprocess and not self.complete self.set_property("compact", compact) checkouts.checkout(combinations) checkouts.compile(combinations) # require_src_dirs(self, combinations) self.problems = downward_suites.build_suite(self.suite) self.configs = _get_configs(self.config_nicks) self.make_runs()
def build_experiment(): parser = experiments.ExpArgParser() parser.add_argument('-p', '--package', required=True, help="planner package (tar.gz)") version_help = "planner version (e.g. seq-opt-bjolp); " version_help += "required if several versions are included in the package" parser.add_argument('-v', '--version', default=None, help=version_help) parser.add_argument('-s', '--suite', default=[], type=tools.csv, required=True, help=downward_suites.HELP) exp = experiments.build_experiment(parser) problems = downward_suites.build_suite(exp.suite) planner_dir_from = None try: planner_dir_from = prepare_planner(exp, compile_m32=False) # planner_dir_from = prepare_planner(exp, compile_m32=True) # planner_dir_from = reuse_planner(exp) except Exception, err: raise SystemExit('Error: Could not prepare planner: %s' % err)
def __init__(self, parser=ReportArgParser(parents=[report_type_parser])): parser.add_argument('-c', '--configs', type=tools.csv, help='only use specified configurations (e.g. WORK-ou,WORK-yY). ' 'If none specified, use all found configs') parser.add_argument('-s', '--suite', type=tools.csv, help=downward_suites.HELP) Report.__init__(self, parser) if self.configs: self.name_parts.append('+'.join(self.configs)) if self.suite: self.name_parts.append('+'.join(self.suite)) if self.suite: self.problems = downward_suites.build_suite(self.suite) else: self.problems = [] def filter_by_problem(run): """ If suite is set, only process problems from the suite, otherwise process all problems """ return any(prob.domain == run['domain'] and prob.problem == run['problem'] for prob in self.problems) def filter_by_config(run): """ If configs is set, only process those configs, otherwise process all configs """ return any(config == run['config'] for config in self.configs) filter_funcs = [] if self.configs: filter_funcs.append(filter_by_config) if self.problems: filter_funcs.append(filter_by_problem) if filter_funcs: self.data.filter(*filter_funcs)
def __init__(self, parser=ReportArgParser(parents=[report_type_parser])): parser.add_argument( '-c', '--configs', nargs='*', default=[], help= 'planner configurations (if none specified, use all found configs)' ) parser.add_argument( '-s', '--suite', nargs='*', default=[], help='tasks, domains or suites (if none specified, use whole suite)' ) parser.add_argument('--res', default='domain', dest='resolution', help='resolution of the report', choices=['suite', 'domain', 'problem']) parser.add_argument('--filter', nargs='*', default=[], help='filters will be applied as follows: ' \ 'expanded:lt:100 -> only process if run[expanded] < 100') Report.__init__(self, parser) self.focus = None self.output = '' # For some attributes only compare commonly solved tasks self.commonly_solved_foci = [ 'expanded', 'generated', 'plan_length', 'search_time', 'total_time' ] info = 'Report only commonly solved problems for %s' info %= self.commonly_solved_foci self.add_info(info) self.problems = downward_suites.build_suite(self.suite) def filter_by_problem(run): """ If suite is set, only process problems from the suite, otherwise process all problems """ if not self.problems: return True for problem in self.problems: if problem.domain == run['domain'] and problem.problem == run[ 'problem']: return True return False def filter_by_config(run): """ If configs is set, only process those configs, otherwise process all configs """ if not self.configs: return True for config in self.configs: if config == run['config']: return True return False self.add_filter(filter_by_problem, filter_by_config) self.parse_filters()
def build_experiment(): # Factory for experiments. # # Parses cmd-line options to decide whether this is a gkigrid # experiment or a local experiment. # NOTE: All parameters are given to the experiment instance exp = experiments.build_experiment(parser=downward_configs.get_dw_parser()) # Includes a "global" file, i.e., one needed for all runs, into the # experiment archive. In case of GkiGridExperiment, copies it to the # main directory of the experiment. The name "PLANNER" is an ID for # this resource that can also be used to refer to it in shell scripts. exp.add_resource("PLANNER", "../downward/search/downward", "downward") problems = downward_suites.build_suite(exp.suite) configs = downward_configs.get_configs(exp.configs) for problem in problems: for config_name, config_string in configs: # Adds a new run to the experiment and returns it run = exp.add_run() # Make the planner resource available for this run. # In environments like the argo cluster, this implies # copying the planner into each task. For the gkigrid, we merely # need to set up the PLANNER environment variable. run.require_resource('PLANNER') domain_file = problem.domain_file() problem_file = problem.problem_file() # Copy "../benchmarks/domain/domain.pddl" into the run # directory under name "domain.pddl" and make it available as # resource "DOMAIN" (usable as environment variable $DOMAIN). run.add_resource('DOMAIN', domain_file, 'domain.pddl') run.add_resource('PROBLEM', problem_file, 'problem.pddl') translator_path = '../downward/translate/translate.py' translator_path = os.path.abspath(translator_path) translate_cmd = '%s %s %s' % (translator_path, domain_file, problem_file) preprocessor_path = '../downward/preprocess/preprocess' preprocessor_path = os.path.abspath(preprocessor_path) preprocess_cmd = '%s < %s' % (preprocessor_path, 'output.sas') # Optionally, can use run.set_preprocess() and # run.set_postprocess() to specify code that should be run # before the main command, i.e., outside the part for which we # restrict runtime and memory. For example, post-processing # could be used to rename result files or zipping them up. The # postprocessing code can find out whether the command succeeded # or was aborted via the environment variable $RETURNCODE run.set_preprocess('%s; %s' % (translate_cmd, preprocess_cmd)) # A bash fragment that gives the code to be run when invoking # this job. run.set_command("$PLANNER %s < output" % config_string) # Specifies that all files names "plan.soln*" (using # shell-style glob patterns) are part of the experiment output. # There's a corresponding declare_required_output for output # files that must be present at the end or we have an error. A # specification like this is e.g. necessary for the Argo # cluster. On the gkigrid, this wouldn't do anything, although # the declared outputs are stored so that we # can later verify that all went according to plan. run.declare_optional_output('*.groups') run.declare_optional_output('output') run.declare_optional_output('output.sas') run.declare_optional_output('sas_plan') # Set some properties to be able to analyze the run correctly # The properties are written into the "properties" file run.set_property('config', config_name) run.set_property('domain', problem.domain) run.set_property('problem', problem.problem) # The run's id determines the directory it will be copied to # by resultfetcher run.set_property('id', [config_name, problem.domain, problem.problem]) # Actually write and copy all the files exp.build()