Skip to content

Commit

Permalink
Continue consolidating constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
tarnold17 committed Sep 23, 2024
1 parent 13817e3 commit f9052f9
Show file tree
Hide file tree
Showing 4 changed files with 182 additions and 357 deletions.
4 changes: 2 additions & 2 deletions docs/model_library/strategic_water_management/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ Strategic Model Mathematical Notation

:math:`\textcolor{red}{S_{k}^{DisposalCapacity}}` = Slack variable to provide necessary disposal capacity

:math:`\textcolor{red}{S_{r}^{TreamentCapacity}}` = Slack variable to provide necessary treatment capacity
:math:`\textcolor{red}{S_{r}^{TreatmentCapacity}}` = Slack variable to provide necessary treatment capacity

:math:`\textcolor{red}{S_{o}^{BeneficialResueCapacity}}` = Slack variable to provide necessary beneficial reuse capacity

Expand Down Expand Up @@ -802,7 +802,7 @@ The set :math:`\textcolor{blue}{J}` should also include the 0th case (e.g. 0 bbl
\sum_{l \in L | (l, r) \in LLA}\textcolor{red}{F_{l,r,t}^{Piped}}
+ \sum_{l \in L | (l, r) \in LLT}\textcolor{red}{F_{l,r,t}^{Trucked}}
\leq \textcolor{red}{T_{r,[t]}^{Capacity}}
\leq \textcolor{red}{T_{r,[t]}^{Capacity}} + \textcolor{red}{S_{r}^{TreatmentCapacity}}
**Treatment Feed Balance:** :math:`\forall \textcolor{blue}{r \in R}, \textcolor{blue}{t \in T}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,130 +575,6 @@ def TerminalProductionTankLevelBalanceRule(model, p, t):
else:
raise Exception("storage type not supported")

def StorageSiteBalanceRule(model, s, t):
if t == model.s_T.first():
return model.v_L_Storage[s, t] == model.p_lambda_Storage[s] + sum(
model.v_F_Piped[l, s, t] for l in model.s_L if model.p_LLA[l, s]
) + sum(
model.v_F_Trucked[l, s, t] for l in model.s_L if model.p_LLT[l, s]
) - sum(
model.v_F_Piped[s, l, t] for l in model.s_L if model.p_LLA[s, l]
) - sum(
model.v_F_Trucked[s, l, t] for l in model.s_L if model.p_LLT[s, l]
)
else:
return model.v_L_Storage[s, t] == model.v_L_Storage[
s, model.s_T.prev(t)
] + sum(
model.v_F_Piped[l, s, t] for l in model.s_L if model.p_LLA[l, s]
) + sum(
model.v_F_Trucked[l, s, t] for l in model.s_L if model.p_LLT[l, s]
) - sum(
model.v_F_Piped[s, l, t] for l in model.s_L if model.p_LLA[s, l]
) - sum(
model.v_F_Trucked[s, l, t] for l in model.s_L if model.p_LLT[s, l]
)

model.StorageSiteBalance = Constraint(
model.s_S,
model.s_T,
rule=StorageSiteBalanceRule,
doc="Storage site balance rule",
)

def PipelineCapacityExpansionRule(model, l, l_tilde):
if model.p_LLA[l, l_tilde]:
if model.p_LLA[l_tilde, l]:
return (
model.v_F_Capacity[l, l_tilde]
== model.p_sigma_Pipeline[l, l_tilde]
+ model.p_sigma_Pipeline[l_tilde, l]
+ model.v_S_PipelineCapacity[l, l_tilde]
)
else:
return (
model.v_F_Capacity[l, l_tilde]
== model.p_sigma_Pipeline[l, l_tilde]
+ model.v_S_PipelineCapacity[l, l_tilde]
)

else:
return Constraint.Skip

model.PipelineCapacityExpansion = Constraint(
model.s_L,
model.s_L,
rule=PipelineCapacityExpansionRule,
doc="Pipeline capacity construction/expansion",
)

def PipelineCapacityRule(model, l, l_tilde, t):
if model.p_LLA[l, l_tilde]:
return model.v_F_Piped[l, l_tilde, t] <= model.v_F_Capacity[l, l_tilde]
else:
return Constraint.Skip

model.PipelineCapacity = Constraint(
(model.s_L - model.s_O - model.s_K),
(model.s_L - model.s_F),
model.s_T,
rule=PipelineCapacityRule,
doc="Pipeline capacity",
)

def StorageCapacityExpansionRule(model, s):
return (
model.v_X_Capacity[s]
== model.p_sigma_Storage[s] + model.v_S_StorageCapacity[s]
)

model.StorageCapacityExpansion = Constraint(
model.s_S,
rule=StorageCapacityExpansionRule,
doc="Storage capacity construction/expansion",
)

def StorageCapacityRule(model, s, t):
return model.v_L_Storage[s, t] <= model.v_X_Capacity[s]

model.StorageCapacity = Constraint(
model.s_S, model.s_T, rule=StorageCapacityRule, doc="Storage capacity"
)

def DisposalCapacityExpansionRule(model, k):
return (
model.v_D_Capacity[k]
== model.p_sigma_Disposal[k] + model.v_S_DisposalCapacity[k]
)

model.DisposalCapacityExpansion = Constraint(
model.s_K,
rule=DisposalCapacityExpansionRule,
doc="Disposal capacity construction/expansion",
)

def DisposalCapacityRule(model, k, t):
return (
sum(model.v_F_Piped[l, k, t] for l in model.s_L if model.p_LLA[l, k])
+ sum(model.v_F_Trucked[l, k, t] for l in model.s_L if model.p_LLT[l, k])
<= model.v_D_Capacity[k]
)

model.DisposalCapacity = Constraint(
model.s_K, model.s_T, rule=DisposalCapacityRule, doc="Disposal capacity"
)

def TreatmentCapacityRule(model, r, t):
return (
sum(model.v_F_Piped[l, r, t] for l in model.s_L if model.p_LLA[l, r])
+ sum(model.v_F_Trucked[l, r, t] for l in model.s_L if model.p_LLT[l, r])
<= model.p_sigma_Treatment[r] + model.v_S_TreatmentCapacity[r]
)

model.TreatmentCapacity = Constraint(
model.s_R, model.s_T, rule=TreatmentCapacityRule, doc="Treatment capacity"
)

def TreatmentBalanceRule(model, r, t):
return (
model.p_epsilon_Treatment[r, "TDS"]
Expand Down Expand Up @@ -735,21 +611,6 @@ def BeneficialReuseCapacityRule(model, o, t):

# COMMENT: Beneficial reuse capacity constraint has not been tested yet

def ExternalSourcingCostRule(model, f, p, t):
return (
model.v_C_Sourced[f, p, t]
== (model.v_F_Sourced[f, p, t] + model.v_F_Trucked[f, p, t])
* model.p_pi_Sourcing[f]
)

model.ExternalSourcingCost = Constraint(
model.s_F,
model.s_CP,
model.s_T,
rule=ExternalSourcingCostRule,
doc="Externally sourced water cost",
)

def TotalExternalSourcingCostRule(model):
return model.v_C_TotalSourced == sum(
sum(sum(model.v_C_Sourced[f, p, t] for f in model.s_F) for p in model.s_CP)
Expand Down
Loading

0 comments on commit f9052f9

Please sign in to comment.