def generate_graph_laplacian_list(self, node_size, orders): if self.graph_topology is None: print("Network topology is not initialized yet") return 0 self.graph_laplacian_list = list() self.graph_laplacian_list.append(np.identity(node_size)) lap = rd.make_laplacian_matrix(self.graph_topology) base = rd.make_laplacian_matrix(self.graph_topology) self.graph_laplacian_list.append( rd.make_laplacian_matrix(self.graph_topology)) if orders > 2: for i in range(2, orders): lap = np.matmul(lap, base) self.graph_laplacian_list.append(lap) return self.graph_laplacian_list
LOG_FILE = "/home/yanzx1993/VNR_A3C_LOG/LOG" ENTROPY_WEIGHT = 0.5 EPS = 1e-6 INPUT_FEATURES = 5 EXTRACTED_FEATURES = INPUT_FEATURES * 64 SNODE_SIZE = 100 VNODE_FEATURES_SIZE = 3 #NUM_AGENT = mp.cpu_count()#4 or 8 i guess NUM_AGENT = 24 ORDERS = 3 GAMMA = 0.99 ALIVE_TIME = 50000 #saver=tf.train.Saver() LAPLACIAN = rd.make_laplacian_matrix(G) LAPLACIAN_LIST = rd.make_laplacian_list(G, SNODE_SIZE, ORDERS) LAPLACIAN_TENSOR = np.stack(LAPLACIAN_LIST) RANDOM_SEED = 93 def random_gen(rate): rv = poisson(rate) plist = [] for i in range(int(rate * 100 + 1)): plist.append(rv.cdf(i)) rnd = np.random.rand() for i in range(len(plist)): if (rnd <= plist[i]): #print(i)
import numpy as np import tensorflow as tf import random_graph_gen as rd import time start = time.clock() node = 100 input_features = 4 output_features = 4 * 32 orders = 3 learning_rate = 0.000001 max_steps = 90 n = rd.make_random_graph(node, 0.5) adj = rd.make_adj_matrix(n) lap = rd.make_laplacian_matrix(n) base = rd.make_laplacian_matrix(n) sess = tf.InteractiveSession() with tf.name_scope("graph_laplacian"): lap_ls = [] lap_ls.append(np.identity(node)) lap_ls.append(lap) for i in range(2, orders): lap = np.matmul(lap, base) lap_ls.append(lap) with tf.name_scope("placeholders"): x = tf.placeholder(tf.float32, [input_features, node], name="state") y_ = tf.placeholder(tf.float32, [None, node], name="actions")