Skip to content

Commit 4d6ae80

Browse files
committed
avoid solving all the periods and scenarios simultaneously if not needed
1 parent 9d42219 commit 4d6ae80

7 files changed

Lines changed: 172 additions & 104 deletions

File tree

CHANGELOG.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
Change Log
22
=============
33

4-
[4.18.4] - 2025-03-21
4+
[4.18.4] - 2025-03-31
55
-----------------------
6+
- [FIXED] avoid solving all the periods and scenarios simultaneously if not needed
67
- [CHANGED] added GenerationConsumptionRatio output file
78
- [FIXED] error in some terms of the operation costs
89
- [FIXED] error in CostRecovery output file

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ Miniconda (recommended)
120120
2. **Packages and Solver**:
121121

122122
1. Launch a new Anaconda prompt (or terminal in any IDE)
123-
2. The `HiGHS 1.7.2 <https://ergo-code.github.io/HiGHS/dev/interfaces/python/#python-getting-started>`_ is our recommendation if you want a free and open-source solver.
123+
2. The `HiGHS <https://ergo-code.github.io/HiGHS/dev/interfaces/python/#python-getting-started>`_ is our recommendation if you want a free and open-source solver.
124124
3. Install openTEPES via pip by ``pip install openTEPES``
125125

126126
Continue at `Get Started <#get-started>`_ and see the `Tips <#tips>`_.

openTEPES/openTEPES.py

Lines changed: 120 additions & 59 deletions
Large diffs are not rendered by default.

openTEPES/openTEPES_InputData.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ def ProcessParameter(pDataFrame: pd.DataFrame, pTimeStep: int) -> pd.DataFrame:
548548

549549
#%% defining subsets: active load levels (n,n2), thermal units (t), RES units (r), ESS units (es), candidate gen units (gc), candidate ESS units (ec), all the electric lines (la), candidate electric lines (lc), candidate DC electric lines (cd), existing DC electric lines (cd), electric lines with losses (ll), reference node (rf), and reactive generating units (gq)
550550
mTEPES.p = Set(doc='periods' , initialize=[pp for pp in mTEPES.pp if pPeriodWeight [pp] > 0.0 and sum(pDuration[pp,sc,n] for sc,n in mTEPES.scc*mTEPES.nn)])
551-
mTEPES.sc = Set(doc='scenarios' , initialize=[scc for scc in mTEPES.scc ])
551+
mTEPES.sc = Set(doc='scenarios' , initialize=[scc for scc in mTEPES.scc ])
552552
mTEPES.ps = Set(doc='periods/scenarios' , initialize=[(p,sc) for p,sc in mTEPES.p*mTEPES.sc if pScenProb [p,sc] > 0.0 and sum(pDuration[p,sc,n ] for n in mTEPES.nn)])
553553
mTEPES.st = Set(doc='stages' , initialize=[stt for stt in mTEPES.stt if pStageWeight [stt] > 0.0])
554554
mTEPES.n = Set(doc='load levels' , initialize=[nn for nn in mTEPES.nn if sum(pDuration [p,sc,nn] for p,sc in mTEPES.ps) > 0])
@@ -1327,18 +1327,18 @@ def filter_rows(df, set):
13271327
mTEPES.pIndHydrogen = Param(initialize=pIndHydrogen , within=Binary, doc='Indicator of hydrogen demand and pipeline network' )
13281328
mTEPES.pIndHeat = Param(initialize=pIndHeat , within=Binary, doc='Indicator of heat demand and pipe network' )
13291329

1330-
mTEPES.pENSCost = Param(initialize=pENSCost , within=NonNegativeReals, doc='ENS cost' )
1331-
mTEPES.pH2NSCost = Param(initialize=pH2NSCost , within=NonNegativeReals, doc='HNS cost' )
1332-
mTEPES.pHeatNSCost = Param(initialize=pHeatNSCost , within=NonNegativeReals, doc='HTNS cost' )
1333-
mTEPES.pCO2Cost = Param(initialize=pCO2Cost , within=NonNegativeReals, doc='CO2 emission cost' )
1334-
mTEPES.pAnnualDiscRate = Param(initialize=pAnnualDiscRate , within=UnitInterval, doc='Annual discount rate' )
1335-
mTEPES.pUpReserveActivation = Param(initialize=pUpReserveActivation, within=UnitInterval, doc='Proportion of upward reserve activation' )
1336-
mTEPES.pDwReserveActivation = Param(initialize=pDwReserveActivation, within=UnitInterval, doc='Proportion of downward reserve activation' )
1337-
mTEPES.pMinRatioDwUp = Param(initialize=pMinRatioDwUp , within=UnitInterval, doc='Minimum ration between upward and downward reserve')
1338-
mTEPES.pMaxRatioDwUp = Param(initialize=pMaxRatioDwUp , within=UnitInterval, doc='Maximum ration between upward and downward reserve')
1339-
mTEPES.pSBase = Param(initialize=pSBase , within=PositiveReals, doc='Base power' )
1340-
mTEPES.pTimeStep = Param(initialize=pTimeStep , within=PositiveIntegers, doc='Unitary time step' )
1341-
mTEPES.pEconomicBaseYear = Param(initialize=pEconomicBaseYear , within=PositiveIntegers, doc='Base year' )
1330+
mTEPES.pENSCost = Param(initialize=pENSCost , within=NonNegativeReals, doc='ENS cost' )
1331+
mTEPES.pH2NSCost = Param(initialize=pH2NSCost , within=NonNegativeReals, doc='HNS cost' )
1332+
mTEPES.pHeatNSCost = Param(initialize=pHeatNSCost , within=NonNegativeReals, doc='HTNS cost' )
1333+
mTEPES.pCO2Cost = Param(initialize=pCO2Cost , within=NonNegativeReals, doc='CO2 emission cost' )
1334+
mTEPES.pAnnualDiscRate = Param(initialize=pAnnualDiscRate , within=UnitInterval, doc='Annual discount rate' )
1335+
mTEPES.pUpReserveActivation = Param(initialize=pUpReserveActivation, within=UnitInterval, doc='Proportion of upward reserve activation' )
1336+
mTEPES.pDwReserveActivation = Param(initialize=pDwReserveActivation, within=UnitInterval, doc='Proportion of downward reserve activation' )
1337+
mTEPES.pMinRatioDwUp = Param(initialize=pMinRatioDwUp , within=UnitInterval, doc='Minimum ratio downward to upward operating reserves')
1338+
mTEPES.pMaxRatioDwUp = Param(initialize=pMaxRatioDwUp , within=UnitInterval, doc='Maximum ratio downward to upward operating reserves')
1339+
mTEPES.pSBase = Param(initialize=pSBase , within=PositiveReals, doc='Base power' )
1340+
mTEPES.pTimeStep = Param(initialize=pTimeStep , within=PositiveIntegers, doc='Unitary time step' )
1341+
mTEPES.pEconomicBaseYear = Param(initialize=pEconomicBaseYear , within=PositiveIntegers, doc='Base year' )
13421342

13431343
mTEPES.pReserveMargin = Param(mTEPES.par, initialize=pReserveMargin.to_dict() , within=NonNegativeReals, doc='Adequacy reserve margin' )
13441344
mTEPES.pEmission = Param(mTEPES.par, initialize=pEmission.to_dict() , within=NonNegativeReals, doc='Maximum CO2 emission' )

openTEPES/openTEPES_Main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@
519519
# conveyed by you (or copies made from those copies), or (b) primarily
520520
# for and in connection with specific products or compilations that
521521
# contain the covered work, unless you entered into that arrangement,
522-
# or that patent license was granted, prior to 28 March 2107.
522+
# or that patent license was granted, prior to 28 March 2007.
523523
#
524524
# Nothing in this License shall be construed as excluding or limiting
525525
# any implied license or other defenses to infringement that may
@@ -660,7 +660,7 @@
660660
# For more information on this, and how to apply and follow the GNU AGPL, see
661661
# <https://www.gnu.org/licenses/>.
662662

663-
# Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - March 21, 2025
663+
# Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - March 31, 2025
664664
# simplicity and transparency in power systems planning
665665

666666
# Developed by
@@ -686,7 +686,7 @@
686686
# import pkg_resources
687687
from .openTEPES import openTEPES_run
688688

689-
print('\033[1;32mOpen Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - Version 4.18.4 - March 21, 2025\033[0m')
689+
print('\033[1;32mOpen Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - Version 4.18.4 - March 31, 2025\033[0m')
690690
print('\033[34m#### Academic research license - for non-commercial use only ####\033[0m \n')
691691

692692
parser = argparse.ArgumentParser(description='Introducing main parameters...')

openTEPES/openTEPES_OutputResults.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - March 21, 2025
2+
Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - March 31, 2025
33
"""
44

55
import time
@@ -2195,10 +2195,12 @@ def Transformation1(df, _name):
21952195
GenCost = pd.Series(data=[sum(mTEPES.pDiscountedWeight[p] * mTEPES.pScenProb[p,sc]() * mTEPES.pLoadLevelDuration[p,sc,n]() * mTEPES.pLinearVarCost [p,sc,n,gc] * OptModel.vTotalOutput [p,sc,n,gc]() +
21962196
mTEPES.pDiscountedWeight[p] * mTEPES.pScenProb[p,sc]() * mTEPES.pLoadLevelDuration[p,sc,n]() * mTEPES.pConstantVarCost[p,sc,n,gc] * OptModel.vCommitment [p,sc,n,gc]() +
21972197
mTEPES.pDiscountedWeight[p] * mTEPES.pScenProb[p,sc]() * mTEPES.pLoadLevelWeight [p,sc,n]() * mTEPES.pStartUpCost [ gc] * OptModel.vStartUp [p,sc,n,gc]() +
2198-
mTEPES.pDiscountedWeight[p] * mTEPES.pScenProb[p,sc]() * mTEPES.pLoadLevelWeight [p,sc,n]() * mTEPES.pShutDownCost [ gc] * OptModel.vShutDown [p,sc,n,gc]() for p,sc,n in mTEPES.psn if (p,gc) in mTEPES.pgc) for gc in mTEPES.gc], index=mTEPES.gc, dtype='float64')
2198+
mTEPES.pDiscountedWeight[p] * mTEPES.pScenProb[p,sc]() * mTEPES.pLoadLevelWeight [p,sc,n]() * mTEPES.pShutDownCost [ gc] * OptModel.vShutDown [p,sc,n,gc]() for p,sc,n in mTEPES.psn if (p,gc) in mTEPES.pgc) if gc in mTEPES.nr else
2199+
sum(mTEPES.pDiscountedWeight[p] * mTEPES.pScenProb[p,sc]() * mTEPES.pLoadLevelDuration[p,sc,n]() * mTEPES.pLinearVarCost [p,sc,n,gc] * OptModel.vTotalOutput [p,sc,n,gc]() for p,sc,n in mTEPES.psn if (p,gc) in mTEPES.pgc) for gc in mTEPES.gc], index=mTEPES.gc, dtype='float64')
21992200
EmsCost = pd.Series(data=[sum(mTEPES.pDiscountedWeight[p] * mTEPES.pScenProb[p,sc]() * mTEPES.pLoadLevelDuration[p,sc,n]() * mTEPES.pEmissionVarCost[p,sc,n,gc] * OptModel.vTotalOutput [p,sc,n,gc]() for p,sc,n in mTEPES.psn if (p,gc) in mTEPES.pgc) for gc in mTEPES.gc], index=mTEPES.gc, dtype='float64')
22002201
OpGCost = pd.Series(data=[sum(mTEPES.pDiscountedWeight[p] * mTEPES.pScenProb[p,sc]() * mTEPES.pLoadLevelWeight [p,sc,n]() * mTEPES.pOperReserveCost[ gc] * OptModel.vReserveUp [p,sc,n,gc]() +
2201-
mTEPES.pDiscountedWeight[p] * mTEPES.pScenProb[p,sc]() * mTEPES.pLoadLevelWeight [p,sc,n]() * mTEPES.pOperReserveCost[ gc] * OptModel.vReserveDown [p,sc,n,gc]() for p,sc,n in mTEPES.psn if (p,gc) in mTEPES.pgc) for gc in mTEPES.gc], index=mTEPES.gc, dtype='float64')
2202+
mTEPES.pDiscountedWeight[p] * mTEPES.pScenProb[p,sc]() * mTEPES.pLoadLevelWeight [p,sc,n]() * mTEPES.pOperReserveCost[ gc] * OptModel.vReserveDown [p,sc,n,gc]() for p,sc,n in mTEPES.psn if (p,gc) in mTEPES.pgc) if gc in mTEPES.nr else
2203+
0.0 for gc in mTEPES.gc], index=mTEPES.gc, dtype='float64')
22022204
CnsCost = pd.Series(data=[sum(mTEPES.pDiscountedWeight[p] * mTEPES.pScenProb[p,sc]() * mTEPES.pLoadLevelDuration[p,sc,n]() * mTEPES.pLinearVarCost [p,sc,n,ec] * OptModel.vESSTotalCharge[p,sc,n,ec]() for p,sc,n in mTEPES.psn if (p,ec) in mTEPES.pec) for ec in mTEPES.ec], index=mTEPES.ec, dtype='float64')
22032205
OpCCost = pd.Series(data=[sum(mTEPES.pDiscountedWeight[p] * mTEPES.pScenProb[p,sc]() * mTEPES.pLoadLevelWeight [p,sc,n]() * mTEPES.pOperReserveCost[ ec] * OptModel.vESSReserveUp [p,sc,n,ec]() +
22042206
mTEPES.pDiscountedWeight[p] * mTEPES.pScenProb[p,sc]() * mTEPES.pLoadLevelWeight [p,sc,n]() * mTEPES.pOperReserveCost[ ec] * OptModel.vESSReserveDown[p,sc,n,ec]() for p,sc,n in mTEPES.psn if (p,ec) in mTEPES.pec) for ec in mTEPES.ec], index=mTEPES.ec, dtype='float64')

0 commit comments

Comments
 (0)