Beispiel #1
0
def GenerateMacroActionsFromeFile(batch_size):
    filename = '../src/taxi18.dom'
    m = GenerateRoadModelFromFile(filename)

    start_location = np.array([m.GetRandomStartLocation(batch_size)])
    current_location = start_location[-1, :]
    print current_location

    print m.GenerateAllRoadMacroActions(current_location, batch_size)[0].shape
Beispiel #2
0
def CheckNeighboursTest():
    file_name = '../src/taxi18.dom'
    m = GenerateRoadModelFromFile(file_name)

    locs = m.locations

    for loc in locs:
        loc = tuple(loc)
        # length = len(m.GenerateRoadMacroActions(tuple(loc), 3))
        neighbours = m.GetNeighbours(loc)
        # print loc, neighbours
        for nei in neighbours:
            n_neighbours = m.GetNeighbours(nei)

            if loc in n_neighbours:
                print loc, nei
Beispiel #3
0
def IterateOverMacroActions(batch_size):
    file_name = '../datasets/slot18/tlog18.dom'
    m = GenerateRoadModelFromFile(file_name)
    # m.AddTwoSidedRoads()
    locs = m.locations

    sum = 0.0
    max = 0
    count = 0
    for loc in locs:
        length = len(m.GenerateAllRoadMacroActions(tuple(loc), batch_size))
        sum += length
        if length > max:
            max = length

        # count the number of locations where we have macroactions
        if length > 0:
            # print loc, length
            count += 1
    print count, max, sum / count
    """
Beispiel #4
0
def HistTests():
    file_name = '../src/taxi44.dom'
    m = GenerateRoadModelFromFile(file_name)

    hypers_file = open('hypers44.txt', 'w')
    locs = m.locations
    vals = m.values
    for i in range(locs.shape[0]):
        if vals[i] != -1.0:
            loc = locs[i, :]
            hypers_file.write(
                str(loc[0]) + ' ' + str(loc[1]) + ' ' + str(vals[i]) + '\n')
    hypers_file.close()

    list_vals = [v for v in vals.tolist() if v != -1.0]
    updated_vals = np.asarray(list_vals)
    print scipy.stats.skew(updated_vals)
    plt.hist(updated_vals, bins=50)

    plt.show()
Beispiel #5
0
def LogTransformTest():
    file_name = '../src/taxi18.dom'
    m = GenerateRoadModelFromFile(file_name)
    vals = m.values
    for val in vals:
        print val
Beispiel #6
0
def NewDatasetTest():
    file_name = '../datasets/slot18/tlog18.dom'
    m = GenerateRoadModelFromFile(file_name)
    print m.mean
Beispiel #7
0
def GetMacroActionsOfLocation(loc, batch_size):
    filename = '../src/taxi18.dom'
    m = GenerateRoadModelFromFile(filename)
    return m.GenerateAllRoadMacroActions(loc, batch_size)
Beispiel #8
0
def LoadActionsFromFileTest(folder_name, batch_size):
    filename = '../datasets/slot18/taxi18.dom'
    m = GenerateRoadModelFromFile(filename)
    m.LoadSelectedMacroactions(folder_name, batch_size)
Beispiel #9
0
    error = 0
    for test_p in test:
        point = locs[test_p: test_p + 1, :]
        assert len(point.shape) == 2
        weights = gp.GPWeights(locations=locs_train, current_location=point, cholesky=cholesky)
        mu_predict = gp.GPMean(measurements=vals_train, weights=weights)

        truth = vals[test_p]
        print point, truth, mu_predict
        error += (mu_predict- truth)**2

    print sqrt(error / (test_number_of_points))


if __name__ == "__main__":
    file_name = '../datasets/slot18/tlog18.dom'
    m = GenerateRoadModelFromFile(file_name)
    allowed_indexes = m.informative_locations_indexes
    locs = m.locations[allowed_indexes, :]
    vals = m.values[allowed_indexes]

    #TestPrediction(locs, vals)

    pairs = GenerateGridPairs(range(8,12), range(40,44)).tolist()

    raw_indexes = map(lambda x: TupleToLine(x, m.dim_1, m.dim_2), pairs)
    indexes = [x for x in raw_indexes if vals[x]!= m.NO_DATA_CONST]
    selected_locs = locs[indexes, :]
    print selected_locs
    selected_vals = vals[indexes]
    TestPrediction(selected_locs, selected_vals)