本文整理汇总了Python中Simulation.forward方法的典型用法代码示例。如果您正苦于以下问题:Python Simulation.forward方法的具体用法?Python Simulation.forward怎么用?Python Simulation.forward使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Simulation
的用法示例。
在下文中一共展示了Simulation.forward方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_sample
# 需要导入模块: import Simulation [as 别名]
# 或者: from Simulation import forward [as 别名]
def get_sample(traj_dist,experiment_id):
#Start a simulation and do the stuff
functions = {}
args = {}
real_fun(functions)
states = np.genfromtxt('/home/elias/[email protected]/_Winter2015/CSC494/Trajectories/Traj'+str(experiment_id+1)+'state.txt', delimiter=',',dtype=np.float32)
actions = np.genfromtxt('/home/elias/[email protected]/_Winter2015/CSC494/Trajectories/Traj'+str(experiment_id+1)+'action.txt' ,dtype=np.float32)
T,d = states.shape
#Create simulation
Sim = Simulation(function=functions["Traj{}".format(str(experiment_id+1))], args=[[0,0,3],0])
Sim.restart()
f = open('/home/elias/[email protected]/_Winter2015/CSC494/Trajectories/Traj{}pred.txt'.format(experiment_id+1),'w+')
r = open('/home/elias/[email protected]/_Winter2015/CSC494/Trajectories/Traj{}residuals.txt'.format(experiment_id+1),'w+')
for timestep in range(T):
states[timestep,:] = normalize(state_norms[experiment_id],controller.getDif(Sim.cid,Sim.copter,Sim.target))
old = actions[timestep,:].copy()
actions[timestep,:] = denormalize(action_norms[experiment_id], get_action(traj_dist,states[timestep,:],timestep)[0])
Sim.forward(actions[timestep,:].tolist())
f.write(str(actions[timestep,:])+'\n')
r.write(str(old-actions[timestep,:])+'\n')
#Sim.forward()
Sim.sync()
print(vrep.simxStopSimulation(Sim.cid,vrep.simx_opmode_oneshot_wait))
f.close()
r.close()
return states,actions
示例2: real_fun
# 需要导入模块: import Simulation [as 别名]
# 或者: from Simulation import forward [as 别名]
from Simulation import *
from function_names import *
import numpy as np
from numpy import *
functions = {}
args = {}
real_fun(functions)
states = genfromtxt('/home/elias/[email protected]/_Winter2015/CSC494/Trajectories/Traj7state.txt', delimiter=',',dtype=float32)
actions = genfromtxt('/home/elias/[email protected]/_Winter2015/CSC494/Trajectories/Traj7action.txt' ,dtype=float32)
T,d = states.shape
#Create simulation
Sim = Simulation(function=functions["Traj7"], args=[[0,0,3],0])
Sim.restart()
for x in range(T):
Sim.forward(actions[x,:].tolist())
#Sim.forward()
print(controller.getDif(Sim.cid,Sim.copter,Sim.target))
print(actions[x,:])
raw_input()
Sim.sync()
示例3: real_fun
# 需要导入模块: import Simulation [as 别名]
# 或者: from Simulation import forward [as 别名]
functions = {}
args = {}
real_fun(functions)
#
norm_states = genfromtxt('/home/elias/[email protected]/_Winter2015/CSC494/Trajectories/Traj1state.txt', delimiter=',',dtype=float32)
norm_actions = genfromtxt('/home/elias/[email protected]/_Winter2015/CSC494/Trajectories/Traj1action.txt' ,dtype=float32)
states,actions = get_flat_files()
#Create simulation
Sim = Simulation(function=functions["Traj1"], args=[[0,0,3],0])
nn = Net()
states, actions = shuffle_in_unison(states,actions)
T,d = states.shape
train_states = states[:4800,:]
train_actions = actions[:4800,:]
val_states, val_actions =- states[4800:,:], actions[4800:,:]
sess, out, feed_me, keep_prob, momentum = nn.train(train_states,train_actions,10,val_states,val_actions)
Sim.restart()
for x in range(T):
state = (controller.getDif(Sim.cid,Sim.copter,Sim.target))
val = np.zeros((1,9))
val[0,:] = state
act = sess.run([out], feed_dict={feed_me:val, keep_prob:1})
act = np.asarray(act,dtype=float32)[0,:,:]
raw_input()
print(act)
Sim.forward(act[0].tolist())
#Sim.forward()
Sim.sync()