Esempio n. 1
0
    def test_get_next_challenger_repeat(self):
        """
            test get_next_challenger - repeat configurations
        """
        intensifier = AbstractRacer(tae_runner=None,
                                    stats=self.stats,
                                    traj_logger=None,
                                    rng=np.random.RandomState(12345),
                                    deterministic=True,
                                    run_obj_time=False,
                                    cutoff=1,
                                    instances=[1])

        # should not repeat configurations
        self.rh.add(self.config1, 1, 1, StatusType.SUCCESS)
        config, _ = intensifier.get_next_challenger(
            challengers=[self.config1, self.config2],
            chooser=None,
            run_history=self.rh,
            repeat_configs=False)

        self.assertEqual(config, self.config2)

        # should repeat configurations
        config, _ = intensifier.get_next_challenger(
            challengers=[self.config1, self.config2],
            chooser=None,
            run_history=self.rh,
            repeat_configs=True)

        self.assertEqual(config, self.config1)
Esempio n. 2
0
    def test_get_next_challenger(self):
        """
            test get_next_challenger - pick from list/chooser
        """
        intensifier = AbstractRacer(tae_runner=None,
                                    stats=self.stats,
                                    traj_logger=None,
                                    rng=np.random.RandomState(12345),
                                    deterministic=True,
                                    run_obj_time=False,
                                    cutoff=1,
                                    instances=[1])

        # Error when nothing to choose from
        with self.assertRaisesRegex(ValueError,
                                    "No configurations/chooser provided"):
            intensifier.get_next_challenger(challengers=None,
                                            chooser=None,
                                            run_history=self.rh)

        # next challenger from a list
        config, _ = intensifier.get_next_challenger(
            challengers=[self.config1, self.config2],
            chooser=None,
            run_history=self.rh)
        self.assertEqual(config, self.config1)

        config, _ = intensifier.get_next_challenger(
            challengers=[self.config2, self.config3],
            chooser=None,
            run_history=self.rh)
        self.assertEqual(config, self.config2)

        # next challenger from a chooser
        intensifier = AbstractRacer(tae_runner=None,
                                    stats=self.stats,
                                    traj_logger=None,
                                    rng=np.random.RandomState(12345),
                                    deterministic=True,
                                    run_obj_time=False,
                                    cutoff=1,
                                    instances=[1])
        chooser = SMAC4AC(self.scen, rng=1).solver.epm_chooser

        config, _ = intensifier.get_next_challenger(challengers=None,
                                                    chooser=chooser,
                                                    run_history=self.rh)
        self.assertEqual(len(list(config.get_dictionary().values())), 2)
        self.assertTrue(24 in config.get_dictionary().values())
        self.assertTrue(68 in config.get_dictionary().values())

        config, _ = intensifier.get_next_challenger(challengers=None,
                                                    chooser=chooser,
                                                    run_history=self.rh)
        self.assertEqual(len(list(config.get_dictionary().values())), 2)
        self.assertTrue(95 in config.get_dictionary().values())
        self.assertTrue(38 in config.get_dictionary().values())