def run_experiment(argst): args, location = argst # reset all things for every new experiment pid = multiprocessing.current_process().pid np.random.seed(pid) bcd.offline_changepoint_detection.data = None Record.records[pid] = pd.DataFrame() world = create_world() controllers = [] for j, _ in enumerate(world.joints): controllers.append(Controller(world, j)) alpha_prior = np.array([.1, .1]) n = len(world.joints) independent_prior = .7 # the model prior is proportional to 1/distance between the joints model_prior = np.array([[0 if x == y else independent_prior if x == n else 1/abs(x-y) for x in range(n+1)] for y in range(n)]) # normalize model_prior[:, :-1] = ((model_prior.T[:-1, :] / np.sum(model_prior[:, :-1], 1)).T * (1-independent_prior)) if args.objective == "random": objective = random_objective elif args.objective == "entropy": objective = exp_neg_entropy elif args.objective == "cross_entropy": objective = exp_cross_entropy data, metadata = dependency_learning(N_actions=args.queries, N_samples=args.samples, world=world, objective_fnc=objective, use_change_points=args.changepoint, alpha_prior=alpha_prior, model_prior=model_prior, action_machine= ActionMachine(world, controllers, .1), location=location) filename = generate_filename(metadata) with open(filename, "wb") as _file: cPickle.dump((data, metadata), _file)
import argparse __author__ = 'johannes' if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('--useRos', action='store_true', help="Enable ROS/real robot usage.") args = parser.parse_args() if args.useRos: world = create_ros_drawer_world() action_machine = RosActionMachine(world) else: world = create_world() controller = [ Controller(world, i) for i, joint in enumerate(world.joints) ] action_machine = ActionMachine(world, controller) jpos = np.array([int(j.get_q()) for j in world.joints]) try: for i, joint in enumerate(world.joints): action_pos = np.array(jpos) action_pos[i] = world.joints[i].max_limit action_machine.run_action(action_pos) action_pos[i] = world.joints[i].min_limit action_machine.run_action(action_pos) except KeyboardInterrupt:
import argparse __author__ = 'johannes' if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('--useRos', action='store_true', help="Enable ROS/real robot usage.") args = parser.parse_args() if args.useRos: world = create_ros_drawer_world() action_machine = RosActionMachine(world) else: world = create_world() controller = [Controller(world, i) for i, joint in enumerate(world.joints)] action_machine = ActionMachine(world, controller) jpos = np.array([int(j.get_q()) for j in world.joints]) try: for i, joint in enumerate(world.joints): action_pos = np.array(jpos) action_pos[i] = world.joints[i].max_limit action_machine.run_action(action_pos) action_pos[i] = world.joints[i].min_limit action_machine.run_action(action_pos) except KeyboardInterrupt: pass
def test_create_world(self): world = create_world(3) self.assertEqual(len(world.joints), 6)