当前位置: 首页>>代码示例>>Python>>正文


Python simulator.Simulator方法代码示例

本文整理汇总了Python中simulator.Simulator方法的典型用法代码示例。如果您正苦于以下问题:Python simulator.Simulator方法的具体用法?Python simulator.Simulator怎么用?Python simulator.Simulator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在simulator的用法示例。


在下文中一共展示了simulator.Simulator方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run_test

# 需要导入模块: import simulator [as 别名]
# 或者: from simulator import Simulator [as 别名]
def run_test(self, args):
        print("testing...")
        model = self
        sim = Simulator(model)

        model.eval()

        game = args.instance_class(
            args.vizdoom_config, args.wad_path, args.skiprate, visible=True, mode=vizdoom.Mode.ASYNC_PLAYER,
            actions=args.action_set)
        step_state = game.get_state_normalized()

        while True:
            state = sim.get_state(step_state)
            # compute an action
            action = sim.get_action(state)
            # render
            step_state, _, finished = game.step_normalized(action[0][0])
            if finished:
                print("episode return: {}".format(game.get_episode_return())) 
开发者ID:akolishchak,项目名称:doom-net-pytorch,代码行数:22,代码来源:mcts_base.py

示例2: __init__

# 需要导入模块: import simulator [as 别名]
# 或者: from simulator import Simulator [as 别名]
def __init__(self, bytecode, mappingInfo, assertInfo={}, pcInitAddr=0, snippetMode = False):
        """
        Initialize the bytecode interpreter (simulator).

        :param bytecode: an bytes/bytearray object containing the bytecode to execute
        :param mappingInfo: the line/address mapping dictionnary produced by the assembler
        :param assertInfo: the assertion dictionnary produced by the assembler
        :param pcInitAddr: the address at which PC should start (default 0)
        """
        self.bc = bytecode
        self.addr2line = mappingInfo
        self.assertInfo = assertInfo
        # Useful to set line breakpoints
        self.line2addr = {}
        for addr,lines in mappingInfo.items():
            for line in lines:
                self.line2addr[line] = addr
        self.lineBreakpoints = []
        self.sim = Simulator(bytecode, self.assertInfo, self.addr2line, pcInitAddr)
        self.reset()
        self.errorsPending = None
        self.snippetMode = snippetMode 
开发者ID:mgard,项目名称:epater,代码行数:24,代码来源:bytecodeinterpreter.py

示例3: simulationSettings

# 需要导入模块: import simulator [as 别名]
# 或者: from simulator import Simulator [as 别名]
def simulationSettings(self, enable=False, values=None):
        if enable:
            self.simulationEnabled = True
            self.simulator = simulator.Simulator(values, settings.getInterval())
        if not enable:
            self.simulator = None
            self.simulationEnabled = False 
开发者ID:ArtificialQualia,项目名称:PyEveLiveDPS,代码行数:9,代码来源:animate.py

示例4: create

# 需要导入模块: import simulator [as 别名]
# 或者: from simulator import Simulator [as 别名]
def create(self, num, model, init_val):
        sim_id = len(self.simulators)
        sim = simulator.Simulator(model, num, init_val)
        self.simulators.append(sim)
        return [{'eid': '%s.%s' % (sim_id, eid), 'type': model, 'rel': []}
                for eid, inst in enumerate(sim.instances)] 
开发者ID:grei-ufc,项目名称:pade,代码行数:8,代码来源:example_sim.py

示例5: run_train

# 需要导入模块: import simulator [as 别名]
# 或者: from simulator import Simulator [as 别名]
def run_train(self, args):
        print("training...")

        model = self
        sim = Simulator(model)

        games = []
        for i in range(1):
            games.append(
                args.instance_class(args.vizdoom_config, args.wad_path, args.skiprate, actions=args.action_set, id=i)
            )

        for iter in range(100):
            print("iteration: ", iter)
            #
            # generate data
            #
            processes = []
            for game in games:
                process = Process(target=self.generate_data, args=(game, sim, args))
                process.start()
                processes.append(process)

            for process in processes:
                process.join()
            #
            # train model with new data
            #
            self.train_model(model) 
开发者ID:akolishchak,项目名称:doom-net-pytorch,代码行数:31,代码来源:mcts_base.py

示例6: test

# 需要导入模块: import simulator [as 别名]
# 或者: from simulator import Simulator [as 别名]
def test(task, 
         num_episodes=10,
         policy_network_hidden_sizes=(32, 32),
         policy_adaptive_std=False):
    
    directory = 'log/{}/'.format(task)
    simulator = Simulator(task=task)
    
    input_shape = (None, simulator.obsevation_dim)
    output_size = simulator.action_dim
    
    if simulator.action_type == 'continuous':
        policy_network = GaussianMLPPolicy(input_shape=input_shape,
                                           output_size=output_size,
                                           hidden_sizes=policy_network_hidden_sizes,
                                           adaptive_std=policy_adaptive_std,
                                           std_hidden_sizes=policy_network_hidden_sizes)
    elif simulator.action_type == 'discrete':
        policy_network = CategoricalMLPPolicy(input_shape=input_shape,
                                              output_size=output_size,
                                              hidden_sizes=policy_network_hidden_sizes)
    
    sampler = Sampler(simulator, policy_network)
    
    with tf.Session() as sess:
        saver = tf.train.Saver()
        checkpoint_path = os.path.join(directory, '{}.ckpt'.format(task))
        saver.restore(sess, checkpoint_path)
        
        for i in range(num_episodes):
            path = sampler.rollout(sess, max_path_length=1000, render=True)
            print("epsiode {}, reward {}".format(i, path['total_reward'])) 
开发者ID:PacktPublishing,项目名称:Python-Reinforcement-Learning-Projects,代码行数:34,代码来源:test.py

示例7: _start_worker

# 需要导入模块: import simulator [as 别名]
# 或者: from simulator import Simulator [as 别名]
def _start_worker(G, policy_class, policy_locals, task): 
    
    G.scope = "worker_{}".format(G.worker_id)
    with tf.variable_scope(G.scope):
        policy = policy_class.copy(policy_locals)
        simulator = Simulator(task)

    G.ops = get_param_assign_ops(policy.get_params())
    G.sampler = Sampler(simulator, policy)
    G.sess = tf.Session()
    
    G.sess.__enter__()
    G.sess.run(tf.global_variables_initializer()) 
开发者ID:PacktPublishing,项目名称:Python-Reinforcement-Learning-Projects,代码行数:15,代码来源:sampler.py

示例8: __init__

# 需要导入模块: import simulator [as 别名]
# 或者: from simulator import Simulator [as 别名]
def __init__(self, controller):
        super( SimulatorWindow, self ).__init__()
        self.controller = controller
        self.elapsed = 0.0
        self.epoch = 0
        self.throttleval = 0.0
        self.loadval = 0.0
        self.committedThrottleVal = 0.0
        self.dt = 1.0 / simconstants.SIMFREQ
        self.va = 0.0
        self.vb = 0.0
        self.vc = 0.0

        self.connect('destroy', lambda w: Gtk.main_quit())
        self.set_default_size(1024, 800)

        vbox = Gtk.VBox()
        self.add(vbox)

        self.table = GraphTable()
        vbox.pack_start( self.table, True, True, 0 )

        self.table.add_row( "omega", 0.05 )
        self.table.add_row( "theta", 5 )
        self.table.add_row( "va", 3 )
        self.table.add_row( "ia", 3 )
        self.table.add_row( "bemf", 4 )
        self.table.add_row( "torque", 50 )
        self.table.add_row( "errors", 5 )

        hbox = Gtk.HBox()
        self.pwm = self.add_label( "throttle (%): ", hbox )
        adj1 = Gtk.Adjustment(0.0, 0.0, 101.0, 0.1, 1.0, 1.0)
        self.throttlescale = Gtk.HScale()
        self.throttlescale.set_adjustment( adj1 )
        self.throttlescale.set_digits(1)
        self.throttlescale.set_draw_value(True)
        hbox.pack_start( self.throttlescale, True, True, 0 )
        self.throttlescale.connect( "change-value", self.change_throttle )

        self.load = self.add_label( "load (Nm): ", hbox )
        adj2 = Gtk.Adjustment(0.0, 0.0, 5.0, 0.01, 1.0, 1.0)
        self.loadscale = Gtk.HScale()
        self.loadscale.set_adjustment( adj2 )
        self.loadscale.set_digits(2)
        self.loadscale.set_draw_value(True)
        hbox.pack_start( self.loadscale, True, True, 0 )
        self.loadscale.connect( "change-value", self.change_load )

        vbox.pack_start(hbox, False, False, 0)
        self.sim = Simulator()

        GObject.timeout_add( 1, self.callback )

        self.show_all() 
开发者ID:gtoonstra,项目名称:bldc-sim,代码行数:57,代码来源:sim.py


注:本文中的simulator.Simulator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。