Ejemplo n.º 1
0
    def test_sets_intervals(self):
        test_model = uc.ucModel('test1', test1_path)
        test_model.arrange_data()

        result = test_model.sets['intervals'].indices
        expected_set = list(range(48))
        self.assertEqual(result, expected_set)
Ejemplo n.º 2
0
 def test_initial_state_commit_is_wrong_3(self):
     test_model = uc.ucModel('test1', test1_path)
     test_model.arrange_data()
     test_model.data.initial_state['NumCommited']['Coal1'] = 0.3
     test_model.data.validate_initial_state_data(test_model.sets)
     result = test_model.data.initial_state['NumCommited']['Coal1']
     self.assertEqual(result, 0)
Ejemplo n.º 3
0
    def test_settings_loaded(self):
        test_model = uc.ucModel('test1', test1_path)
        val = test_model.settings['OUTPUTS_PATH']

        expected_path = os.path.abspath(
            os.path.join(os.sep, 'Users', 'danie', 'Documents', 'denki-uc',
                         'test', 'outputs'))

        self.assertEqual(val, expected_path)
Ejemplo n.º 4
0
 def test_arma_demand(self):
     test_model = uc.ucModel('test1', test1_path)
     test_model.arrange_data()
     scenarios = test_model.sets['scenarios']
     scenarios.indices = list(range(5))
     test_model.data.add_arma_scenarios(scenarios, random_seed=12)
     result = \
         (
          round(test_model.data.traces['demand'][(3, 'Demand')][12], 3),
          round(test_model.data.traces['wind'][(2, 'Wind')][21], 3),
          round(test_model.data.traces['solarPV'][(1, 'Solar')][37], 3),
         )
     self.assertEqual(result, (2393.924, 0.442, 0))
Ejemplo n.º 5
0
    def solve_day(self):
        day_model = uc.ucModel(self.name, self.input_path)
        day_model.arrange_data()
        day_model.solve()

        self.days_status = dict()
        self.days_status['OptimalityStatus'] = day_model.optimality_status
        self.days_status['ObjFnVal'] = day_model.opt_fn_value
        self.days_status['SolverTime'] = day_model.solver_time

        time_end_day = time.perf_counter()
        self.days_status['TotalRunTime'] = time_end_day - self.time_start_day
        exit()
Ejemplo n.º 6
0
    def test_too_large_intermittent_trace(self):
        test_model = uc.ucModel('test1', test1_path)
        test_model.arrange_data()
        scenarios = test_model.sets['scenarios']
        scenarios.indices = list(range(2))

        test_model.data.orig_traces['wind']['Wind'][12] = 5000
        test_model.data.orig_traces['solarPV']['Solar'][12] = 5000
        test_model.data.orig_traces['demand']['Demand'][12] = 5000

        test_model.data.add_arma_scenarios(scenarios, random_seed=5)

        result = (round(test_model.data.traces['demand'][(1, 'Demand')][12]),
                  test_model.data.traces['wind'][(1, 'Wind')][12],
                  test_model.data.traces['solarPV'][(1, 'Solar')][12])
        self.assertEqual(result, (4821, 1, 1))
Ejemplo n.º 7
0
    def test_negative_trace(self):
        test_model = uc.ucModel('test1', test1_path)
        test_model.arrange_data()
        scenarios = test_model.sets['scenarios']
        scenarios.indices = list(range(2))

        test_model.data.orig_traces['demand']['Demand'][12] = -5000
        test_model.data.orig_traces['wind']['Wind'][12] = -5000
        test_model.data.orig_traces['solarPV']['Solar'][12] = -5000

        test_model.data.add_arma_scenarios(scenarios, random_seed=5)

        result = (test_model.data.traces['demand'][(1, 'Demand')][12],
                  test_model.data.traces['wind'][(1, 'Wind')][12],
                  test_model.data.traces['solarPV'][(1, 'Solar')][12])

        self.assertEqual(result, (0, 0, 0))
Ejemplo n.º 8
0
 def test_initial_state_is_loaded(self):
     test_model = uc.ucModel('test1', test1_path)
     test_model.arrange_data()
     val = test_model.data.initial_state['PowerGeneration_MW']['Coal1']
     self.assertEqual(val, 300)
Ejemplo n.º 9
0
 def test_look_ahead_intervals_correct(self):
     test_model = uc.ucModel('test1', test1_path)
     test_model.arrange_data()
     actual_result = test_model.sets['look_ahead_intervals'].indices
     expected_set = list(range(28, 48))
     self.assertEqual(expected_set, actual_result)
Ejemplo n.º 10
0
    def test_name_is_set(self):
        name = 'hello'
        path = 'goodbye'

        test_model = uc.ucModel(name, path)
        self.assertEqual(test_model.name, name)
Ejemplo n.º 11
0
 def test_sets_storage(self):
     test_model = uc.ucModel('test1', test1_path)
     test_model.arrange_data()
     result = test_model.sets['units_storage'].indices
     expected_set = ['Battery1']
     self.assertEqual(result, expected_set)
Ejemplo n.º 12
0
 def test_sets_variable(self):
     test_model = uc.ucModel('test1', test1_path)
     test_model.arrange_data()
     result = test_model.sets['units_variable'].indices
     expected_set = ['SolarPV1', 'Wind1']
     self.assertEqual(result, expected_set)
Ejemplo n.º 13
0
 def test_sets_commit(self):
     test_model = uc.ucModel('test1', test1_path)
     test_model.arrange_data()
     result = test_model.sets['units_commit'].indices
     expected_set = ['Coal1', 'Coal2', 'Gas1', 'Gas2']
     self.assertEqual(result, expected_set)
Ejemplo n.º 14
0
import denkiuc.uc_model as uc
import os

path_to_test1 = os.path.join(uc.path_to_examples, 'test1')
test_model = uc.ucModel('test1', path_to_test1)
test_model.arrange_data()
test_model.solve()
Ejemplo n.º 15
0
import denkiuc.uc_model as uc
import os
import unittest
import denkiuc.sanity_check_solution as scs

test1_path = os.path.join(uc.path_to_tests, 'test1')
tM = uc.ucModel('test1', test1_path)
tM.data.units.loc['Coal1', 'NoUnits'] = 5
tM.arrange_data()
tM.solve()


class economic_dispatch_sanity_checks(unittest.TestCase):
    def test_power_lt_capacity_no_error(self):
        for u in tM.sets['units'].indices:
            units_capacity = \
                tM.data.units['Capacity_MW'][u] * tM.data.units['NoUnits'][u]

            for i in tM.sets['intervals'].indices:
                for s in tM.sets['scenarios'].indices:

                    tM.results['power_generated'].loc[i, (s, u)] = \
                        units_capacity * 1

        test_result = \
            scs.check_power_lt_capacity(tM.sets, tM.data, tM.results)

        self.assertEqual(test_result, 0)

    def test_power_lt_capacity_error(self):
        counter = 0
Ejemplo n.º 16
0
 def test_traces_are_loaded(self):
     test_model = uc.ucModel('test1', test1_path)
     test_model.arrange_data()
     val = test_model.data.traces['demand'][(0, 'Demand')][0]
     self.assertEqual(val, 1000)
Ejemplo n.º 17
0
 def test_unit_data_is_loaded(self):
     test_model = uc.ucModel('test1', test1_path)
     test_model.arrange_data()
     val = test_model.data.units['Capacity_MW']['Coal1']
     self.assertEqual(val, 510)
Ejemplo n.º 18
0
    def test_inputs_path_is_set(self):
        name = 'hello'
        path = 'goodbye'

        test_model = uc.ucModel(name, path)
        self.assertEqual(test_model.path_to_inputs, path)