Example #1
0
    def test_generator(self):
        periods = tg.uniform_int(10, 100)
        utils = tg.exponential(0.1, 0.9, 0.3)
        g = tg.TaskGenerator(periods, utils)

        self.assertEqual(len(list(g.tasks(max_tasks=10))), 10)
        self.assertLessEqual(len(list(g.tasks(max_util=10))), 100)

        ts1 = g.tasks(max_util=10, squeeze=True, time_conversion=ms2us)
        ts2 = g.tasks(max_util=10, squeeze=False, time_conversion=ms2us)

        self.assertAlmostEqual(sum([t.utilization() for t in ts1]), 10, places=2)
        self.assertNotEqual(sum([t.utilization() for t in ts2]), 10)
Example #2
0
    def test_task_system_creation(self):
        periods = tg.uniform_int(10, 100)
        utils = tg.exponential(0.1, 0.9, 0.3)
        g = tg.TaskGenerator(periods, utils)

        self.assertEqual(len(g.make_task_set(max_tasks=10)), 10)
        self.assertLessEqual(len((g.make_task_set(max_util=10))), 100)

        ts1 = g.make_task_set(max_util=10, squeeze=True, time_conversion=ms2us)
        ts2 = g.make_task_set(max_util=10, squeeze=False, time_conversion=ms2us)

        self.assertAlmostEqual(ts1.utilization(), 10, places=2)
        # Not strictly impossible, but very unlikely
        self.assertNotEqual(ts2.utilization(), 10)
Example #3
0
    def test_generator(self):
        periods = tg.uniform_int(10, 100)
        utils = tg.exponential(0.1, 0.9, 0.3)
        g = tg.TaskGenerator(periods, utils)

        self.assertEqual(len(list(g.tasks(max_tasks=10))), 10)
        self.assertLessEqual(len(list(g.tasks(max_util=10))), 100)

        ts1 = g.tasks(max_util=10, squeeze=True, time_conversion=ms2us)
        ts2 = g.tasks(max_util=10, squeeze=False, time_conversion=ms2us)

        self.assertAlmostEqual(sum([t.utilization() for t in ts1]),
                               10,
                               places=2)
        self.assertNotEqual(sum([t.utilization() for t in ts2]), 10)
Example #4
0
    def test_drawing_functions(self):
        f = tg.uniform_int(10, 100)
        self.assertTrue(type(f()) == int)
        self.assertTrue(10 <= f() <= 100)

        f = tg.uniform(10, 100)
        self.assertTrue(type(f()) == float)
        self.assertTrue(10 <= f() <= 100)

        f = tg.uniform_choice("abcdefg")
        self.assertTrue(type(f()) == str)
        self.assertTrue("a" <= f() <= "g")

        f = tg.exponential(0.1, 0.7, 0.4)
        self.assertTrue(type(f()) == float)
        self.assertTrue(0.1 <= f() <= 0.7)
Example #5
0
    def test_drawing_functions(self):
        f = tg.uniform_int(10, 100)
        self.assertTrue(type(f()) == int)
        self.assertTrue(10 <= f() <= 100)

        f = tg.uniform(10, 100)
        self.assertTrue(type(f()) == float)
        self.assertTrue(10 <= f() <= 100)

        f = tg.uniform_choice("abcdefg")
        self.assertTrue(type(f()) == str)
        self.assertTrue('a' <= f() <= 'g')

        f = tg.exponential(0.1, 0.7, 0.4)
        self.assertTrue(type(f()) == float)
        self.assertTrue(0.1 <= f() <= 0.7)
Example #6
0
    def test_task_system_creation(self):
        periods = tg.uniform_int(10, 100)
        utils = tg.exponential(0.1, 0.9, 0.3)
        g = tg.TaskGenerator(periods, utils)

        self.assertEqual(len(g.make_task_set(max_tasks=10)), 10)
        self.assertLessEqual(len((g.make_task_set(max_util=10))), 100)

        ts1 = g.make_task_set(max_util=10, squeeze=True, time_conversion=ms2us)
        ts2 = g.make_task_set(max_util=10,
                              squeeze=False,
                              time_conversion=ms2us)

        self.assertAlmostEqual(ts1.utilization(), 10, places=2)
        # Not strictly impossible, but very unlikely
        self.assertNotEqual(ts2.utilization(), 10)
Example #7
0
    'uni-short'     : gen.uniform_int( 3,  33),
    'uni-moderate'  : gen.uniform_int(10, 100),
    'uni-long'      : gen.uniform_int(50, 250),

    'log-uni-short'     : gen.log_uniform_int( 3,  33),
    'log-uni-moderate'  : gen.log_uniform_int(10, 100),
    'log-uni-long'      : gen.log_uniform_int(50, 250),
    }

NAMED_UTILIZATIONS = {
# Named utilization distributions used in several UNC papers, in milliseconds.
    'uni-light'     : gen.uniform(0.001, 0.1),
    'uni-medium'    : gen.uniform(0.1  , 0.4),
    'uni-heavy'     : gen.uniform(0.5  , 0.9),

    'exp-light'     : gen.exponential(0, 1, 0.10),
    'exp-medium'    : gen.exponential(0, 1, 0.25),
    'exp-heavy'     : gen.exponential(0, 1, 0.50),

    'bimo-light'    : gen.multimodal([(gen.uniform(0.001, 0.5), 8),
                                      (gen.uniform(0.5  , 0.9), 1)]),
    'bimo-medium'   : gen.multimodal([(gen.uniform(0.001, 0.5), 6),
                                      (gen.uniform(0.5  , 0.9), 3)]),
    'bimo-heavy'    : gen.multimodal([(gen.uniform(0.001, 0.5), 4),
                                      (gen.uniform(0.5  , 0.9), 5)]),
}

def uniform_slack(min_slack_ratio, max_slack_ratio):
    """Choose deadlines uniformly such that the slack
       is within [cost + min_slack_ratio * (period - cost),
                  cost + max_slack_ratio * (period - cost)].
Example #8
0
    # Named period distributions used in several UNC papers, in milliseconds.
    'uni-short': gen.uniform_int(3, 33),
    'uni-moderate': gen.uniform_int(10, 100),
    'uni-long': gen.uniform_int(50, 250),
}

NAMED_UTILIZATIONS = {
    # Named utilization distributions used in several UNC papers, in milliseconds.
    'uni-light':
    gen.uniform(0.001, 0.1),
    'uni-medium':
    gen.uniform(0.1, 0.4),
    'uni-heavy':
    gen.uniform(0.5, 0.9),
    'exp-light':
    gen.exponential(0, 1, 0.10),
    'exp-medium':
    gen.exponential(0, 1, 0.25),
    'exp-heavy':
    gen.exponential(0, 1, 0.50),
    'bimo-light':
    gen.multimodal([(gen.uniform(0.001, 0.5), 8), (gen.uniform(0.5, 0.9), 1)]),
    'bimo-medium':
    gen.multimodal([(gen.uniform(0.001, 0.5), 6), (gen.uniform(0.5, 0.9), 3)]),
    'bimo-heavy':
    gen.multimodal([(gen.uniform(0.001, 0.5), 4), (gen.uniform(0.5, 0.9), 5)]),
}


def uniform_slack(min_slack_ratio, max_slack_ratio):
    """Choose deadlines uniformly such that the slack