Esempio n. 1
0
 def test_init_state(self):
     state = c.init_state(100, [20, 40], 2)
     self.assertEquals(state['previous_state'], 0)
     self.assertEquals(state['previous_utilization'], [])
     self.assertEquals(state['time_in_states'], 0)
     self.assertEquals(state['time_in_state_n'], 0)
     self.assertTrue('request_windows' in state)
     self.assertTrue('estimate_windows' in state)
     self.assertTrue('variances' in state)
     self.assertTrue('acceptable_variances' in state)
Esempio n. 2
0
 def test_init_state(self):
     state = c.init_state(100, [20, 40], 2)
     self.assertEquals(state['previous_state'], 0)
     self.assertEquals(state['previous_utilization'], [])
     self.assertEquals(state['time_in_states'], 0)
     self.assertEquals(state['time_in_state_n'], 0)
     self.assertTrue('request_windows' in state)
     self.assertTrue('estimate_windows' in state)
     self.assertTrue('variances' in state)
     self.assertTrue('acceptable_variances' in state)
Esempio n. 3
0
    def test_mhod(self):
        state_config = [1.0]
        otf = 0.1
        window_sizes = [30, 40]
        bruteforce_step = 0.5
        learning_steps = 0
        time_step = 300
        migration_time = 20.
        utilization = [1.0]
        state = c.init_state(10, window_sizes, 2)

        with MockTransaction:
            state['previous_utilization'] = []
            expect(estimation).select_best_estimates.and_return([[0., 0.],
                                                                 [0., 0.]])
            expect(c).get_current_state.and_return(1).once()
            decision, _ = c.mhod(state_config, otf, window_sizes,
                                 bruteforce_step, learning_steps, time_step,
                                 migration_time, utilization, state)
            self.assertFalse(decision)

        with MockTransaction:
            state['previous_utilization'] = []
            expect(estimation).select_best_estimates.and_return([[0., 0.],
                                                                 [0., 0.]])
            expect(c).get_current_state.and_return(0).once()
            decision, _ = c.mhod(state_config, otf, window_sizes,
                                 bruteforce_step, learning_steps, time_step,
                                 migration_time, utilization, state)
            self.assertFalse(decision)

        with MockTransaction:
            state['previous_utilization'] = []
            expect(estimation).select_best_estimates.and_return([[0., 1.],
                                                                 [0., 1.]])
            expect(c).get_current_state.and_return(0).once()
            decision, _ = c.mhod(state_config, otf, window_sizes,
                                 bruteforce_step, learning_steps, time_step,
                                 migration_time, utilization, state)
            self.assertFalse(decision)

        with MockTransaction:
            state['previous_utilization'] = []
            expect(estimation).select_best_estimates.and_return([[0., 1.],
                                                                 [0., 1.]])
            expect(c).get_current_state.and_return(1).once()
            decision, _ = c.mhod(state_config, otf, window_sizes,
                                 bruteforce_step, learning_steps, time_step,
                                 migration_time, utilization, state)
            self.assertTrue(decision)
Esempio n. 4
0
    def test_mhod(self):
        state_config = [1.0]
        otf = 0.1
        window_sizes = [30, 40]
        bruteforce_step = 0.5
        learning_steps = 0
        time_step = 300
        migration_time = 20.
        utilization = [1.0]
        state = c.init_state(10, window_sizes, 2)

        with MockTransaction:
            state['previous_utilization'] = []
            expect(estimation).select_best_estimates.and_return([[0., 0.], [0., 0.]])
            expect(c).get_current_state.and_return(1).once()
            decision, _ = c.mhod(state_config, otf, window_sizes, bruteforce_step,
                                 learning_steps, time_step, migration_time, utilization, state)
            self.assertFalse(decision)

        with MockTransaction:
            state['previous_utilization'] = []
            expect(estimation).select_best_estimates.and_return([[0., 0.], [0., 0.]])
            expect(c).get_current_state.and_return(0).once()
            decision, _ = c.mhod(state_config, otf, window_sizes, bruteforce_step,
                                 learning_steps, time_step, migration_time, utilization, state)
            self.assertFalse(decision)

        with MockTransaction:
            state['previous_utilization'] = []
            expect(estimation).select_best_estimates.and_return([[0., 1.], [0., 1.]])
            expect(c).get_current_state.and_return(0).once()
            decision, _ = c.mhod(state_config, otf, window_sizes, bruteforce_step,
                                 learning_steps, time_step, migration_time, utilization, state)
            self.assertFalse(decision)

        with MockTransaction:
            state['previous_utilization'] = []
            expect(estimation).select_best_estimates.and_return([[0., 1.], [0., 1.]])
            expect(c).get_current_state.and_return(1).once()
            decision, _ = c.mhod(state_config, otf, window_sizes, bruteforce_step,
                                 learning_steps, time_step, migration_time, utilization, state)
            self.assertTrue(decision)