def test1(): sys = systems.system() sys.add_node("add node 1,1") sys.add_node("add node 1,5") sys.add_node("add node 1,10") sys.add_node("add node 1,15") sys.add_node("add node 1,20") sys.add_node("add node 5,1") sys.add_node("add node 5,5") sys.add_node("add node 5,10") sys.add_node("add node 5,15") sys.add_node("add node 5,20") sys.add_node("add node 10,1") sys.add_node("add node 10,5") sys.add_node("add node 10,10") sys.add_node("add node 10,15") sys.add_node("add node 10,20") sys.add_node("add node 15,1") sys.add_node("add node 15,5") sys.add_node("add node 15,10") sys.add_node("add node 15,15") sys.add_node("add node 15,20") sys.add_node("add node 20,1") sys.add_node("add node 20,5") sys.add_node("add node 20,10") sys.add_node("add node 20,15") sys.add_node("add node 20,20") sys.update() sys.set_interfer("set interfer 11 50") sys.add_user("add user 1,1") sys.simul_start("simul start 20,20") return sys.user.whole_error()
def test2(): sys = systems.system() sys.add_random("add random 10") sys.update() sys.set_interfer("set interfer 11 50") sys.add_user("add user 1,1") sys.simul_start("simul start 20,20") return sys.user.whole_error()
def f(x): global transformation # tack on the pre-determined spinor coordinates from fixing three points x = list([-x[0], -x[1], x[0], x[1], -x[3], x[2], x[2], x[3], x[4], x[5], x[4], x[5]]) + list(x[6:]) kappa = compress(x) return(systems.system(kappa, transformation))
def main(): # system 객체 생성 sys = systems.system() # finish 입력받을 때 까지 실행 while (True): # 콘솔 그래픽 삭제 sys.clear() # 노드 정보 업데이트 sys.update() # 콘솔 그래픽 출력 sys.print_grid() # command를 받음 input = sys.get_command() # command가 re : system 객체 초기화 if "re" in input: sys = systems.system() # debug : command 입력 안할 시 bug if input == "": continue # command가 finish : main 프로그램 종료 if sys.finish(input): break # command가 add node 20,15 : system의 (20,15) 좌표에 node 추가 # node의 기본 채널은 11 sys.add_node(input) # command가 add random 10 : system에 random 좌표의 10개 node 추가 # node의 기본 채널은 11 sys.add_random(input) # command가 remove node 20,15 : system의 (20, 15) 좌표의 node 제거 sys.remove_node(input) # command가 set channel 20,20 12 : system의 (20, 20) 좌표의 node의 channel을 12로 변경 sys.set_channel(input) # command가 set intfer 11 5 : system의 11채널에 5Mbps의 간섭을 설정 (전체 범위에 일정한 간섭) sys.set_interfer(input) # command가 add user 1,1 : system에 (1, 1) 좌표에 user 추가 sys.add_user(input) # command가 simul start 20,20 : simulation시작 user를 (20, 20)까지 이동시키면서 위치 추정 sys.simul_start(input) # command가 test 5 : test5를 실행 sys.test(input) return
def test4(): sys = systems.system() sys.add_node("add node 1,1") sys.set_channel("set channel 1,1 11") sys.add_node("add node 1,5") sys.set_channel("set channel 1,1 11") sys.add_node("add node 1,15") sys.set_channel("set channel 1,15 16") sys.add_node("add node 1,20") sys.set_channel("set channel 1,20 16") sys.add_node("add node 5,1") sys.set_channel("set channel 5,1 11") sys.add_node("add node 5,20") sys.set_channel("set channel 5,20 16") sys.add_node("add node 8,1") sys.set_channel("set channel 8,1 11") sys.add_node("add node 8,20") sys.set_channel("set channel 8,20 16") sys.add_node("add node 10,1") sys.set_channel("set channel 10,1 21") sys.add_node("add node 10,20") sys.set_channel("set channel 10,20 26") sys.add_node("add node 15,1") sys.set_channel("set channel 15,1 21") sys.add_node("add node 15,20") sys.set_channel("set channel 15,20 26") sys.add_node("add node 20,1") sys.set_channel("set channel 20,1 21") sys.add_node("add node 20,5") sys.set_channel("set channel 20,5 21") sys.add_node("add node 20,15") sys.set_channel("set channel 20,15 26") sys.add_node("add node 20,20") sys.set_channel("set channel 20,20 26") sys.update() sys.set_interfer("set interfer 11 5") #sys.set_interfer("set interfer 16 50") #sys.set_interfer("set interfer 21 50") #sys.set_interfer("set interfer 26 50") sys.add_user("add user 1,1") sys.simul_start("simul start 20,20") return sys.user.whole_error()
sys.path.append(os.path.join(os.path.dirname(sys.path[0]), 'models')) import pystorms from MPC_cvx import MPC from Koopman import Koopman from Koopman_liftCtrl import Koopman2 from DMD import DMD from NARX import NARX from MovingAnchor import MovingAnchor from systems import system import numpy as np import pandas as pd import seaborn as sns from matplotlib import pyplot as plt done = False Delta = system("pystorm Delta") Xub_extreme, Xlb_extreme = Delta.stateBounds() Uub, Ulb = Delta.inputBounds() t = 0 tmulti = 50 n_basis = 6 n = Xub_extreme.size m = Uub.size n0 = 20 #n0 > nk + m KPmodel = Koopman(Xub_extreme, Xlb_extreme, Uub, Ulb, n_basis) KCmodel = Koopman2(Xub_extreme, Xlb_extreme, Uub, Ulb, n_basis) DMDmodel = DMD(Xub_extreme, Xlb_extreme, Uub, Ulb, n_basis) NARXmodel = NARX(Xub_extreme, Xlb_extreme, Uub, Ulb, n_basis) MAmodel = MovingAnchor(Xub_extreme, Xlb_extreme, Uub, Ulb, n_basis) Xub_scaled = KPmodel.scale(Xub_extreme) Xlb_scaled = KPmodel.scale(Xlb_extreme)
import pystorms from MPC_cvx import MPC from Koopman import Koopman from Koopman_liftCtrl import Koopman2 from DMD import DMD from NARX import NARX from MovingAnchor import MovingAnchor from systems import system import numpy as np import pandas as pd import seaborn as sns from matplotlib import pyplot as plt done = False observe = True Theta = system("pystorm Theta") settings = np.ones(2) Xub_extreme, Xlb_extreme = Theta.stateBounds() Uub, Ulb = Theta.inputBounds() Mub, Mlb = Theta.metricBounds() # np.random.get_state()[1][0] np.random.seed(878528420) # 1536292545 t = 0 tmulti = 50 n_basis = 6 n = Xub_extreme.size m = Uub.size ncost = 1 n0 = 150 #n0 > nk + m 150? if observe: KPmodel = Koopman(Xub_extreme,