예제 #1
0
 def __init__(self,
              *filename,
              file_name: str = "networkDeserialization.txt"):
     Logger.__init__(self, file_name)
     self.f.write("Network Deserialization Data")
     self.pipe_list: {Pipe} = self.deserialize_pipe_list(*filename)
     self.valve_list: {Valve} = self.deserialize_valve_list(*filename)
     self.short_pipe_list: {ShortPipe
                            } = self.deserialize_short_pipe_list(*filename)
     self.resistor_list: {Resistor
                          } = self.deserialize_resistor_list(*filename)
     self.compressor_station_list: {
         CompressorStation
     } = self.deserialize_compressor_station_list(*filename)
     self.node_list: {Innode} = self.deserialize_innode_list(*filename)
     self.source_list: {Source} = self.deserialize_source_list(*filename)
     self.sink_list: {Sink} = self.deserialize_sink_list(*filename)
     self.control_valve_list: {
         ControlValve
     } = self.deserialize_control_valve_list(*filename)
     self.energy_consumption_measurement = self.deserialize_energy_consumption_measurement(
         *filename)
     self.power_measurement = self.deserialize_power_measurement(*filename)
     CompressorStation.set_energy_power_measurement(
         self.energy_consumption_measurement, self.power_measurement)
     Source.read_constant_data(self.source_list)
     self.f.close()
예제 #2
0
    def __init__(self, networkDescerialization: NetworkDeserialization,
                 scenario: Scenario):
        Network.__init__(self, networkDeserialization, scenario)
        Logger.__init__(self, "optimization.txt")
        self.model = Model("Minimization of Network Flow Operation Costs")
        element_q, node_q, node_p = self.define_model_variables()

        # self.define_model_variables()
        for pipe in networkDeserialization.pipe_list.values():
            m = Model("approximation")
            variable_dict = {}
            pipe.p_e = m.addVar(lb=0.0, ub=0.0, vtype='C')
            conti_functon: ContiFunction = ContiFunction(pipe, m)
            conti_functon._model_definition(pipe, variable_dict)
            m.setObjective(4 * variable_dict[pipe.id] + 3, "minimize")
            m.optimize()
            # conti_functon._model_definition(pipe, variable_dict)

            # conti: ContiFunction = ContiFunction(pipe, m)
            # print(conti.optimize())
            print("Conti Function Approximation p_min = {}, p_max = {}".format(
                pipe.from_node.pressure_min, pipe.from_node.pressure_max))
            # friction:FrictionFunctionApproximation = FrictionFunctionApproximation(pipe.from_node.pressure_min, pipe.from_node.pressure_max,
            #                                                                        pipe.from_node.flow_min, pipe.from_node.flow_max,
            #                                                                        pipe, m)
            # print(friction.optimize())
            # print("Friction Function Approximation p_min ={} p_max ={} q_min ={} q_max ={}".format(pipe.from_node.pressure_min, pipe.from_node.pressure_max, pipe.from_node.flow_min, pipe.from_node.flow_max))
            # impact: ImpactFunctionApproximation = ImpactFunctionApproximation(pipe.to_node.pressure_min, pipe.to_node.pressure_max, pipe.to_node.flow_min, pipe.to_node.flow_max, pipe, m)
            # print(impact.optimize())
            # print("ImpactFunctionApproximation p_min ={}, p_max ={} q_min ={}, q_max ={}".format(pipe.to_node.pressure_min, pipe.to_node.pressure_max, pipe.to_node.flow_min, pipe.to_node.flow_max))
            # gas_consumption: GasFlowCompressorConsumptionApproximation = GasFlowCompressorConsumptionApproximation(4000000, 6000000,4000000, 6000000,
            #                                                                                                        1000.0, 1000.0, model=m, compressor=pipe)
            # print(gas_consumption.optimize())
            # print("GasFlowCompressorConsumption  p_min ={}, p_max ={}, p_v_min = {} p_v_max = {} q_min ={}, q_max ={}".format(pipe.from_node.pressure_min, pipe.from_node.pressure_max, pipe.to_node.pressure_min, pipe.to_node.pressure_max, pipe.to_node.flow_min, pipe.to_node.flow_max))
        self.model.optimize()
 def __init__(self, x1_min: float, x1_max: float, x2_min: float, x2_max: float, x3_min: float, x3_max, f_x1_x2_x3:
 Callable, threshold: int = 3, optimization_type: bool = True, file_name="approximation_3d.txt", simulation_id="id", model=None):
     Logger.__init__(self, file_name)
     self.x1_min: float = x1_min
     self.x1_max: float = x1_max
     self.x2_min: float = x2_min
     self.x2_max: float = x2_max
     self.x3_min: float = x3_min
     self.x3_max: float = x3_max
     self.mesh_3d: _3dMesh = _3dMesh(x1_min, x1_max, x2_min, x2_max, x3_min, x3_max, f_x1_x2_x3, threshold)
     self.model = model
     self.f_x1_x2_x3 = f_x1_x2_x3
     self.optimization_type = optimization_type
     self.simulation_id = simulation_id
예제 #4
0
 def __init__(self,
              x1_min,
              x1_max,
              _f_x1_: Callable,
              threshold: int = 3,
              optimizaiton_type: bool = True,
              file_name="approximation_1d.txt",
              simulation_id="id",
              model: Model = None):
     Logger.__init__(self, file_name)
     self.x1_min = x1_min
     self.x1_max = x1_max
     self.f_x1 = _f_x1_
     self.mesh1d: _1DMesh = _1DMesh(x1_min, x1_max, _f_x1_, threshold)
     self.model = model
     self.optimization_type = optimizaiton_type
     self.simulation_id = simulation_id
 def __init__(self,
              x1_min: float,
              x1_max: float,
              x2_min: float,
              x2_max: float,
              _f_x1_x2: Callable,
              threshold: int = 3,
              optimization_type: bool = True,
              file_name="approximation_2d.txt",
              simulation_id="id",
              model=None):
     Logger.__init__(self, file_name)
     self.x1_max = x1_max
     self.x1_min = x1_min
     self.x2_max = x2_max
     self.x2_min = x2_min
     self.mesh_2d = _2DMesh(x1_min, x1_max, x2_min, x2_max, _f_x1_x2,
                            threshold)
     self.model = model
     self.fx1_x2 = _f_x1_x2
     self.optimization_type = optimization_type
     self.simulation_id = simulation_id