示例#1
0
    def test_status(self):

        scen = Scenario(scenario={
            'cs': ConfigurationSpace(),
            'run_obj': 'quality',
            'output_dir': ''
        },
                        cmd_options=None)
        stats = Stats(scen)

        eta = ExecuteTARunAClib(ta=shlex.split(""), stats=stats)

        def test_success(**kwargs):
            results = {"status": "SUCCESS", "cost": 1234567890}
            return results, "", ""

        eta._call_ta = test_success
        status, cost, runtime, ar_info = eta.run(config={}, instance='0')
        self.assertEqual(status, StatusType.SUCCESS)

        def test_success(**kwargs):
            results = {"status": "SUCESS", "cost": 1234567890}
            return results, "", ""

        eta._call_ta = test_success
        status, cost, runtime, ar_info = eta.run(config={}, instance='0')
        self.assertEqual(status, StatusType.CRASHED)

        def test_success(**kwargs):
            results = {"status": "success", "cost": 1234567890}
            return results, "", ""

        eta._call_ta = test_success
        status, cost, runtime, ar_info = eta.run(config={}, instance='0')
        self.assertEqual(status, StatusType.CRASHED)
    def __init__(self,
                 cost_oracle: typing.Mapping[str, float],
                 tae: typing.Type[SerialRunner] = ExecuteTARunOld,
                 **kwargs: typing.Any) -> None:
        '''
            Constructor

            Arguments
            ---------
            cost_oracle: typing.Mapping[str,float]
                cost of oracle per instance
        '''

        super().__init__(**kwargs)
        self.cost_oracle = cost_oracle
        if tae is ExecuteTARunAClib:
            self.runner = ExecuteTARunAClib(**kwargs)  # type: SerialRunner
        elif tae is ExecuteTARunOld:
            self.runner = ExecuteTARunOld(**kwargs)
        elif tae is ExecuteTAFuncDict:
            self.runner = ExecuteTAFuncDict(**kwargs)
        elif tae is ExecuteTAFuncArray:
            self.runner = ExecuteTAFuncArray(**kwargs)
        else:
            raise Exception('TAE not supported')
示例#3
0
    def test_run(self):
        '''
            running some simple algo in aclib 2.0 style
        '''
        scen = Scenario(scenario={
            'cs': ConfigurationSpace(),
            'run_obj': 'quality',
            'output_dir': ''
        },
                        cmd_options=None)
        stats = Stats(scen)

        eta = ExecuteTARunAClib(
            ta=shlex.split("python test/test_tae/dummy_ta_wrapper_aclib.py 1"),
            stats=stats)
        status, cost, runtime, ar_info = eta.run(config={}, instance='0')
        assert status == StatusType.TIMEOUT
        assert cost == 2.0
        assert runtime == 2.0

        print(status, cost, runtime)

        eta = ExecuteTARunAClib(
            ta=shlex.split("python test/test_tae/dummy_ta_wrapper_aclib.py 2"),
            stats=stats)
        status, cost, runtime, ar_info = eta.run(config={}, instance='0')
        assert status == StatusType.SUCCESS
        assert cost == 3.0
        assert runtime == 3.0

        print(status, cost, runtime)

        eta = ExecuteTARunAClib(
            ta=shlex.split("python test/test_tae/dummy_ta_wrapper_aclib.py 2"),
            stats=stats,
            run_obj="quality")
        status, cost, runtime, ar_info = eta.run(config={}, instance='0')
        assert status == StatusType.SUCCESS
        assert cost == 2.0
        assert runtime == 3.0

        print(status, cost, runtime, ar_info)
示例#4
0
    def test_run(self):
        '''
            running some simple algo in aclib 2.0 style
        '''
        scen = Scenario(scenario={}, cmd_args=None)
        stats = Stats(scen)

        eta = ExecuteTARunAClib(
            ta=shlex.split("python test/test_tae/dummy_ta_wrapper_aclib.py 1"),
            stats=stats)
        status, cost, runtime, ar_info = eta.run(config={})
        assert status == StatusType.TIMEOUT
        assert cost == 2.0
        assert runtime == 2.0

        print(status, cost, runtime)

        eta = ExecuteTARunAClib(
            ta=shlex.split("python test/test_tae/dummy_ta_wrapper_aclib.py 2"),
            stats=stats)
        status, cost, runtime, ar_info = eta.run(config={})
        assert status == StatusType.SUCCESS
        assert cost == 3.0
        assert runtime == 3.0

        print(status, cost, runtime)

        eta = ExecuteTARunAClib(
            ta=shlex.split("python test/test_tae/dummy_ta_wrapper_aclib.py 2"),
            stats=stats,
            run_obj="quality")
        status, cost, runtime, ar_info = eta.run(config={}, )
        assert status == StatusType.SUCCESS
        assert cost == 2.0
        assert runtime == 3.0

        print(status, cost, runtime, ar_info)
示例#5
0
        logging.basicConfig(level=logging.INFO)
    else:
        logging.basicConfig(level=logging.DEBUG)

    scenario = Scenario(args_.scenario, cmd_options={'output_dir': ""})
    traj_logger = TrajLogger(None, Stats(scenario))
    trajectory = traj_logger.read_traj_aclib_format(args_.trajectory,
                                                    scenario.cs)
    if args_.tae == "old":
        tae = ExecuteTARunOld(ta=scenario.ta,
                              run_obj=scenario.run_obj,
                              par_factor=scenario.par_factor,
                              cost_for_crash=scenario.cost_for_crash)
    if args_.tae == "aclib":
        tae = ExecuteTARunAClib(ta=scenario.ta,
                                run_obj=scenario.run_obj,
                                par_factor=scenario.par_factor,
                                cost_for_crash=scenario.cost_for_crash)

    validator = Validator(scenario, trajectory, args_.seed)

    # Load runhistory
    if args_.runhistory:
        runhistory = RunHistory(average_cost)
        for rh_path in args_.runhistory:
            runhistory.update_from_json(rh_path, scenario.cs)
    else:
        runhistory = None

    if args_.epm:
        validator.validate_epm(config_mode=args_.configs,
                               instance_mode=args_.instances,