openTEPES 4.18.7__py3-none-any.whl → 4.18.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,16 +1,15 @@
1
1
  """
2
- Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - October 22, 2025
2
+ Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - January 21, 2026
3
3
  """
4
4
 
5
5
  import time
6
6
  import os
7
- import pandas as pd
8
7
  import pyomo.environ as pyo
9
8
  import psutil
10
9
  import logging
11
10
  from pyomo.opt import SolverFactory, SolverStatus, TerminationCondition
12
11
  from pyomo.util.infeasible import log_infeasible_constraints
13
- from pyomo.environ import Suffix
12
+ from pyomo.environ import Suffix, UnitInterval
14
13
 
15
14
  def ProblemSolving(DirName, CaseName, SolverName, OptModel, mTEPES, pIndLogConsole, p, sc, st):
16
15
  print('Problem solving ****')
@@ -51,8 +50,8 @@ def ProblemSolving(DirName, CaseName, SolverName, OptModel, mTEPES, pIndLogConso
51
50
  # Solver.options['RINSHeur' ] = 100
52
51
  # Solver.options['EpGap' ] = 0.01
53
52
  Solver.options['Threads' ] = int((psutil.cpu_count(logical=True) + psutil.cpu_count(logical=False))/2)
54
- Solver.options['TimeLimit' ] = 36000
55
- # Solver.options['ItLim' ] = 36000000
53
+ Solver.options['TimeLimit' ] = 72000
54
+ # Solver.options['ItLim' ] = 72000000
56
55
  if SolverName == 'appsi_highs':
57
56
  FileName = f'{_path}/openTEPES_highs_{CaseName}_{p}_{sc}_{st}.log'
58
57
  if os.path.exists(FileName):
@@ -64,15 +63,15 @@ def ProblemSolving(DirName, CaseName, SolverName, OptModel, mTEPES, pIndLogConso
64
63
  Solver.options['mip_rel_gap' ] = 0.01
65
64
  Solver.options['parallel' ] = 'on'
66
65
  Solver.options['threads' ] = int((psutil.cpu_count(logical=True) + psutil.cpu_count(logical=False))/2)
67
- Solver.options['time_limit' ] = 36000
68
- Solver.options['simplex_iteration_limit'] = 36000000
66
+ Solver.options['time_limit' ] = 72000
67
+ Solver.options['simplex_iteration_limit'] = 72000000
69
68
  if SolverName == 'gams':
70
69
  FileName = f'{_path}/openTEPES_gams_{CaseName}_{p}_{sc}_{st}.log'
71
70
  solver_options = {
72
71
  'file COPT / cplex.opt / ; put COPT putclose "LPMethod 4" / "EpGap 0.01" / ; GAMS_MODEL.OptFile = 1 ; '
73
72
  'option SysOut = off ;',
74
73
  'option LP = cplex ; option MIP = cplex ;',
75
- 'option ResLim = 36000 ; option IterLim = 36000000 ;',
74
+ 'option ResLim = 72000 ; option IterLim = 72000000 ;',
76
75
  'option Threads = '+str(int((psutil.cpu_count(logical=True) + psutil.cpu_count(logical=False))/2))+' ;'
77
76
  }
78
77
 
@@ -106,12 +105,14 @@ def ProblemSolving(DirName, CaseName, SolverName, OptModel, mTEPES, pIndLogConso
106
105
  if mTEPES.NoRepetition == 1:
107
106
  for var in OptModel.component_data_objects(pyo.Var, active=True, descend_into=True):
108
107
  if not var.is_continuous() and not var.is_fixed() and var.value != None:
109
- var.fixed = True # fix the current value
108
+ var.fixed = True # fix the current value
109
+ var.domain = UnitInterval # change the domain to continuous
110
110
  nUnfixedVars += 1
111
111
  else:
112
112
  for var in OptModel.component_data_objects(pyo.Var, active=True, descend_into=True):
113
113
  if not var.is_continuous() and not var.is_fixed() and var.value != None and var.index()[0] == p and var.index()[1] == sc:
114
- var.fixed = True # fix the current value
114
+ var.fixed = True # fix the current value
115
+ var.domain = UnitInterval # change the domain to continuous
115
116
  nUnfixedVars += 1
116
117
 
117
118
  # continuous investment decisions are fixed to their optimal values
@@ -171,50 +172,50 @@ def ProblemSolving(DirName, CaseName, SolverName, OptModel, mTEPES, pIndLogConso
171
172
  if mTEPES.NoRepetition == 1:
172
173
  for pp,scc in mTEPES.ps:
173
174
  print (f'***** Period: {pp}, Scenario: {scc}, Stage: {st} ******')
174
- print (' Total generation investment cost [MEUR] ', sum(mTEPES.pDiscountedWeight[pp] * mTEPES.pGenInvestCost [eb ] * OptModel.vGenerationInvest [pp,eb ]() for eb in mTEPES.eb if (pp,eb) in mTEPES.peb) +
175
- sum(mTEPES.pDiscountedWeight[pp] * mTEPES.pGenInvestCost [bc ] * OptModel.vGenerationInvestHeat[pp,bc ]() for bc in mTEPES.bc if (pp,bc) in mTEPES.pbc))
176
- print (' Total generation retirement cost [MEUR] ', sum(mTEPES.pDiscountedWeight[pp] * mTEPES.pGenRetireCost [gd ] * OptModel.vGenerationRetire [pp,gd ]() for gd in mTEPES.gd if (pp,gd) in mTEPES.pgd))
175
+ print (' Total generation investment cost [MEUR] ', mTEPES.pDiscountedWeight[pp] * sum(mTEPES.pGenInvestCost [eb ] * OptModel.vGenerationInvest [pp,eb ]() for eb in mTEPES.eb if (pp,eb) in mTEPES.peb) +
176
+ mTEPES.pDiscountedWeight[pp] * sum(mTEPES.pGenInvestCost [bc ] * OptModel.vGenerationInvestHeat[pp,bc ]() for bc in mTEPES.bc if (pp,bc) in mTEPES.pbc))
177
+ print (' Total generation retirement cost [MEUR] ', mTEPES.pDiscountedWeight[pp] * sum(mTEPES.pGenRetireCost [gd ] * OptModel.vGenerationRetire [pp,gd ]() for gd in mTEPES.gd if (pp,gd) in mTEPES.pgd))
177
178
  if mTEPES.pIndHydroTopology == 1 and mTEPES.rn:
178
- print(' Total reservoir investment cost [MEUR] ', sum(mTEPES.pDiscountedWeight[pp] * mTEPES.pRsrInvestCost [rc ] * OptModel.vReservoirInvest [pp,rc ]() for rc in mTEPES.rn if (pp,rc) in mTEPES.prc))
179
+ print(' Total reservoir investment cost [MEUR] ', mTEPES.pDiscountedWeight[pp] * sum(mTEPES.pRsrInvestCost [rc ] * OptModel.vReservoirInvest [pp,rc ]() for rc in mTEPES.rn if (pp,rc) in mTEPES.prc))
179
180
  else:
180
181
  print(' Total reservoir investment cost [MEUR] ', 0.0)
181
- print (' Total network investment cost [MEUR] ', sum(mTEPES.pDiscountedWeight[pp] * mTEPES.pNetFixedCost [ni,nf,cc] * OptModel.vNetworkInvest [pp,ni,nf,cc]() for ni,nf,cc in mTEPES.lc if (pp,ni,nf,cc) in mTEPES.plc))
182
+ print (' Total network investment cost [MEUR] ', mTEPES.pDiscountedWeight[pp] * sum(mTEPES.pNetFixedCost [ni,nf,cc] * OptModel.vNetworkInvest [pp,ni,nf,cc]() for ni,nf,cc in mTEPES.lc if (pp,ni,nf,cc) in mTEPES.plc))
182
183
  if mTEPES.pIndHydrogen == 1 and mTEPES.pc:
183
- print(' Total H2 pipe investment cost [MEUR] ', sum(mTEPES.pDiscountedWeight[pp] * mTEPES.pH2PipeFixedCost [ni,nf,cc] * OptModel.vH2PipeInvest [pp,ni,nf,cc]() for ni,nf,cc in mTEPES.pc if (pp,ni,nf,cc) in mTEPES.ppc))
184
+ print(' Total H2 pipe investment cost [MEUR] ', mTEPES.pDiscountedWeight[pp] * sum(mTEPES.pH2PipeFixedCost [ni,nf,cc] * OptModel.vH2PipeInvest [pp,ni,nf,cc]() for ni,nf,cc in mTEPES.pc if (pp,ni,nf,cc) in mTEPES.ppc))
184
185
  else:
185
186
  print(' Total H2 pipe investment cost [MEUR] ', 0.0)
186
187
  if mTEPES.pIndHeat == 1 and mTEPES.hc:
187
- print(' Total heat pipe investment cost [MEUR] ', sum(mTEPES.pDiscountedWeight[pp] * mTEPES.pHeatPipeFixedCost[ni,nf,cc] * OptModel.vHeatPipeInvest [pp,ni,nf,cc]() for ni,nf,cc in mTEPES.hc if (pp,ni,nf,cc) in mTEPES.phc))
188
+ print(' Total heat pipe investment cost [MEUR] ', mTEPES.pDiscountedWeight[pp] * sum(mTEPES.pHeatPipeFixedCost[ni,nf,cc] * OptModel.vHeatPipeInvest [pp,ni,nf,cc]() for ni,nf,cc in mTEPES.hc if (pp,ni,nf,cc) in mTEPES.phc))
188
189
  else:
189
190
  print(' Total heat pipe investment cost [MEUR] ', 0.0)
190
- print (' Total generation operation cost [MEUR] ', sum(mTEPES.pDiscountedWeight[pp] * mTEPES.pScenProb [pp,scc ]() * OptModel.vTotalGCost [pp,scc,n ]() for n in mTEPES.n ))
191
- print (' Total consumption operation cost [MEUR] ', sum(mTEPES.pDiscountedWeight[pp] * mTEPES.pScenProb [pp,scc ]() * OptModel.vTotalCCost [pp,scc,n ]() for n in mTEPES.n ))
192
- print (' Total emission cost [MEUR] ', sum(mTEPES.pDiscountedWeight[pp] * mTEPES.pScenProb [pp,scc ]() * OptModel.vTotalECost [pp,scc,n ]() for n in mTEPES.n ))
193
- print (' Total network losses penalty cost [MEUR] ', sum(mTEPES.pDiscountedWeight[pp] * mTEPES.pScenProb [pp,scc ]() * OptModel.vTotalNCost [pp,scc,n ]() for n in mTEPES.n ))
194
- print (' Total reliability cost [MEUR] ', sum(mTEPES.pDiscountedWeight[pp] * mTEPES.pScenProb [pp,scc ]() * OptModel.vTotalRCost [pp,scc,n ]() for n in mTEPES.n ))
191
+ print (' Total generation operation cost [MEUR] ', mTEPES.pDiscountedWeight[pp] * sum(mTEPES.pScenProb [pp,scc ]() * OptModel.vTotalGCost [pp,scc,n ]() for n in mTEPES.n ))
192
+ print (' Total consumption operation cost [MEUR] ', mTEPES.pDiscountedWeight[pp] * sum(mTEPES.pScenProb [pp,scc ]() * OptModel.vTotalCCost [pp,scc,n ]() for n in mTEPES.n ))
193
+ print (' Total emission cost [MEUR] ', mTEPES.pDiscountedWeight[pp] * sum(mTEPES.pScenProb [pp,scc ]() * OptModel.vTotalECost [pp,scc,n ]() for n in mTEPES.n ))
194
+ print (' Total network losses penalty cost [MEUR] ', mTEPES.pDiscountedWeight[pp] * sum(mTEPES.pScenProb [pp,scc ]() * OptModel.vTotalNCost [pp,scc,n ]() for n in mTEPES.n ))
195
+ print (' Total reliability cost [MEUR] ', mTEPES.pDiscountedWeight[pp] * sum(mTEPES.pScenProb [pp,scc ]() * OptModel.vTotalRCost [pp,scc,n ]() for n in mTEPES.n ))
195
196
  else:
196
197
  print (f'***** Period: {p}, Scenario: {sc}, Stage: {st} ******')
197
- print (' Total generation investment cost [MEUR] ', sum(mTEPES.pDiscountedWeight[p] * mTEPES.pGenInvestCost [eb ] * OptModel.vGenerationInvest [p,eb ]() for eb in mTEPES.eb if (p,eb) in mTEPES.peb) +
198
- sum(mTEPES.pDiscountedWeight[p] * mTEPES.pGenInvestCost [bc ] * OptModel.vGenerationInvestHeat[p,bc ]() for bc in mTEPES.bc if (p,bc) in mTEPES.pbc))
199
- print (' Total generation retirement cost [MEUR] ', sum(mTEPES.pDiscountedWeight[p] * mTEPES.pGenRetireCost [gd ] * OptModel.vGenerationRetire [p,gd ]() for gd in mTEPES.gd if (p,gd) in mTEPES.pgd))
198
+ print (' Total generation investment cost [MEUR] ', mTEPES.pDiscountedWeight[p] * sum(mTEPES.pGenInvestCost [eb ] * OptModel.vGenerationInvest [p,eb ]() for eb in mTEPES.eb if (p,eb) in mTEPES.peb) +
199
+ mTEPES.pDiscountedWeight[p] * sum(mTEPES.pGenInvestCost [bc ] * OptModel.vGenerationInvestHeat[p,bc ]() for bc in mTEPES.bc if (p,bc) in mTEPES.pbc))
200
+ print (' Total generation retirement cost [MEUR] ', mTEPES.pDiscountedWeight[p] * sum(mTEPES.pGenRetireCost [gd ] * OptModel.vGenerationRetire [p,gd ]() for gd in mTEPES.gd if (p,gd) in mTEPES.pgd))
200
201
  if mTEPES.pIndHydroTopology == 1 and mTEPES.rn:
201
- print (' Total reservoir investment cost [MEUR] ', sum(mTEPES.pDiscountedWeight[p] * mTEPES.pRsrInvestCost [rc ] * OptModel.vReservoirInvest [p,rc ]() for rc in mTEPES.rn if (p,rc) in mTEPES.prc))
202
+ print (' Total reservoir investment cost [MEUR] ', mTEPES.pDiscountedWeight[p] * sum(mTEPES.pRsrInvestCost [rc ] * OptModel.vReservoirInvest [p,rc ]() for rc in mTEPES.rn if (p,rc) in mTEPES.prc))
202
203
  else:
203
204
  print (' Total reservoir investment cost [MEUR] ', 0.0)
204
- print (' Total network investment cost [MEUR] ', sum(mTEPES.pDiscountedWeight[p] * mTEPES.pNetFixedCost [ni,nf,cc] * OptModel.vNetworkInvest [p,ni,nf,cc ]() for ni,nf,cc in mTEPES.lc if (p,ni,nf,cc) in mTEPES.plc))
205
+ print (' Total network investment cost [MEUR] ', mTEPES.pDiscountedWeight[p] * sum(mTEPES.pNetFixedCost [ni,nf,cc] * OptModel.vNetworkInvest [p,ni,nf,cc ]() for ni,nf,cc in mTEPES.lc if (p,ni,nf,cc) in mTEPES.plc))
205
206
  if mTEPES.pIndHydrogen == 1 and mTEPES.pc:
206
- print (' Total H2 pipe investment cost [MEUR] ', sum(mTEPES.pDiscountedWeight[p] * mTEPES.pH2PipeFixedCost [ni,nf,cc] * OptModel.vH2PipeInvest [p,ni,nf,cc ]() for ni,nf,cc in mTEPES.pc if (p,ni,nf,cc) in mTEPES.ppc))
207
+ print (' Total H2 pipe investment cost [MEUR] ', mTEPES.pDiscountedWeight[p] * sum(mTEPES.pH2PipeFixedCost [ni,nf,cc] * OptModel.vH2PipeInvest [p,ni,nf,cc ]() for ni,nf,cc in mTEPES.pc if (p,ni,nf,cc) in mTEPES.ppc))
207
208
  else:
208
209
  print (' Total H2 pipe investment cost [MEUR] ', 0.0)
209
210
  if mTEPES.pIndHeat == 1 and mTEPES.hc:
210
- print (' Total heat pipe investment cost [MEUR] ', sum(mTEPES.pDiscountedWeight[p] * mTEPES.pHeatPipeFixedCost[ni,nf,cc] * OptModel.vHeatPipeInvest [p,ni,nf,cc ]() for ni,nf,cc in mTEPES.hc if (p,ni,nf,cc) in mTEPES.phc))
211
+ print (' Total heat pipe investment cost [MEUR] ', mTEPES.pDiscountedWeight[p] * sum(mTEPES.pHeatPipeFixedCost[ni,nf,cc] * OptModel.vHeatPipeInvest [p,ni,nf,cc ]() for ni,nf,cc in mTEPES.hc if (p,ni,nf,cc) in mTEPES.phc))
211
212
  else:
212
213
  print (' Total heat pipe investment cost [MEUR] ', 0.0)
213
- print (' Total generation operation cost [MEUR] ', sum(mTEPES.pDiscountedWeight[p] * mTEPES.pScenProb [p,sc ]() * OptModel.vTotalGCost [p,sc,n ]() for n in mTEPES.n ))
214
- print (' Total consumption operation cost [MEUR] ', sum(mTEPES.pDiscountedWeight[p] * mTEPES.pScenProb [p,sc ]() * OptModel.vTotalCCost [p,sc,n ]() for n in mTEPES.n ))
215
- print (' Total emission cost [MEUR] ', sum(mTEPES.pDiscountedWeight[p] * mTEPES.pScenProb [p,sc ]() * OptModel.vTotalECost [p,sc,n ]() for n in mTEPES.n ))
216
- print (' Total network losses penalty cost [MEUR] ', sum(mTEPES.pDiscountedWeight[p] * mTEPES.pScenProb [p,sc ]() * OptModel.vTotalNCost [p,sc,n ]() for n in mTEPES.n ))
217
- print (' Total reliability cost [MEUR] ', sum(mTEPES.pDiscountedWeight[p] * mTEPES.pScenProb [p,sc ]() * OptModel.vTotalRCost [p,sc,n ]() for n in mTEPES.n ))
214
+ print (' Total generation operation cost [MEUR] ', mTEPES.pDiscountedWeight[p] * sum(mTEPES.pScenProb [p,sc ]() * OptModel.vTotalGCost [p,sc,n ]() for n in mTEPES.n ))
215
+ print (' Total consumption operation cost [MEUR] ', mTEPES.pDiscountedWeight[p] * sum(mTEPES.pScenProb [p,sc ]() * OptModel.vTotalCCost [p,sc,n ]() for n in mTEPES.n ))
216
+ print (' Total emission cost [MEUR] ', mTEPES.pDiscountedWeight[p] * sum(mTEPES.pScenProb [p,sc ]() * OptModel.vTotalECost [p,sc,n ]() for n in mTEPES.n ))
217
+ print (' Total network losses penalty cost [MEUR] ', mTEPES.pDiscountedWeight[p] * sum(mTEPES.pScenProb [p,sc ]() * OptModel.vTotalNCost [p,sc,n ]() for n in mTEPES.n ))
218
+ print (' Total reliability cost [MEUR] ', mTEPES.pDiscountedWeight[p] * sum(mTEPES.pScenProb [p,sc ]() * OptModel.vTotalRCost [p,sc,n ]() for n in mTEPES.n ))
218
219
 
219
220
  # Adding SolverResults to mTEPES
220
221
  mTEPES.SolverResults = SolverResults