Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
)
for qpk in tf.qpk()
}
mynet.add_import_node(
node_key=imp_node_key,
prices=imp_prices
)
# export node
exp_node_key = 'thatexpnode'
exp_prices = {
qpk: ResourcePrice(
prices=1.5,
volumes=None,
)
for qpk in tf.qpk()
}
mynet.add_export_node(
node_key=exp_node_key,
prices=exp_prices,
)
# add arc without fixed losses from import node to export
arc_tech_IE = Arcs(
name="IE",
# efficiency=[1, 1, 1, 1],
efficiency={(0, 0): 1, (0, 1): 1, (0, 2): 1, (0, 3): 1},
efficiency_reverse=None,
static_loss=None,
validate=False,
capacity=[0.5, 1.0, 2.0],
minimum_cost=[5, 5.1, 5.2],
specific_capacity_cost=1,
capacity_is_instantaneous=False,
)
mynet.add_directed_arc(
node_key_a=imp_node_key, node_key_b=exp_node_key, arcs=arc_tech_IE
)
# no sos, regular time intervals
ipp = self.build_solve_ipp(
solver_options={},
perform_analysis=False,
plot_results=False, # True,
print_solver_output=False,
networks={"mynet": mynet},
time_frame=tf,
static_losses_mode=InfrastructurePlanningProblem.STATIC_LOSS_MODE_DEP,
mandatory_arcs=[],
max_number_parallel_arcs={},
use_prices_block=use_prices_block
)
# export prices are higher: it makes sense to install the arc since the
# revenue (@ max. cap.) exceeds the cost of installing the arc
assert (
True
in ipp.networks["mynet"]
.edges[(imp_node_key, exp_node_key, 0)][Network.KEY_ARC_TECH]
.options_selected
)
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
# overview
(imports_qpk,
exports_qpk,
balance_qpk,
import_costs_qpk,
export_revenue_qpk,
ncf_qpk,
aggregate_static_demand_qpk,
aggregate_static_supply_qpk,
aggregate_static_balance_qpk) = statistics(ipp)
# there should be no imports
abs_tol = 1e-6
abs_tol = 1e-3
imports_qp = sum(imports_qpk[qpk] for qpk in tf.qpk() if qpk[1] == 0)
assert imports_qp > 0.0 - abs_tol
abs_tol = 1e-3
import_costs_qp = sum(import_costs_qpk[qpk] for qpk in tf.qpk() if qpk[1] == 0)
assert import_costs_qp > 0.0 - abs_tol
# there should be no exports
abs_tol = 1e-2
exports_qp = sum(exports_qpk[(q, 0, k)] for k in tf.time_intervals[q])
export_revenue_qp = sum(export_revenue_qpk[(q, 0, k)] for k in tf.time_intervals[q])
assert exports_qp > 0.0 - abs_tol
assert export_revenue_qp > 0.0 - abs_tol
# the revenue should exceed the costs
abs_tol = 1e-2
assert (
export_revenue_qp > import_costs_qp - abs_tol
)
# the capex should be positive
abs_tol = 1e-6
assert pyo.value(ipp.instance.var_capex) > 0 - abs_tol
# *************************************************************************
# *************************************************************************
# *****************************************************************************
# *****************************************************************************