Skip to content

Commit f5575b1

Browse files
committed
Set negative commitment to zero in pass-through inputs
1 parent 810f692 commit f5575b1

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

gridpath/project/operations/fix_commitment.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import os.path
2323
from pandas import read_csv
2424
from pyomo.environ import Set, Param, NonNegativeReals, Expression
25+
import warnings
2526

2627

2728
from gridpath.auxiliary.auxiliary import (
@@ -373,13 +374,23 @@ def export_pass_through_inputs(
373374
fixed_commitment_file, delimiter="\t", lineterminator="\n"
374375
)
375376
for g, tmp in m.FNL_COMMIT_PRJ_OPR_TMPS:
377+
commitment_value = m.Commitment[g, tmp].expr.value
378+
if commitment_value < 0:
379+
warnings.warn(
380+
f"Commitment for ({g}, {tmp}) is "
381+
f"{commitment_value}; changing to 0 in "
382+
f"pass-through inputs to avoid data type error "
383+
f"when loading into next stage. This is "
384+
f"expected due to solver optimality tolerances."
385+
)
386+
commitment_value = 0
376387
fixed_commitment_writer.writerow(
377388
[
378389
g,
379390
tmp,
380391
stage,
381392
final_commitment_stage_dict[g],
382-
m.Commitment[g, tmp].expr.value,
393+
commitment_value,
383394
]
384395
)
385396

0 commit comments

Comments
 (0)