示例#1
0
 def value_unserved_demand(self):
     if self._VoLL_init:
         return get_node_attributes(self, "VoLL")
     else:
         raise ValueError(
             "Value of Lost Load (VoLL) for gas consumption has not been initialised."
         )
示例#2
0
def get_node_attributes_():
    '''Unchanged from v1.11'''
    g = Graph([(1, 5), (5, 5)])
    g.nodes[5]['foo'] = 'bar'
    g.nodes[1]['foo'] = 'boo'
    # Works as expected
    d = function.get_node_attributes(g, 'foo')
    print(type(d))  # <class 'dict'>
    print(len(d))  # 2
    print(d)  # {1: 'boo', 5: 'bar'}
示例#3
0
def get_node_attributes_():
    '''
    get_node_attributes(<Graph>, <attribute key>) returns a dict 
    - The <attribute key> can be anything that could be a key (i.e. any immutable object), but in most cases it will be a string. Multiple keys cannot
      be specified
    - The returned dict's keys are node identifiers who have the desired attribute key
    '''
    g = Graph([(1, 5), (5, 5)])
    g.node[5]['foo'] = 'bar'
    g.node[1]['foo'] = 'boo'
    # Works as expected
    #d = function.get_node_attributes(g, 'foo')
    #print(type(d)) # <class 'dict'>
    #print(len(d)) # 2
    #print(d) # {1: 'boo', 5: 'bar'}
    # Does not work. There is no object with the literal attribute key ('foo', 'hi')
    g.node[1]['hi'] = 'bye'
    d = function.get_node_attributes(g, ('foo', 'hi'))
    print(d)  # {}
    g.node[1][('foo', 'hi')] = 'lmao'
    print(function.get_node_attributes(g, ('foo', 'hi')))  # {1: 'lmao'}
                                                else:
                                                    fichier.write("probleme\n")
                                                    print("probleme")

                            for noeud in G.nodes():
                                fichier.write(
                                    str(noeud) + " " + str(G.nodes[noeud]) +
                                    "\n")
                            for u, v, edata in G.edges(data=True):
                                fichier.write(
                                    str(u) + "'" + str(v) + " " +
                                    str(edata["label"]) + "\n")

                            #fichier.write(str(G.nodes.data())+"\n")
                            #fichier.write(str(G.edges.data())+"\n")
                            pos = get_node_attributes(G, 'coordonnees')
                            #print(pos)

                            #plt.figure(figsize =(5,12))

                            red_edges = [(1, 2), (2, 1), (1, 3), (3, 1),
                                         (1, 5), (5, 1), (2, 4), (4, 2),
                                         (3, 4), (4, 3), (2, 5), (5, 2)]
                            green_edges = []
                            blue_edges = []
                            black_edges = []
                            weights = []
                            #black_edges = [edge for edge in G.edges() if edge not in red_edges]
                            for u, v, edata, in G.edges(data=True):
                                if (u, v) not in red_edges:
                                    #                             if contient_arete((u,v), GC, compteur%2) :
 def _containsRobot(self, robotID):
     return robotID in get_node_attributes(self.graph, ROBOT_ID).values()
 def getRobots(self):
     '''Returns a dict where keys are positions and values robotID of robots on the board'''
     return get_node_attributes(self.graph, ROBOT_ID)
示例#7
0
 def maximum_pressure_bounds(self):
     if self._p_max_init:
         return get_node_attributes(self, "p_max")
     else:
         raise ValueError(
             "Upper bounds on nodal pressures have not been initialised.")
示例#8
0
 def nodal_demands(self):
     if self._d_init:
         return get_node_attributes(self, "d")
     else:
         raise ValueError(
             "Maximum nodal injections have not been initialised.")
示例#9
0
 def maximum_nodal_injections(self):
     if self._s_max_init:
         return get_node_attributes(self, "s_max")
     else:
         raise ValueError(
             "Maximum nodal injections have not been initialised.")
示例#10
0
 def minimum_nodal_injections(self):
     if self._s_min_init:
         return get_node_attributes(self, "s_min")
     else:
         raise ValueError("Nodal consumptions have not been initialised.")