Ejemplo n.º 1
0
        while(start_goal_dist < 150):
            # input("in while")

            print("j is: " + str(j))
            j+=1
            rand_nums = np.random.random_integers(0,500,4)
            start =  np.array([rand_nums[0], rand_nums[1]])
            goal =  np.array([rand_nums[2], rand_nums[3]])
            start_goal_dist = np.linalg.norm(start - goal)
        # input("after while")


        emo = np.random.random_integers(0,len(emos)-1)
        # print("emo is: "  + str(emos[emo]))
        print("demo_filenames is: " + str(demo_filenames[emo]))
        demos, starts, goals, modes, emos_ignore = rl.process_demos(demo_filenames[emo])
        print("demos is:...")
        vnorm_bins = rl.detect_bins(demos, starts, goals)
        pweights_ = load_weights_numpy(pweight_filenames[emo])
        print("pweights_ is: " + str(pweights_))
        path, err_goal, termination_msg, path_duration = rl.create_path_from_policy(pweights_, start, goal, vnorm_bins, None)
        paths = [path]
        print("path is: "+ str(path))
        path_filename = "exp" + str(subject) + "_"
        rl.save_paths_to_file(paths, start, goal, emos[emo], "subject=" + str(subject), path_filename, i)
        path_filenames.append(path_filename + str(i) + ".csv")
        truth_file.write(str(i) + ":" + str(emos[emo]))
        truth_file.write("\n")
        i+=1

with open ("exp" + str(subject) + "_pathfile_names.txt", "w") as f:
Ejemplo n.º 2
0
def load_weights_numpy(filename):
    weights = np.load(filename)
    return weights

filenames = ["SF_demo0",
                    "SF_demo1",
                    "SF_demo2",
                    "SF_demo3",
                    "SF_demo4",
                    "SF_demo5",
                    "SF_demo6",
                    "SF_demo7",
                    # "SF_demo8",
                    # "SF_demo9",
]
demos, starts, goals, modes, emos = rl.process_demos(filenames)
vnorm_bins = rl.detect_bins(demos, starts, goals)

fname="cur_opt___SF_2dp_demo_pweights_10.npy"
# fname="demo0_pweights_rweights_10.csv"
# pweights_, rweights_ = load_pweights_rweights(fname)
pweights_ = load_weights_numpy(fname)
input("checking...")
print("pweights_ is: " + str(np.shape(pweights_)))
print(pweights_)

# generalized_start = [450,67]
# generalized_goal = [86,396]

# generalized_start = [250,167]
# generalized_goal = [416,196]