Skip to content

Commit

Permalink
Merge pull request #3 from rundxdi/main
Browse files Browse the repository at this point in the history
Remove solve_model
  • Loading branch information
rundxdi authored Jan 23, 2024
2 parents 91120db + 0125b94 commit da71c31
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
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 @@ def report_model(self, outfile="pretty_model_output.txt"):
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 @@ def thermal_uninvested(b, gen):

# 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 @@ def quickstart_reserve_limits(b, thermalGen):
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
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

0 comments on commit da71c31

Please sign in to comment.