Commit ad00aea
Rebase/decompose (#49)
* Initializing branch for decomposing positive/negative charges (branched off of feature/parametrize_charges)
In utils:
- Updating sum() util function to use pyo.summation
- Adding decompose_consumption function to split a np array, pyo variable, or cvxpy variable into positive and negative components
- Adding initialize_decomposed_pyo_vars to help with initializing the decomposed elements in a pyomo model
Modifying existing tests in test_costs.py to include decompositino
Adding test_decompose_consumption_np, test_decompose_consumption_cvxpy, test_decompose_consumption_pyo to test_utils.py
Adding documentation notes in how_to_advanced
Adding test coverage for negative values input to energy / demand calculation
Removing ValueError raised in calculate_cost for non-np.array/pyo/cvx object. Since this code is never actually reached because the valueerror will be raised from ut.multiply() first
Consolidating consumption_data_dict and consumption_object_dict arguments
Adding magnitude constraint so that positive_var[t] + negative_var[t] == abs(expression[t]) to prevent both variables becoming large when export rate is higher than energy rate
Reformatted with black
Updated test_calculate_cost_pyo to use ipopt rather than gurobi when running decompose_exports, since abs() function is nonlinear / nonconvex
* Renaming scale_ratios to percent_change_dict in parametrize_charge_dict and parametrize_rate_data
Adding test_calculate_itemized_costs for np, cvx, and pyo with one non-decomposed and one decomposed example
Adding a warning test to calculate_export_revenue
Adding helper functions for pyo and cvx problems to be used by their versions of both test_calculate_cost and test_calculate_itemized_cost
Adding warning that decompose_exports isn't supported with cvxpy due to non-DCP exports-imports issues
Reformatted with black
* Simplifying test_decompose_consumption_pyo with approx
* Changing decompose_exports argument to decomposition_type, which can take None, "absolute_value", "binary", or other types in the future
Using max_pos for creating positive and negative pyomo variables
(WIP: Index issue failing test in test_utils)
* Adding missing arguments in test_costs.py
* COSTS
Adding calculate_conversion_factors
Modifying calculate_energy_cost to only apply convex approximation when there are charge tiers
TESTS
Adding consumption_estimate to test_calculate_cost_cvx to avoid default 0 issues
Adding additional test case for cvx problem without charge limit to test_calculate_cost_cvx
Updating test expectations in test_max_pos_pyo so that scalar inputs have scalar expectations, vector inputs have vector expectations
* Fixing bug with duplicated conversion_factor in calculate_cost
Reformatting with black
* Since conversion_factor is applied earlier during import/export decomposition, removing it from divisor in costs.py and renaming divisor to n_per_hour
Moving application of conversion factor to helper function get_converted_consumption_data
* Consolidating get_unique_row_name and default_varstr_alias_func
default_varstr_alias_func takes row index parameter, where index is used if "name" is blank
Removing dashes from names in test_costs.py since sanitize_varstr removes dashes and replaces with underscores
Cleaning up error expectation in test_calculate_cost_np
* Cleaning up calculate_energy_cost
* Reverting changes to default_varstr_alias_func
Adding back get_unique_row_name (renamed to get_charge_name)
Removing initialize_decomposed_pyo_vars. The variables self-initialize during solve.
Updating test_decompose_consumption_pyo to just check for the presence of objects, not values. (WIP to add value check in test_calculate_cost_pyo for pre-decomposed inputs)
Renaming _get_decomposed_var_names to get_decomposed_var_names
Adding test cases for extended consumption data format in test_calculate_cost_np and test_calculate_cost_pyo
* Adding test calling max_pos on pyo scalar
Updating minimum pyomo version to 6.8
* Reformatted with black
* Add comprehensive test coverage for utils and costs
- Add scalar LinearExpression tests for max_pos_pyo
- Add TypeError tests for invalid types in max_pos and decompose_consumption
- Add warning tests for unimplemented decomposition types
- Add ValueError test for invalid type in calculate_export_revenue
- Add negative values warning test in calculate_demand_costs
- Add test for consumption_estimate=None and dict consumption_estimate
- Add conversion factor test with MW units in test_calculate_itemized_cost_pyo
- Fix idempotency in get_converted_consumption_data to prevent duplicate components
- Add warnings for unimplemented decomposition_type in utils.decompose_consumption
* Removing uneeded else statements in calculate_cost if conversion / decomposition has already been run on the model
* Correcting UserWarning syntax in costs.py
* Creating new test to address bug with double unit conversions in itemized costs
* Fixed errors in rebase so that only two tests fail now
* Fixing flake8 errors
* Trying to address double unit conversion
* Fixed unit conversion errors and all tests now passing
* Autoreformatted with black
* Creating codecov.yml file to try to address patch coverage
* Fixed flake8 errors
* Fixing documentation formatting
* Fixing whitespace error
---------
Co-authored-by: dalyw <sdwettermark@gmail.com>1 parent d86ca9c commit ad00aea
13 files changed
Lines changed: 5050 additions & 691 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
139 | | - | |
| 138 | + | |
140 | 139 | | |
141 | | - | |
142 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
143 | 145 | | |
144 | 146 | | |
145 | 147 | | |
146 | | - | |
| 148 | + | |
147 | 149 | | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
154 | 159 | | |
155 | | - | |
156 | | - | |
| 160 | + | |
157 | 161 | | |
158 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
159 | 213 | | |
160 | | - | |
161 | | - | |
| 214 | + | |
| 215 | + | |
162 | 216 | | |
163 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
164 | 223 | | |
165 | 224 | | |
166 | 225 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| |||
0 commit comments