SimualtionPlanner-Tutorial

ST-GCN
Author

SEOYEON CHOI

Published

March 22, 2023

table

BASELINE

imports

import rpy2
import rpy2.robjects as ro 
from rpy2.robjects.vectors import FloatVector 
from rpy2.robjects.packages import importr

%load_ext rpy2.ipython

%%R
library(GNAR)
library(igraph)
import itstgcnEvolveGCNH
import torch
import itstgcnEvolveGCNH.planner 

read data

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 WindmillOutputMediumDatasetLoader
loader5 = WindmillOutputMediumDatasetLoader()
from torch_geometric_temporal.dataset import WindmillOutputSmallDatasetLoader
loader6 = WindmillOutputSmallDatasetLoader()
loader6 = itstgcnEvolveGCNH.load_data('./data/Windmillsmall.pkl')
from torch_geometric_temporal.dataset import MontevideoBusDatasetLoader
loader10 = MontevideoBusDatasetLoader()
loader6 = itstgcnGCLSTM.load_data('./data/Windmillsmall.pkl')

PLNR_STGCN_RAND

plans_stgcn_rand = {
    'max_iteration': 30, 
    'method': ['STGCN', 'IT-STGCN'],
    'mrate': [0,0.3,0.6],
    'lags': [4], 
    'nof_filters': [12], 
    'inter_method': ['linear','nearest'],
    'epoch': [50]
}
plnr = itstgcn.planner.PLNR_STGCN_RAND(plans_stgcn_rand,loader2,dataset_name='pedalme')

plnr.simulate()
plans_stgcn_rand = {
    'max_iteration': 15, 
    'method': ['STGCN', 'IT-STGCN'],
    'mrate': [0.3],
    'lags': [8], 
    'nof_filters': [12], 
    'inter_method': ['linear'],
    'epoch': [50]
}
plnr = itstgcn.planner.PLNR_STGCN_RAND(plans_stgcn_rand,loader3,dataset_name='wikimath')

plnr.simulate()
1/15 is done
2/15 is done
3/15 is done
4/15 is done
5/500
plnr = itstgcn.planner.PLNR_STGCN_RAND(plans_stgcn_rand,loader3,dataset_name='wikimath')

plnr.simulate()
plans_stgcn_rand = {
    'max_iteration': 15, 
    'method': ['STGCN', 'IT-STGCN'],
    'mrate': [0.8],
    'lags': [8], 
    'nof_filters': [12], 
    'inter_method': ['linear'],
    'epoch': [50]
}
plnr = itstgcn.planner.PLNR_STGCN_RAND(plans_stgcn_rand,loader3,dataset_name='wikimath')

plnr.simulate()
plnr = itstgcn.planner.PLNR_STGCN_RAND(plans_stgcn_rand,loader3,dataset_name='wikimath')

plnr.simulate()
plans_stgcn_rand = {
    'max_iteration': 15, 
    '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,loader3,dataset_name='wikimath')

plnr.simulate()
plans_stgcn_rand = {
    'max_iteration': 1, 
    'method': ['STGCN', 'IT-STGCN'],
    'mrate': [0.7],
    'lags': [8], 
    'nof_filters': [16], 
    'inter_method': ['linear'],
    'epoch': [50]
}
plnr = itstgcnGConvLSTM.planner.PLNR_STGCN_RAND(plans_stgcn_rand,loader6,dataset_name='windmillsmall')
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 = itstgcnEvolveGCNH.planner.PLNR_STGCN_RAND(plans_stgcn_rand,loader6,dataset_name='windmillsmall')
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,loader5,dataset_name='windmillmedium')
plnr.simulate()

PLNR_STGCN_MANUAL

my_list = [[] for _ in range(20)] #chickenpox
another_list = list(range(100,200))
my_list[10] = another_list
mindex = my_list
my_list = [[] for _ in range(15)] #pedalme
another_list = list(range(5,25))
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
mindex = my_list
my_list = [[] for _ in range(1068)] #wikimath
another_list = list(range(200,500))
my_list[10] = another_list
mindex = my_list
my_list = [[] for _ in range(26)] #windmilmedi
another_list = list(range(200,500)) # 676*0.8 = 540.8
my_list[10] = another_list
mindex = my_list
import numpy as np
import random
my_list = [[] for _ in range(675)] #monte
another_list = list(range(200,350)) #743

for i in np.array(random.sample(range(0, 675), 400)):
    my_list[i] = 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': 30, 
    'method': ['STGCN', 'IT-STGCN'], 
    'mindex': [mindex],
    'lags': [8], 
    'nof_filters': [12], 
    'inter_method': ['linear'],
    'epoch': [50]
}
plnr = itstgcnadd.planner.PLNR_STGCN_MANUAL(plans_stgcn_block,loader,dataset_name='fivenodes')
plnr.simulate(mindex=mindex,mtype='block')
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': 30, 
    'method': ['STGCN', 'IT-STGCN'], 
    'mindex': [mindex],
    'lags': [8], 
    'nof_filters': [12], 
    'inter_method': ['linear'],
    'epoch': [50]
}
plnr = itstgcn.planner.PLNR_STGCN_MANUAL(plans_stgcn_block,loader6,dataset_name='windmiloutputsmall')
plnr.simulate(mindex=mindex,mtype='block')
my_list = [[] for _ in range(1068)] #wikimath
another_list = random.sample(range(0, 576), 432)
for i in range(0, 1068):
    my_list[i] = 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': 10, 
    'method': ['STGCN', 'IT-STGCN'], 
    'mindex': [mindex],
    'lags': [4], 
    'nof_filters': [12], 
    'inter_method': ['nearest','linear'],
    'epoch': [50]
}
plnr = itstgcn.planner.PLNR_STGCN_MANUAL(plans_stgcn_block,loader3,dataset_name='wikimath')
plnr.simulate(mindex=mindex,mtype='block')
# 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': 10, 
    'method': ['STGCN', 'IT-STGCN'], 
    'mindex': [mindex],
    'lags': [4], 
    'nof_filters': [12], 
    'inter_method': ['nearest','linear'],
    'epoch': [50]
}
plnr = itstgcn.planner.PLNR_STGCN_MANUAL(plans_stgcn_block,loader3,dataset_name='wikimath')
plnr.simulate(mindex=mindex,mtype='block')
# 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': 10, 
    'method': ['STGCN', 'IT-STGCN'], 
    'mindex': [mindex],
    'lags': [4], 
    'nof_filters': [12], 
    'inter_method': ['nearest','linear'],
    'epoch': [50]
}
plnr = itstgcn.planner.PLNR_STGCN_MANUAL(plans_stgcn_block,loader3,dataset_name='wikimath')
plnr.simulate(mindex=mindex,mtype='block')

PLNR_GNAR_RAND

plans_gnar_rand = {
    'max_iteration': 30, 
#    'method': ['GNAR'], 
    'mrate': [0.8, 0.9],
    'lags': [4], 
#    'nof_filters': [8,16], 
    'inter_method': ['cubic','linear'],
#    'epoch': [1]
}
plnr = itstgcn.planner.PLNR_GNAR_RAND(plans_gnar_rand,loader1,dataset_name='chickenpox')
plnr.simulate()

PLNR_GNAR_BLOCK

my_list = [[] for _ in range(20)] #chickenpox
another_list = list(range(100,200))
my_list[10] = another_list
mindex = my_list
my_list = [[] for _ in range(15)] #pedalme
another_list = list(range(5,25))
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
mindex = my_list
my_list = [[] for _ in range(1068)] #wikimath
another_list = list(range(10,20))
my_list[10] = another_list
mindex = my_list
my_list = [[] for _ in range(26)] #windmilmedi
another_list = list(range(200,500)) # 676*0.8 = 540.8
my_list[10] = another_list
mindex = my_list
my_list = [[] for _ in range(11)] #windmilsmall
another_list = list(range(5000,10000)) # 17470*0.8 = 13976.0
my_list[10] = another_list
mindex = my_list
my_list = [[] for _ in range(675)] #monte
another_list = list(range(200,350)) #743

for i in np.array(random.sample(range(0, 675), 400)):
    my_list[i] = another_list
mindex = my_list
# mindex = [[],[],list(range(50,250)),[],[]]
# mindex = [list(range(10,100)),[],list(range(50,80)),[],[]]
# mindex= [list(range(10,100)),[],list(range(50,80)),list(range(50,150)),[]]
plans_gnar_block = {
    'max_iteration': 3, 
    'method': ['GNAR'], 
    'mindex': [mindex],
    'lags': [4,8], 
    'inter_method': ['linear'],
}
plnr = itstgcn.planner.PLNR_GNAR_MANUAL(plans_gnar_block,loader1,dataset_name='chickenpox')
plnr.simulate(mindex,mtype='block')
# mindex = [[],[],list(range(50,250)),[],[]]
# mindex = [list(range(10,100)),[],list(range(50,80)),[],[]]
# mindex= [list(range(10,100)),[],list(range(50,80)),list(range(50,150)),[]]
plans_gnar_block = {
    'max_iteration': 3, 
    'method': ['GNAR'], 
    'mindex': [mindex],
    'lags': [8], 
    'inter_method': ['linear'],
}
plnr = itstgcn.planner.PLNR_GNAR_MANUAL(plans_gnar_block,loader3,dataset_name='wikimath')
plnr.simulate(mindex,mtype='block')