Ejemplo n.º 1
0
import alarms, motionModels
import numpy as np
from sklearn.model_selection import train_test_split
from scoring import AUC, ROC
from sklearn.neural_network import MLPRegressor
from sklearn.ensemble import GradientBoostingRegressor
from sklearn.tree import DecisionTreeRegressor
import time

model_name = 'sim_1'

mean_means = np.array((-5, 10))
mean_bounds = np.array((25, 20))
noise = np.diag([1e-6, 1e-6])  # essentially zero noise
truthMM1 = motionModels.MM_LineCV('left-right', noise)
truthMM2 = motionModels.MM_LineCV('right-down', noise)
timeres = .1
timelen = 1.
times = np.zeros((int(timelen / timeres), )) + timeres


def createTruth(npoints, nrepeats=4000):
    """
    Generates a range of initial states for both vehicles, then simulates from
    each one a certain number of times.
    """
    ## generating a grid of features
    res = int(npoints**.25)
    npoints = res**4
    x_0 = np.linspace(-1., 1., res)
Ejemplo n.º 2
0
timeres = .1
## the time duration of each simulation, and of the alarms' predictions. (s)
timelen = 2.5
## Each vehicle is started within a certain coordinate range, then moved
## backwards for 'timeback' seconds. Because the forward motion is partially
## random, this does not constrain the vehicles' positions to be within this
## coordinate range.
timeback = 2.
## The uncertainty in each vehicle's initial state is assumed to be Gaussian
## with this covariance matrix.
initialcovariance = np.diag([2., .5]) * .1
## name with which to save plots and tables; None = display but don't save
savename = 'sim2'  # None #

times = np.array([timeres] * int(timelen / timeres))
MM1 = motionModels.MM_LineCV('left-right', np.diag([2., .5]))
MM2 = motionModels.MM_LineCV('right-down', np.diag([2., .5]))

v1 = np.random.normal(10., 5., nsims)
x1 = np.random.normal(5, 2., nsims) - timeback * v1
vehicle1 = np.array((x1, v1)).T
v2 = np.random.normal(10., 5., nsims)
x2 = np.random.normal(-5, 2., nsims) - timeback * v2
vehicle2 = np.array((x2, v2)).T

mc_samplecounts = np.logspace(1, 3, 3).astype(int)
model = Model('MLP')

print "running"

truth = []