Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove solve_model #3

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions gtep/gtep_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,6 @@
with open(outfile, "w") as outf:
self.model.pprint(ostream=outf)

## TODO: probably don't have gurobi as default solver? Instead set as open source.
def solve_model(self, solver="gurobi", solver_args=None):
"""Solves the expansion planning model. Solver_args are passed directly
to the chosen solver. Assigns solution results to self.results.

Args:
solver (str, optional): _description_. Defaults to "gurobi".
solver_args (_type_, optional): _description_. Defaults to None.
"""
opt = SolverFactory(solver)
TransformationFactory("gdp.bigm").apply_to(self.model)
self.results = opt.solve(self.model, tee=False, load_solutions=True)

def report_large_coefficients(self, outfile, magnitude_cutoff):
"""
Dump very large magnitude (>= 1e5) coefficients to a json file.
Expand Down Expand Up @@ -270,6 +257,7 @@

# Planning reserve requirement constraint
## NOTE: renewableCapacityValue is a percentage of renewableCapacity
## TODO: renewableCapacityValue ==> renewableCapacityFactor
## NOTE: reserveMargin is a percentage of peakLoad
## TODO: check and re-enable with additional bounding transform before bigm
## TODO: renewableCapacityValue... should this be time iterated? is it tech based?
Expand Down Expand Up @@ -525,7 +513,7 @@
b.loadShed = Var(m.buses, domain=NonNegativeReals, initialize=0)

# TODO: adjacent bus angle difference constraints should be added -- what should they be?
# TODO: likewise, what do we want angle boudns to actually be?
# TODO: likewise, what do we want angle bounds to actually be?

def bus_angle_bounds(b, bus):
return (-90, 90)
Expand Down Expand Up @@ -1348,7 +1336,7 @@
}

# A fraction of renewableCapacity representing fraction of capacity
# that can be reliably counted toward planning reserve requriement

Check warning on line 1339 in gtep/gtep_model.py

View workflow job for this annotation

GitHub Actions / Check Spelling

"requriement" should be "requirement".
# TODO: WHAT HAVE I DONE HERE I HATE IT
m.renewableCapacityValue = {
renewableGen: min(
Expand Down Expand Up @@ -1438,7 +1426,7 @@
}

# Cost per MW of curtailed renewable energy
# NOTE: what should this be vauled at? This being both curtailment and load shed.

Check warning on line 1429 in gtep/gtep_model.py

View workflow job for this annotation

GitHub Actions / Check Spelling

"vauled" should be "valued".
# TODO: update valuations
m.curtailmentCost = 2 * max(m.fuelCost.values())
m.loadShedCost = 1000 * m.curtailmentCost
Expand Down
8 changes: 5 additions & 3 deletions gtep/tests/unit/test_gtep_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from prescient.data.providers import gmlc_data_provider
from prescient.simulator.options import Options
from prescient.simulator.config import PrescientConfig
import datetime


import logging
from io import StringIO
Expand Down Expand Up @@ -88,14 +88,16 @@ def test_model_init(self):
)

# Solve the debug model as is. Objective value should be $466769.69
# Assumes availability of gurobi
# Assumes availability of HiGHS
def test_solve_bigm(self):
md = read_debug_model()
modObject = ExpansionPlanningModel(
data=md, num_reps=1, len_reps=1, num_commit=1, num_dispatch=1
)
modObject.create_model()
modObject.solve_model()
opt = SolverFactory("highs")
TransformationFactory("gdp.bigm").apply_to(modObject.model)
modObject.results = opt.solve(modObject.model, tee=False, load_solutions=True)
modObject.report_model()
self.assertAlmostEqual(
value(modObject.model.total_cost_objective_rule), 483519.2, places=1
Expand Down
Loading