def RLmain(i): import RLSim as rl import numpy as np X_0 = [1.1,1.1,1.1] Y_0 = [0.01,0.01,.01] Z_0 = [0, 0, 0] N = len(X_0) # number of parallel runs # run first round of simulation my_sim = rl.mockSimulation() W_0 = [[1/6, 1/6], [1/6, 1/6], [1/6, 1/6]] # initial geuss of weights for + - in x and y directions Ws = [] # series of weights # first round trj1 = my_sim.run_noPlt([X_0, Y_0, Z_0], nstepmax = 10) trj1 = my_sim.PreAll(trj1) trjs = trj1 trj1_Sp = my_sim.PreSamp(trj1, starting_n = N, myn_clusters = 20) # pre analysis trj1_Sp_theta = my_sim.map(trj1_Sp) newPoints = my_sim.findStarting(trj1_Sp_theta, trj1_Sp, W_0, starting_n = N , method = 'RL') trjs_theta = trj1_Sp_theta trjs_Sp_theta = trj1_Sp_theta for round in range(700): # updates the std and mean #my_sim.updateStat(trjs_Sp_theta) # based on min count trajectories my_sim.updateStat(trjs_theta) # based on all trajectories #W_1 = my_sim.updateW(trj1_Sp_theta, W_0) # rewigth weigths using last round W_1 = my_sim.updateW(trjs_Sp_theta, W_0) # important W_0 = W_1 Ws.append(W_0) #print('Weight', W_0) trj1 = my_sim.run_noPlt(newPoints, nstepmax = 5) trj1 = my_sim.PreAll(trj1) # 2 x all points of this round #trjs = np.array([np.array(np.concatenate((trj1[0],trjs[0]))), np.array(np.concatenate((trj1[1],trjs[1])))]) # 2 x all points com_trjs = [] for theta in range(len(trj1)): com_trjs.append(np.concatenate((trjs[theta], trj1[theta]))) trjs = np.array(com_trjs) trjs_theta = np.array(my_sim.map(trjs)) trjs_Sp = my_sim.PreSamp(trjs, starting_n = N) trjs_Sp_theta = np.array(my_sim.map(trjs_Sp)) newPoints = my_sim.findStarting(trjs_Sp_theta, trjs_Sp, W_1, starting_n = N , method = 'RL') #print(Ws) np.save('w'+str(i), Ws) np.save('trjs_theta'+str(i), trjs_theta)
import RLSim as rl import numpy as np #X_0 = [1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1] #Y_0 = [0.01,0.01,.01,0.01,0.01,.01,0.01,0.01,.01,0.01,0.01,.01,0.01,0.01,.01,0.01,0.01,.01,0.01,0.01,.01,0.01,0.01,.01] X_0 = [1.1, 1.1, 1.1] Y_0 = [0.01, 0.01, .01] N = len(X_0) # number of parallel runs # run first round of simulation my_sim = rl.mockSimulation() W_0 = [[1 / 4, 1 / 4], [1 / 4, 1 / 4]] # initial geuss of weights for + - in x and y directions Ws = [] # series of weights # first round trj1 = my_sim.run_noPlt([X_0, Y_0], nstepmax=10) trj1 = my_sim.PreAll(trj1) trjs = trj1 trj1_Sp = my_sim.PreSamp(trj1, starting_n=N, myn_clusters=20) # pre analysis trj1_Sp_theta = my_sim.map(trj1_Sp) newPoints = my_sim.findStarting(trj1_Sp_theta, trj1_Sp, W_0, starting_n=N, method='RL') trjs_theta = trj1_Sp_theta
import numpy as np import RLSim as rl stepS = 0.001 * 120 # microSecond WW times = np.loadtxt('times.txt') times2 = stepS * times rl.pltTimes_folding(times2)
def rlmain(i): from scipy import io as sio import RLSim as rl import numpy as np # inital state S_0 = [0] # inactive N = len(S_0) # number of parallel runs nstepmax = 40 print('Simulation length: ', nstepmax * 0.005) W_0 = [[0.25, 0.25], [0.25, 0.25]] # initial geuss of weights for + - in x and y directions Ws = [] # series of weights newPoints_all = [] Ws.append(W_0) print('Weight', W_0) # run simulation my_sim = rl.mockSimulation() my_sim.tp = sio.mmread('../tProb.mtx') my_sim.x = np.load('../Gens_aloopRMSD.npy') my_sim.y = np.load('../Gens_y_KE.npy') my_sim.mapping = np.load('../map_Macro2micro.npy') #### first round trj1 = my_sim.run(S_0, nstepmax=nstepmax) # 1 x 1 x n_frames trj1 = my_sim.PreAll(trj1) # 1 x 1 x n_frames trjs = trj1[0] # 1 x n_frames trj1_Sp = my_sim.PreSamp_MC(trjs, N=10) # pre analysis # 1 x n_samples trj1_Sp_theta = np.array(my_sim.map(trj1_Sp)) # [trjx, trjy] newPoints = my_sim.findStarting(trj1_Sp_theta, trj1_Sp, W_0, starting_n=N, method='RL') # needs 2 x something trjs_theta = trj1_Sp_theta trjs_Sp_theta = trj1_Sp_theta bad = False for round in range(100): my_sim.updateStat(trjs_theta) # based on all trajectories W_1 = my_sim.updateW(trjs_Sp_theta, W_0) # important W_0 = W_1 Ws.append(W_0) print('Weight', W_0) if np.any(np.isnan(W_0)): bad = True print(bad) break oldTrjs = trjs trj1 = my_sim.run(newPoints, nstepmax=5) trj1 = my_sim.PreAll(trj1)[0] # 2 x all points of this round com_trjs = np.concatenate((trjs, trj1)) trjs = np.array(com_trjs) trjs_theta = np.array(my_sim.map(trjs)) trjs_Sp = my_sim.PreSamp_MC(trjs, N=10) trjs_Sp_theta = np.array(my_sim.map(trjs_Sp)) newPoints = my_sim.findStarting(trjs_Sp_theta, trjs_Sp, W_1, starting_n=N, method='RL') newPoints_all.append(newPoints) #my_sim.pltPoints(trjs_theta, trjs_Sp_theta, newPoints, round, weights=Ws) my_sim.pltPoints(trjs_theta[0], trjs_theta[1]) print(newPoints_all) if not bad: np.save('w' + str(i), Ws) np.save('trjs_theta' + str(i), trjs_theta)
import RLSim as rl z = rl.mockSimulation() z.runSimulation(R=1000, N=1,s=1000, method='RL')
import numpy as np import RLSim as rl stepS = 0.001*0.001*50 # milli Second B2AR times = np.loadtxt('times.txt') times2 = stepS * times rl.pltTimes(times2)