From 83a20406d67838b637222149fd874b2b5e083c7a Mon Sep 17 00:00:00 2001 From: Kyle Skolfield Date: Wed, 28 Feb 2024 16:22:46 -0700 Subject: [PATCH 01/12] readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7990c11..c386066 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,4 @@ IDAES Generation and Transmission Expansion Planning [![GitHub CI](https://github.com/IDAES/idaes-gtep/actions/workflows/test_pr_and_main.yml/badge.svg?branch=main&event=push)](https://github.com/IDAES/idaes-gtep/actions/workflows/test_pr_and_main.yml) [![Documentation Status](https://readthedocs.org/projects/idaes-gtep/badge/?version=latest)](http://idaes-gtep.readthedocs.org/en/latest/) -[`Documentation`](https://idaes-gtep.readthedocs.io) \ No newline at end of file +[Documentation](https://idaes-gtep.readthedocs.io) \ No newline at end of file From 1aa9955e0127fc01b68925aa82223568e40edf8c Mon Sep 17 00:00:00 2001 From: Kyle Skolfield Date: Thu, 29 Feb 2024 14:03:56 -0700 Subject: [PATCH 02/12] Update index.rst --- docs/source/index.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/source/index.rst b/docs/source/index.rst index e04441b..8fc447e 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -10,6 +10,10 @@ Welcome to idaes-gtep's documentation! :maxdepth: 2 :caption: Contents: + Modeling + Data Structure + Solving + Indices and tables From 143ade9605d93a9febea6df36f1c551cd230fe73 Mon Sep 17 00:00:00 2001 From: Kyle Skolfield Date: Thu, 29 Feb 2024 15:18:39 -0700 Subject: [PATCH 03/12] autodoc progress --- docs/source/index.rst | 2 +- docs/source/modeling.rst | 5 +++++ gtep/gtep_model.py | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 docs/source/modeling.rst diff --git a/docs/source/index.rst b/docs/source/index.rst index 8fc447e..9f7a9fd 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -11,7 +11,7 @@ Welcome to idaes-gtep's documentation! :caption: Contents: Modeling - Data Structure + Data Solving diff --git a/docs/source/modeling.rst b/docs/source/modeling.rst new file mode 100644 index 0000000..8c38925 --- /dev/null +++ b/docs/source/modeling.rst @@ -0,0 +1,5 @@ +Wherein we test documentation +============================= + +.. automodule:: gtep_model + :members: \ No newline at end of file diff --git a/gtep/gtep_model.py b/gtep/gtep_model.py index 1f0a247..46f1a4f 100644 --- a/gtep/gtep_model.py +++ b/gtep/gtep_model.py @@ -41,6 +41,9 @@ def __iter__(self): class ExpansionPlanningModel: + """A generalized generation and transmission expansion planning model. + + """ def __init__( self, stages=1, From a462636e415f59b6239613908a7ff7e64732f2a0 Mon Sep 17 00:00:00 2001 From: Kyle Skolfield Date: Thu, 29 Feb 2024 15:21:12 -0700 Subject: [PATCH 04/12] update index.rst --- docs/source/index.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index 9f7a9fd..cd25f62 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -10,9 +10,9 @@ Welcome to idaes-gtep's documentation! :maxdepth: 2 :caption: Contents: - Modeling - Data - Solving + modeling + data + solving From 2efa5768dbe5903eef43614a3579904cef216b78 Mon Sep 17 00:00:00 2001 From: Kyle Skolfield Date: Thu, 29 Feb 2024 15:30:19 -0700 Subject: [PATCH 05/12] autodocs --- docs/source/modeling.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/modeling.rst b/docs/source/modeling.rst index 8c38925..8058272 100644 --- a/docs/source/modeling.rst +++ b/docs/source/modeling.rst @@ -1,5 +1,5 @@ Wherein we test documentation ============================= -.. automodule:: gtep_model +.. automodule:: gtep :members: \ No newline at end of file From cbffb3068d938076df9b192229dc00ec851f894c Mon Sep 17 00:00:00 2001 From: Kyle Skolfield Date: Thu, 29 Feb 2024 15:41:14 -0700 Subject: [PATCH 06/12] autodocs --- docs/source/modeling.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/source/modeling.rst b/docs/source/modeling.rst index 8058272..a87e416 100644 --- a/docs/source/modeling.rst +++ b/docs/source/modeling.rst @@ -2,4 +2,8 @@ Wherein we test documentation ============================= .. automodule:: gtep - :members: \ No newline at end of file + :members: + +.. autoclass:: ExpansionPlanningModel + :members: + \ No newline at end of file From 9255cb7558ed9a33415083a05af796943f0a228c Mon Sep 17 00:00:00 2001 From: Kyle Skolfield Date: Thu, 29 Feb 2024 15:45:27 -0700 Subject: [PATCH 07/12] autodoc --- docs/source/modeling.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/modeling.rst b/docs/source/modeling.rst index a87e416..5c2b81b 100644 --- a/docs/source/modeling.rst +++ b/docs/source/modeling.rst @@ -4,6 +4,6 @@ Wherein we test documentation .. automodule:: gtep :members: -.. autoclass:: ExpansionPlanningModel +.. automodule:: gtep.gtep_model :members: \ No newline at end of file From 1c8c8b6356d7db4dfe72b110ed7db2eeb5850ac2 Mon Sep 17 00:00:00 2001 From: Kyle Skolfield Date: Thu, 29 Feb 2024 16:01:58 -0700 Subject: [PATCH 08/12] autodoc --- gtep/gtep_model.py | 1 + 1 file changed, 1 insertion(+) diff --git a/gtep/gtep_model.py b/gtep/gtep_model.py index 46f1a4f..17a17cb 100644 --- a/gtep/gtep_model.py +++ b/gtep/gtep_model.py @@ -688,6 +688,7 @@ def add_commitment_variables(b, commitment_period): None Returns: None + """ m = b.model() r_p = b.parent_block() From 539bca47744c1e297d41c2d511076f8c490ed20d Mon Sep 17 00:00:00 2001 From: Kyle Skolfield Date: Thu, 29 Feb 2024 16:10:02 -0700 Subject: [PATCH 09/12] autodoc --- gtep/gtep_model.py | 154 ++++++++++++++------------------------------- 1 file changed, 46 insertions(+), 108 deletions(-) diff --git a/gtep/gtep_model.py b/gtep/gtep_model.py index 17a17cb..c71bed0 100644 --- a/gtep/gtep_model.py +++ b/gtep/gtep_model.py @@ -42,7 +42,6 @@ def __iter__(self): class ExpansionPlanningModel: """A generalized generation and transmission expansion planning model. - """ def __init__( self, @@ -54,18 +53,16 @@ def __init__( num_commit=24, num_dispatch=4, ): - """ - Initialize generation & expansion planning model object - Args: - stages : integer number of investment periods - formulation : Egret stuff, to be filled - data : full set of model data - num_reps : integer number of representative periods per investment period - len_reps : (for now integer) length of each representative period (in hours) - num_commit : integer number of commitment periods per representative period - num_dispatch : integer number of dispatch periods per commitment period - Returns: - m : Pyomo model for full GTEP + """Initialize generation & expansion planning model object. + + :stages: integer number of investment periods + :formulation: Egret stuff, to be filled + :data: full set of model data + :num_reps: integer number of representative periods per investment period + :len_reps: (for now integer) length of each representative period (in hours) + :num_commit: integer number of commitment periods per representative period + :num_dispatch: integer number of dispatch periods per commitment period + :return: Pyomo model for full GTEP """ self.stages = stages @@ -78,8 +75,7 @@ def __init__( self.timer = TicTocTimer() def create_model(self): - """ - Create concrete Pyomo model object associated with the ExpansionPlanningModel + """Create concrete Pyomo model object associated with the ExpansionPlanningModel """ self.timer.tic("Creating GTEP Model") m = ConcreteModel() @@ -128,23 +124,18 @@ def create_model(self): ## TODO: this should handle string or i/o object for outfile def report_model(self, outfile="pretty_model_output.txt"): - """ - Pretty prints Pyomo model to outfile. + """Pretty prints Pyomo model to outfile. - Args: - outfile (str, optional): _description_. Defaults to "pretty_model_output.txt". + :outfile: (str, optional) _description_. Defaults to "pretty_model_output.txt". """ with open(outfile, "w") as outf: self.model.pprint(ostream=outf) def report_large_coefficients(self, outfile, magnitude_cutoff): - """ - Dump very large magnitude (>= 1e5) coefficients to a json file. - Args: - outfile: should accept filename or open file and write there; see how we do this in pyomo elsewhere - magnitude_cutoff: magnitude above which to report coefficients - Returns: - None + """Dump very large magnitude (>= 1e5) coefficients to a json file. + + :outfile: should accept filename or open file and write there; see how we do this in pyomo elsewhere + :magnitude_cutoff: magnitude above which to report coefficients """ var_coef_dict = {} for e in self.model.component_data_objects(Constraint): @@ -175,12 +166,7 @@ def add_investment_variables( b, investment_stage, ): - """ - Add continuous variables to investment stage block. - Args: - None - Returns: - None + """Add continuous variables to investment stage block. """ m = b.model() b.investmentStage = investment_stage @@ -243,12 +229,7 @@ def add_investment_constraints( b, investment_stage, ): - """ - Add standard inequalities (i.e., those not involving disjunctions) to investment stage block. - Args: - None - Returns: - None + """Add standard inequalities (i.e., those not involving disjunctions) to investment stage block. """ m = b.model() @@ -415,12 +396,7 @@ def add_dispatch_variables( b, dispatch_period, ): - """ - Add dispatch-associated variables to representative period block. - Args: - None - Returns: - None + """Add dispatch-associated variables to representative period block. """ m = b.model() @@ -537,12 +513,7 @@ def add_dispatch_constraints( b, disp_per, ): - """ - Add dispatch-associated inequalities to representative period block. - Args: - None - Returns: - None + """Add dispatch-associated inequalities to representative period block. """ m = b.model() c_p = b.parent_block() @@ -682,13 +653,7 @@ def operating_cost_dispatch(b): def add_commitment_variables(b, commitment_period): - """ - Add variables and disjuncts to commitment period block. - Args: - None - Returns: - None - + """Add variables and disjuncts to commitment period block. """ m = b.model() r_p = b.parent_block() @@ -883,12 +848,7 @@ def add_commitment_constraints( b, comm_per, ): - """ - Add commitment-associated disjunctions and constraints to representative period block. - Args: - None - Returns: - None + """Add commitment-associated disjunctions and constraints to representative period block. """ m = b.model() r_p = b.parent_block() @@ -992,13 +952,10 @@ def renewable_curtailment_commitment(b): def commitment_period_rule(b, commitment_period): - """ - Create commitment period block. - Args: - b: commitment period block - commitment_period: corresponding commitment period label - Returns: - None + """Create commitment period block. + + :b: commitment period block + :commitment_period: corresponding commitment period label """ m = b.model() r_p = b.parent_block() @@ -1125,13 +1082,10 @@ def representative_period_rule( b, representative_period, ): - """ - Create representative period block. - Args: - b: Representative period block - representative_period: corresponding representative period label - Returns: - None + """Create representative period block. + + :b: Representative period block + :representative_period: corresponding representative period label """ m = b.model() i_s = b.parent_block() @@ -1149,13 +1103,10 @@ def investment_stage_rule( b, investment_stage, ): - """ - Creates investment stage block. - Args: - b: Investment block - investment_stage: ID for current investment stage - Returns: - None + """Creates investment stage block. + + :b: Investment block + :investment_stage: ID for current investment stage """ m = b.parent_block() @@ -1175,14 +1126,10 @@ def investment_stage_rule( def create_objective_function(m): - """ - Creates objective function. Total cost is operating cost plus + """Creates objective function. Total cost is operating cost plus expansion cost plus penalty cost (penalties include generation deficits, renewable quota deficits, and curtailment) - Args: - m: Pyomo GTEP model. - Returns: - None + :m: Pyomo GTEP model. """ if len(m.stages) > 1: m.operatingCost = sum( @@ -1217,11 +1164,9 @@ def total_cost_objective_rule(m): def model_set_declaration(m, stages, rep_per=["a", "b"], com_per=2, dis_per=2): """ Creates Pyomo Sets necessary (convenient) for solving the GTEP model. - Args: - m: Pyomo model object - stages: Number of stages in investment horizon - Returns: - None + + :m: Pyomo model object + :stages: Number of stages in investment horizon """ m.buses = Set( @@ -1294,13 +1239,9 @@ def model_set_declaration(m, stages, rep_per=["a", "b"], com_per=2, dis_per=2): def model_data_references(m): - """ - Creates and labels data for GTEP model; ties input data + """Creates and labels data for GTEP model; ties input data to model directly. - Args: - m: Pyomo model object - Returns: - None + :m: Pyomo model object """ # Maximum output of each thermal generator @@ -1511,15 +1452,12 @@ def model_data_references(m): def model_create_investment_stages(m, stages): - """ - Creates investment blocks and linking constraints for GTEP model. + """Creates investment blocks and linking constraints for GTEP model. Largely manages retirements and links operational units in a given investment stage to operational + installed - retired in the previous investment stage. - Args: - m: Pyomo model object - stages: Number of investment stages in planning horizon - Returns: - None + + :m: Pyomo model object + :stages: Number of investment stages in planning horizon """ m.investmentStage = Block(m.stages, rule=investment_stage_rule) From 9952ecd4f6d3688015f0fb84b7856bcdac4c7861 Mon Sep 17 00:00:00 2001 From: Kyle Skolfield Date: Thu, 29 Feb 2024 16:19:40 -0700 Subject: [PATCH 10/12] autodocs hard --- docs/source/data.rst | 2 ++ docs/source/modeling.rst | 4 ++-- docs/source/solving.rst | 2 ++ gtep/gtep_model.py | 16 ++++++++-------- 4 files changed, 14 insertions(+), 10 deletions(-) create mode 100644 docs/source/data.rst create mode 100644 docs/source/solving.rst diff --git a/docs/source/data.rst b/docs/source/data.rst new file mode 100644 index 0000000..f18be39 --- /dev/null +++ b/docs/source/data.rst @@ -0,0 +1,2 @@ +Data +==== \ No newline at end of file diff --git a/docs/source/modeling.rst b/docs/source/modeling.rst index 5c2b81b..d4787f3 100644 --- a/docs/source/modeling.rst +++ b/docs/source/modeling.rst @@ -1,9 +1,9 @@ -Wherein we test documentation +Modeling ============================= .. automodule:: gtep :members: .. automodule:: gtep.gtep_model - :members: + :members: ExpansionPlanningModel \ No newline at end of file diff --git a/docs/source/solving.rst b/docs/source/solving.rst new file mode 100644 index 0000000..d5bf268 --- /dev/null +++ b/docs/source/solving.rst @@ -0,0 +1,2 @@ +Solving +======= \ No newline at end of file diff --git a/gtep/gtep_model.py b/gtep/gtep_model.py index c71bed0..9516fbb 100644 --- a/gtep/gtep_model.py +++ b/gtep/gtep_model.py @@ -54,14 +54,14 @@ def __init__( num_dispatch=4, ): """Initialize generation & expansion planning model object. - - :stages: integer number of investment periods - :formulation: Egret stuff, to be filled - :data: full set of model data - :num_reps: integer number of representative periods per investment period - :len_reps: (for now integer) length of each representative period (in hours) - :num_commit: integer number of commitment periods per representative period - :num_dispatch: integer number of dispatch periods per commitment period + + :param stages: integer number of investment periods + :param formulation: Egret stuff, to be filled + :param data: full set of model data + :param num_reps: integer number of representative periods per investment period + :param len_reps: (for now integer) length of each representative period (in hours) + :param num_commit: integer number of commitment periods per representative period + :param num_dispatch: integer number of dispatch periods per commitment period :return: Pyomo model for full GTEP """ From 39cc129d1bd70287eac4f359be6efb28894de17c Mon Sep 17 00:00:00 2001 From: Kyle Skolfield Date: Thu, 29 Feb 2024 16:21:02 -0700 Subject: [PATCH 11/12] autodocs hard --- docs/source/modeling.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/modeling.rst b/docs/source/modeling.rst index d4787f3..6372818 100644 --- a/docs/source/modeling.rst +++ b/docs/source/modeling.rst @@ -5,5 +5,5 @@ Modeling :members: .. automodule:: gtep.gtep_model - :members: ExpansionPlanningModel + :members: \ No newline at end of file From 514aaff3f43c5ca06741254321e3b01243cb8931 Mon Sep 17 00:00:00 2001 From: Kyle Skolfield Date: Mon, 4 Mar 2024 09:40:11 -0700 Subject: [PATCH 12/12] .gitignore update --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 68bc17f..40def25 100644 --- a/.gitignore +++ b/.gitignore @@ -158,3 +158,4 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ +.vscode/settings.json