SimualtionPlanner-Tutorial

ST-GCN
Author

SEOYEON CHOI

Published

March 18, 2023

table

BLOCK

List

  • max_iter=30/linear/epoch=50~200/STGCN,IT-STGCN
  • missing 만드는 법(block 생각)

4.반복의미 없음, 고정된 값 출력되어서

할 거

  • missing 0일 때 STGCN/GNAR 비교(CHECK)
  • baseline 제시될만한 데이터셋 뭘까.
  • GNAR warning 안 나오는 법 찾아보기
  • mindex가 중요ㅡ mtype은 기록용으로만 사용됨

_df = pd.concat([_a,,_b,_c],axis=0)

save_data(_df, './data/Pedal_estgcn_randomly_by_rate.pkl')

imports

https://pytorch-geometric-temporal.readthedocs.io/en/latest/_modules/index.html

import itstgcnEvolveGCNH
import torch
import itstgcnEvolveGCNH.planner 
from torch_geometric_temporal.dataset import ChickenpoxDatasetLoader
loader1 = ChickenpoxDatasetLoader()
from torch_geometric_temporal.dataset import PedalMeDatasetLoader
loader2 = PedalMeDatasetLoader()
from torch_geometric_temporal.dataset import WikiMathsDatasetLoader
loader3 = WikiMathsDatasetLoader()
from torch_geometric_temporal.dataset import WindmillOutputLargeDatasetLoader
loader4 = WindmillOutputLargeDatasetLoader()
from torch_geometric_temporal.dataset import WindmillOutputMediumDatasetLoader
loader5 = WindmillOutputMediumDatasetLoader()
from torch_geometric_temporal.dataset import WindmillOutputSmallDatasetLoader
loader6 = WindmillOutputSmallDatasetLoader()
loader6 = itstgcnEvolveGCNH.load_data('./data/Windmillsmall.pkl')
# dataset6 = _a.get_dataset(lags=8)
from torch_geometric_temporal.dataset import MontevideoBusDatasetLoader
loader10 = MontevideoBusDatasetLoader()
import numpy as np
import pandas as pd

read data

# _data = itstgcn.load_data('./data/fivenodes.pkl')
# _edges = torch.tensor(_data['edges']).nonzero().tolist()
# _FX = _data['f'].tolist()
# _node_ids = {'node1':0, 'node2':1, 'node3':2, 'node4':3, 'node5':4} 
# data_dict = {'edges':_edges, 'node_ids':_node_ids, 'FX':_FX}
data_dict = itstgcn.load_data('./data/fivenodes.pkl')
loader = itstgcn.DatasetLoader(data_dict)

PLNR_STGCN_RAND

plans_stgcn_rand = {
    'max_iteration': 30, 
    'method': ['STGCN', 'IT-STGCN'],
    'mrate': [0,0.7,0.8],
    'lags': [2], 
    'nof_filters': [12], 
    'inter_method': ['linear','nearest'],
    'epoch': [50]
}
plnr = itstgcn.planner.PLNR_STGCN_RAND(plans_stgcn_rand,loader1,dataset_name='fivenodes')
plnr.simulate()
plans_stgcn_rand = {
    'max_iteration': 30, 
    'method': ['STGCN', 'IT-STGCN'],
    'mrate': [0.3,0.8],
    'lags': [4], 
    'nof_filters': [16], 
    'inter_method': ['linear'],
    'epoch': [50]
}
plnr = itstgcn.planner.PLNR_STGCN_RAND(plans_stgcn_rand,loader1,dataset_name='chickenpox')
plnr.simulate()
plans_stgcn_rand = {
    'max_iteration': 30, 
    'method': ['STGCN', 'IT-STGCN'],
    'mrate': [0],
    'lags': [4], 
    'nof_filters': [16], 
    'inter_method': ['linear'],
    'epoch': [50]
}
plnr = itstgcn.planner.PLNR_STGCN_RAND(plans_stgcn_rand,loader1,dataset_name='chickenpox')
plnr.simulate()
plans_stgcn_rand = {
    'max_iteration': 1, 
    'method': ['STGCN', 'IT-STGCN'], 
    'mrate': [0],
    'lags': [8], 
    'nof_filters': [12], 
    'inter_method': ['linear'],
    'epoch': [50]
}
plnr = itstgcn.planner.PLNR_STGCN_RAND(plans_stgcn_rand,loader6,dataset_name='windmillsmall')
plnr.simulate()
plans_stgcn_rand = {
    'max_iteration': 10, 
    'method': ['STGCN', 'IT-STGCN'], 
    'mrate': [0.3],
    'lags': [2, 4], 
    'nof_filters': [12], 
    'inter_method': ['linear'],
    'epoch': [50]
}
plnr = itstgcnadd.planner.PLNR_STGCN_RAND(plans_stgcn_rand,loader3,dataset_name='wikimath')
plnr.simulate()
plans_stgcn_rand = {
    'max_iteration': 1, 
    'method': ['STGCN', 'IT-STGCN'], 
    'RecurrentGCN' : ['DCRNN'],
    'mrate': [0],
    'lags': [8], 
    'nof_filters': [12], 
    'inter_method': ['linear'],
    'epoch': [50]
}
plnr = itstgcnadd.planner.PLNR_STGCN_RAND(plans_stgcn_rand,loader6,dataset_name='windmillsmall')
plnr.simulate()
my_list = [[] for _ in range(11)] #windmilsmall
another_list = list(range(5000,7500)) # 17470*0.8 = 13976.0
my_list[1] = another_list
my_list[3] = another_list
my_list[5] = another_list
my_list[7] = another_list
my_list[9] = another_list
mindex = my_list
# mindex= [[],[],[],list(range(50,150)),[]]  # node 1
# mindex= [list(range(10,100)),[],list(range(50,80)),[],[]] # node 2
# mindex= [list(range(10,100)),[],list(range(50,80)),list(range(50,150)),[]] # node3
plans_stgcn_block = {
    'max_iteration': 1, 
    'method': ['STGCN', 'IT-STGCN'], 
    'mindex': [mindex],
    'lags': [8], 
    'nof_filters': [12], 
    'inter_method': ['linear'],
    'epoch': [50]
}
plnr = itstgcnEvolveGCNH.planner.PLNR_STGCN_MANUAL(plans_stgcn_block,loader6,dataset_name='windmillsmall')
plnr.simulate(mindex=mindex,mtype='block')

PLNR_STGCN_MANUAL

my_list = [[] for _ in range(20)] #chickenpox
another_list = list(range(100,400))
my_list[1] = another_list
my_list[3] = another_list
my_list[5] = another_list
my_list[7] = another_list
my_list[9] = another_list
my_list[11] = another_list
my_list[13] = another_list
my_list[15] = another_list
mindex = my_list
my_list = [[] for _ in range(15)] #pedalme
another_list = list(range(5,35))
my_list[2] = another_list
my_list[4] = another_list
my_list[7] = another_list
my_list[11] = another_list
mindex = my_list
import random
my_list = [[] for _ in range(1068)] # wikimath
another_list = random.sample(range(570), 72)
# my_list에서 250개 요소 무작위 선택
selected_indexes = random.sample(range(len(my_list)), 250)
# 선택된 요소에 해당하는 값들을 another_list에 할당
for index in selected_indexes:
    my_list[index] = another_list
# _data = itstgcn.load_data('./data/fivenodes.pkl')
# _edges = torch.tensor(_data['edges']).nonzero().tolist()
# _FX = _data['f'].tolist()
# _node_ids = {'node1':0, 'node2':1, 'node3':2, 'node4':3, 'node5':4} 
# data_dict = {'edges':_edges, 'node_ids':_node_ids, 'FX':_FX}
# loader = itstgcn.DatasetLoader(data_dict)
# data_dict = itstgcn.load_data('./data/fivenodes.pkl')
# loader = itstgcn.DatasetLoader(data_dict)
# mindex= [[],[],[],list(range(50,150)),[]]
# mindex= [list(range(50,150)),[],list(range(50,90)),list(range(50,150)),[]] # node 2
plans_stgcn_block = {
    'max_iteration': 10, 
    'method': ['STGCN', 'IT-STGCN'],
    'RecurrentGCN' : ['GConvGRU','GConvLSTM'],
    'mindex': [mindex],
    'lags': [4], 
    'nof_filters': [16], 
    'inter_method': ['linear'],
    'epoch': [50],
    'lr': [0.01]
}
plnr = itstgcn.planner.PLNR_STGCN_MANUAL(plans_stgcn_block,loader1,dataset_name='chickenpox')

plnr.simulate(mindex=mindex,mtype='block')
# mindex= [[],[],[],list(range(50,150)),[]]
# mindex= [list(range(50,150)),[],list(range(50,90)),list(range(50,150)),[]] # node 2
plans_stgcn_block = {
    'max_iteration': 10, 
    'method': ['STGCN', 'IT-STGCN'], 
    'RecurrentGCN' : ['GConvGRU','GConvLSTM'],
    'mindex': [mindex],
    'lags': [2,4], 
    'nof_filters': [12], 
    'inter_method': ['linear'],
    'epoch': [50]
}
plnr = itstgcnadd.planner.PLNR_STGCN_MANUAL(plans_stgcn_block,loader3,dataset_name='wikimath')
plnr.simulate(mindex=mindex,mtype='block')

PLNR_GNAR_RAND

# _data = itstgcn.load_data('./data/fivenodes.pkl')
# _edges = torch.tensor(_data['edges']).nonzero().tolist()
# _FX = _data['f'].tolist()
# _node_ids = {'node1':0, 'node2':1, 'node3':2, 'node4':3, 'node5':4} 
# data_dict = {'edges':_edges, 'node_ids':_node_ids, 'FX':_FX}
# loader = itstgcn.DatasetLoader(data_dict)
# data_dict=itstgcn.load_data('./data/fivenodes.pkl')
# loader = itstgcn.DatasetLoader(data_dict)
plans_gnar_rand = {
    'max_iteration': 30, 
#    'method': ['GNAR'], 
    'mrate': [0.1],
    'lags': [4], 
#    'nof_filters': [8,16], 
    'inter_method': ['linear','cubic'],
#    'epoch': [1]
}
plnr = itstgcn.planner.PLNR_GNAR_RAND(plans_gnar_rand,loader2,dataset_name='pedalme')
plnr.simulate()
plans_gnar_rand = {
    'max_iteration': 3, 
#    'method': ['GNAR'], 
    'mrate': [0],
    'lags': [2,4], 
#    'nof_filters': [8,16], 
    'inter_method': ['linear'],
#    'epoch': [1]
}
plnr = itstgcn.planner.PLNR_GNAR_RAND(plans_gnar_rand,loader3,dataset_name='wikimath')
plnr.simulate()
plans_gnar_rand = {
    'max_iteration': 3, 
#    'method': ['GNAR'], 
    'mrate': [0,0.3],
    'lags': [8], 
#    'nof_filters': [8,16], 
    'inter_method': ['linear'],
#    'epoch': [1]
}
plnr = itstgcn.planner.PLNR_GNAR_RAND(plans_gnar_rand,loader5,dataset_name='windmillmedium')
plnr.simulate()

PLNR_GNAR_BLOCK

# _data = itstgcn.load_data('./data/fivenodes.pkl')
# _edges = torch.tensor(_data['edges']).nonzero().tolist()
# _FX = _data['f'].tolist()
# _node_ids = {'node1':0, 'node2':1, 'node3':2, 'node4':3, 'node5':4} 
# data_dict = {'edges':_edges, 'node_ids':_node_ids, 'FX':_FX}
# loader = itstgcn.DatasetLoader(data_dict)
# loader = itstgcn.load_data('./data/fivenodes.pkl')
 Nodes : 26

vertices represent 26 windmills
-Edges : 676

weighted edges describe the strength of relationships
- Time : 17464
my_list = [[] for _ in range(26)] #medium
another_list = list(range(1000,2000))+list(range(4000,5000))+list(range(7000,8000)) #17464

for i in np.array(random.sample(range(0, 26), 15)):
    my_list[i] = another_list
mindex = my_list
my_list = [[] for _ in range(20)] #chickenpox
another_list = list(range(100,400))
my_list[2] = another_list
my_list[4] = another_list
my_list[6] = another_list
my_list[8] = another_list
my_list[10] = another_list
my_list[12] = another_list
my_list[14] = another_list
my_list[16] = another_list
mindex = my_list
# mindex= [[],[],[],list(range(50,150)),[]]
# mindex= [list(range(50,150)),[],list(range(50,90)),list(range(50,150)),[]] # node 2
plans_gnar_block = {
    'max_iteration': 3, 
    'method': ['GNAR'], 
    'mindex': [mindex],
    'lags': [4], 
    'inter_method': ['cubic','linear'],
}
plnr = itstgcn.planner.PLNR_GNAR_MANUAL(plans_gnar_block,loader1,dataset_name='chickenpox')
plnr.simulate(mindex,mtype='block')
# mindex= [[],[],[],list(range(50,150)),[]]
# mindex= [list(range(50,150)),[],list(range(50,90)),list(range(50,150)),[]] # node 2
plans_gnar_block = {
    'max_iteration': 3, 
    'method': ['GNAR'], 
    'mindex': [mindex],
    'lags': [2,4], 
    'inter_method': ['linear'],
}