Exemplo n.º 1
0
import GPy
import numpy as np
from GPy.kern._src.custom_kern import RationalQuadratic as ratquadkern


# ker1 = ratquadkern(1,[[0,1, 1],[1,0,1],[1,1,0]])
ker1 = ratquadkern(1,[
    [0,1,1,2,1,2,2,3],
    [1,0,1,1,2,2,3,2],
    [1,1,0,1,1,2,2,2],
    [2,1,1,0,2,1,2,1],
    [1,2,1,2,0,1,1,2],
    [2,2,2,1,1,0,1,1],
    [2,3,2,2,1,1,0,1],
    [3,2,2,1,2,1,1,0],    
])
print "Gpy version: ",GPy.__version__
#print ker1

X = np.array([[0],[1],[2],[3],[4],[5]] ,dtype = np.int32)
Y = np.array([[100],[100],[50],[50],[25],[25]])
m = GPy.models.GPRegression(X,Y,ker1)
# print m
##m.optimize(messages=False)
# print m

# for x in xrange(2,8):
#     print m.predict(np.array([[x]], dtype=np.int32))
print m.predict(np.array([[0],[1],[2],[3],[4],[5],[6],[7]], dtype=np.int32))
Exemplo n.º 2
0
found = False
current = starting
graph.initialize_node_matrix()
graph.all_distance()
edge_matrix_structure = graph.build_edge_martix()
result_prediction = np.empty((0,1), dtype = np.int32)
#print graph.edge_list
#print result_prediction
#print len(graph.edge_list)

for x in graph.edge_list:
    if [graph.get_edge_index(x[0],x[1])] not in result_prediction:
        result_prediction = np.append(result_prediction, np.array([ [graph.get_edge_index(x[0],x[1])]]), axis=0)
observed_edges = np.empty((0,1), dtype = np.int32)
observed_congestions = np.empty((0,1), dtype = np.int32)
ker1 = ratquadkern(1,edge_matrix_structure)
time = 0
#print current
print graph.edge_list
print ker1
print edge_matrix_structure
is_pos_def(x)
while not found:
    time = time + 1
    #print time
    #print current
    #print goal
    #observe
    for n in graph.get_vertex(current).get_connections():
        if [graph.get_edge_index(n.get_id(),current)] not in observed_edges:
            observed_edges = np.append(observed_edges, np.array([[graph.get_edge_index(n.get_id(),current)]]), axis=0)