Ejemplo n.º 1
0
    def test_individual_component_stack_graph(self):
        """Tests stack graph generation when breaking out individual components per generation type."""
        current_dir = os.path.dirname(os.path.abspath(__file__))
        test_cases = [
            os.path.join(current_dir, '..', '..', 'models', 'tests',
                         'uc_test_instances', 'test_case_{}.json'.format(i))
            for i in range(1, 2)
        ]

        for test_case in test_cases:
            with open(test_case, 'r') as f:
                md_dict = json.load(f)
            md = ModelData(md_dict)

            solved_md = solve_unit_commitment(
                md,
                'cbc',
                mipgap=0.001,
                timelimit=None,
                solver_tee=True,
                symbolic_solver_labels=False,
                solver_options=None,
                uc_model_generator=create_tight_unit_commitment_model,
                relaxed=False,
                return_model=False)

            fig, ax = generate_stack_graph(
                solved_md,
                title=repr(test_case),
                show_individual_components=True,
                plot_individual_generators=False,
            )
Ejemplo n.º 2
0
    def test_individual_generator_stack_graph(self):
        """Tests stack graph generation when plotting individual generators."""
        current_dir = os.path.dirname(os.path.abspath(__file__))
        test_cases = [
            os.path.join(current_dir, '..', '..', 'models', 'tests',
                         'uc_test_instances', 'test_case_{}.json'.format(i))
            for i in range(1, 2)
        ]

        for test_case in test_cases:
            with open(test_case, 'r') as f:
                md_dict = json.load(f)
            md = ModelData(md_dict)

            solved_md = solve_unit_commitment(
                md,
                'cbc',
                mipgap=0.001,
                timelimit=None,
                solver_tee=True,
                symbolic_solver_labels=False,
                solver_options=None,
                uc_model_generator=create_tight_unit_commitment_model,
                relaxed=False,
                return_model=False)

            with self.assertRaises(ValueError):
                # The number of generators in the test case exceeds the maximum for this feature.
                fig, ax = generate_stack_graph(
                    solved_md,
                    title=repr(test_case),
                    show_individual_components=False,
                    plot_individual_generators=True,
                )
Ejemplo n.º 3
0
    def test_individual_generator_stack_graph_exception(self):
        """Tests for stack graph generation to fail when both 'show_individual_components' and 'plot_individual_generators' are simultaneously True."""
        current_dir = os.path.dirname(os.path.abspath(__file__))
        test_cases = [
            os.path.join(current_dir, '..', '..', 'models', 'tests',
                         'uc_test_instances', 'test_case_{}.json'.format(i))
            for i in range(1, 2)
        ]

        for test_case in test_cases:
            with open(test_case, 'r') as f:
                md_dict = json.load(f)
            md = ModelData(md_dict)

            solved_md = solve_unit_commitment(
                md,
                'cbc',
                mipgap=0.001,
                timelimit=None,
                solver_tee=True,
                symbolic_solver_labels=False,
                solver_options=None,
                uc_model_generator=create_tight_unit_commitment_model,
                relaxed=False,
                return_model=False)

            with self.assertRaises(ValueError):
                # You cannot set both options to True simultaneously.
                fig, ax = generate_stack_graph(
                    solved_md,
                    title=repr(test_case),
                    show_individual_components=True,
                    plot_individual_generators=True,
                )
Ejemplo n.º 4
0
    end_time = "2020-07-06"

    md = create_ModelData(
        rts_gmlc_dir,
        begin_time,
        end_time,
        simulation="DAY_AHEAD",
        t0_state=None,
    )

    solved_md = solve_unit_commitment(
        md,
        'gurobi',
        mipgap=0.001,
        timelimit=None,
        solver_tee=True,
        symbolic_solver_labels=False,
        options=None,
        uc_model_generator=create_tight_unit_commitment_model,
        relaxed=False,
        return_model=False)

    fig, ax = generate_stack_graph(
        solved_md,
        title=begin_time,
        show_individual_components=False,
        plot_individual_generators=False,
        x_tick_frequency=4,
    )

    plt.show()