Skip to content
Snippets Groups Projects
test_esipp_problem.py 274 KiB
Newer Older
  • Learn to ignore specific revisions
  •     #     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
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
    
    # *****************************************************************************
    
    # *****************************************************************************