Пример #1
0
    def test_score_with_weights(self):
        axl.seed(0)
        opponents_information = [
            utils.PlayerInfo(s, {}) for s in axl.demo_strategies
        ]
        objective = utils.prepare_objective()
        params = DummyParams()
        score = utils.score_params(
            params,
            objective=objective,
            opponents_information=opponents_information,
            # All weight on Coop
            weights=[1, 0, 0, 0, 0])
        expected_score = 3
        self.assertEqual(score, expected_score)

        score = utils.score_params(
            params,
            objective=objective,
            opponents_information=opponents_information,
            # Shared weight between Coop and Def
            weights=[2, 2, 0, 0, 0])
        expected_score = 1.5
        self.assertEqual(score, expected_score)

        score = utils.score_params(
            params,
            objective=objective,
            opponents_information=opponents_information,
            # Shared weight between Coop and Def
            weights=[2, -.5, 0, 0, 0])
        expected_score = 4.0
        self.assertEqual(score, expected_score)
Пример #2
0
    def test_score_with_weights(self):
        axl.seed(0)
        opponents_information = [utils.PlayerInfo(s, {})
                                 for s in axl.demo_strategies]
        objective = utils.prepare_objective()
        params = DummyParams()
        score = utils.score_params(params,
                                   objective=objective,
                                   opponents_information=opponents_information,
                                   # All weight on Coop
                                   weights=[1, 0, 0, 0, 0])
        expected_score = 3
        self.assertEqual(score, expected_score)

        score = utils.score_params(params,
                                   objective=objective,
                                   opponents_information=opponents_information,
                                   # Shared weight between Coop and Def
                                   weights=[2, 2, 0, 0, 0])
        expected_score = 1.5
        self.assertEqual(score, expected_score)

        score = utils.score_params(params,
                                   objective=objective,
                                   opponents_information=opponents_information,
                                   # Shared weight between Coop and Def
                                   weights=[2, -.5, 0, 0, 0])
        expected_score = 4.0
        self.assertEqual(score, expected_score)
        def objective_function(vector):
            params.receive_vector(vector=vector)
            instance_generation_function = 'player'

            return - score_params(params=params, objective=self.objective,
                                  opponents_information=self.opponents_information,
                                  weights=self.weights,
                                  sample_count=self.sample_count,
                                  instance_generation_function=instance_generation_function
                                 )
Пример #4
0
    def test_with_init_kwargs(self):
        axl.seed(0)
        opponents_information = [utils.PlayerInfo(axl.Random, {"p": 0})]
        objective = utils.prepare_objective()
        params = DummyParams()
        score = utils.score_params(params,
                                   objective=objective,
                                   opponents_information=opponents_information)
        expected_score = 0
        self.assertEqual(score, expected_score)

        opponents_information = [utils.PlayerInfo(axl.Random, {"p": 1})]
        objective = utils.prepare_objective()
        params = DummyParams()
        score = utils.score_params(params,
                                   objective=objective,
                                   opponents_information=opponents_information)
        expected_score = 3.0
        self.assertEqual(score, expected_score)
Пример #5
0
    def test_with_init_kwargs(self):
        axl.seed(0)
        opponents_information = [utils.PlayerInfo(axl.Random, {"p": 0})]
        objective = utils.prepare_objective()
        params = DummyParams()
        score = utils.score_params(params,
                                   objective=objective,
                                   opponents_information=opponents_information)
        expected_score = 0
        self.assertEqual(score, expected_score)

        opponents_information = [utils.PlayerInfo(axl.Random, {"p": 1})]
        objective = utils.prepare_objective()
        params = DummyParams()
        score = utils.score_params(params,
                                   objective=objective,
                                   opponents_information=opponents_information)
        expected_score = 3.0
        self.assertEqual(score, expected_score)
Пример #6
0
 def test_score(self):
     axl.seed(0)
     opponents_information = [utils.PlayerInfo(s, {})
                              for s in axl.demo_strategies]
     objective = utils.prepare_objective()
     params = DummyParams()
     score = utils.score_params(params,
                                objective=objective,
                                opponents_information=opponents_information)
     expected_score = 2.0949
     self.assertEqual(score, expected_score)