Newer
Older
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
# arc_tech_IA = Arcs(
# name="any",
# # efficiency=[0.5, 0.5, 0.5],
# efficiency={(q, 0): 0.5, (q, 1): 0.5, (q, 2): 0.5},
# efficiency_reverse=None,
# static_loss=None,
# capacity=[3],
# minimum_cost=[2],
# specific_capacity_cost=1,
# capacity_is_instantaneous=False,
# validate=False,
# )
# mynet.add_directed_arc(node_key_a=node_IMP, node_key_b=node_A, arcs=arc_tech_IA)
# # identify node types
# mynet.identify_node_types()
# # converter
# a_nnk = {
# (0, 0, 0): 0.95,
# (0, 0, 1): 0.95,
# (0, 0, 2): 0.95,
# }
# b_nmk = {
# (0, 0, 0): 3,
# (0, 0, 1): 3,
# (0, 0, 2): 3
# }
# x_n0 = {0: 18}
# # get the signals
# inputs, states, outputs = get_two_node_model_signals(
# tf.number_time_intervals(q)
# )
# # create a discretised dynamic system from dictionaries
# dds = dynsys.DiscretisedDynamicSystem(
# a_nnk=a_nnk,
# b_nmk=b_nmk,
# x_n0=x_n0,
# time_frame=tf
# )
# # create a converter
# cvt = Converter(
# time_frame=tf,
# dds=dds,
# turn_key_cost=3,
# inputs=inputs,
# states=states,
# outputs=outputs,
# )
# # no sos, regular time intervals
# ipp = self.build_solve_ipp(
# solver_options={},
# perform_analysis=False,
# plot_results=False, # True,
# print_solver_output=False,
# time_frame=tf,
# networks={"mynet": mynet},
# converters={"mycvt": cvt},
# static_losses_mode=False,
# mandatory_arcs=[],
# max_number_parallel_arcs={},
# # init_aux_sets=init_aux_sets,
# simplify_problem=False,
# )
# assert not ipp.has_peak_total_assessments()
# assert ipp.results["Problem"][0]["Number of constraints"] == 24
# assert ipp.results["Problem"][0]["Number of variables"] == 22
# assert ipp.results["Problem"][0]["Number of nonzeros"] == 49
# # *********************************************************************
# # *********************************************************************
# # validation
# # if uC,M 1,q,0 = 0, then xC,N 1,q,1 = 17.1 # infeasible
# # if uC,M 1,q,0 = 1, then xC,N 1,q,1 = 20.1. # only feasible option
# # if uC,M 1,q,1 = 0, then xC,N 1,q,2 = 19.095 # only feasible option
# # if uC,M 1,q,1 = 1, then xC,N 1,q,2 = 22.095 # infeasible
# # if uC,M 1,q,2 = 0, then xC,N 1,q,3 = 18.14025 # feasible
# # if uC,M 1,q,2 = 1, then xC,N 1,q,3 = 21.14025 # feasible
# true_u_imqk = {
# ('mycvt', 0, q, 0): 1,
# ('mycvt', 0, q, 1): 0,
# ('mycvt', 0, q, 2): 0, # could also be 1
# }
# true_x_inqk = {
# ('mycvt', 0, q, 0): 20.1,
# ('mycvt', 0, q, 1): 19.095,
# ('mycvt', 0, q, 2): 18.14025, # could also be 21.14025
# }
# # check the inputs
# for imqk, u in true_u_imqk.items():
# assert math.isclose(
# pyo.value(ipp.instance.var_u_imqk[imqk]),
# u,
# abs_tol=1e-6,
# )
# # check the states
# for inqk, x in true_x_inqk.items():
# assert math.isclose(
# pyo.value(ipp.instance.var_x_inqk[inqk]),
# x,
# abs_tol=1e-6,
# )
# *************************************************************************
# *************************************************************************
# TODO: test non-simplifiable problems with time varying prices on select assessments
# TODO: test non-simplifiable problems with volume varying prices on select assessments
# *****************************************************************************
# *****************************************************************************