Ejemplo n.º 1
0
def main():

    # path = '../Scenic-devel/examples/carla/pedestrian.scenic'
    path = 'fullScenario.scenic'
    sampler = ScenicSampler.fromScenario(path)
    falsifier_params = DotMap(
        n_iters=1,
        save_error_table=True,
        save_safe_table=True,
        error_table_path="failures_file.txt",
    )
    falsifier_params.fal_thres = 4
    # falsifier_params.fal_thres = 7
    server_options = DotMap(maxSteps=800, verbosity=0)
    falsifier = generic_falsifier(sampler=sampler,
                                  falsifier_params=falsifier_params,
                                  server_class=ScenicServer,
                                  server_options=server_options,
                                  monitor=specification_monitor(specification))
    t0 = time.time()
    falsifier.run_falsifier()
    t = time.time() - t0
    print(
        f'Generated {len(falsifier.samples)} samples in {t} seconds with 1 worker'
    )
    print(f'Number of counterexamples: {len(falsifier.error_table.table)}')
Ejemplo n.º 2
0
def test_driving_dynamic(pathToLocalFile):
    path = pathToLocalFile('scenic_driving.scenic')
    sampler = ScenicSampler.fromScenario(path)
    falsifier_params = DotMap(
        n_iters=3,
        save_error_table=False,
        save_safe_table=False,
    )
    server_options = DotMap(maxSteps=2, verbosity=3)
    falsifier = generic_falsifier(sampler=sampler,
                                  falsifier_params=falsifier_params,
                                  server_class=ScenicServer,
                                  server_options=server_options)
    falsifier.run_falsifier()
Ejemplo n.º 3
0
        super().__init__(specification)


falsifier_params = DotMap()
falsifier_params.port = PORT
falsifier_params.n_iters = MAX_ITERS
falsifier_params.maxreqs = MAXREQS
falsifier_params.bufsize = BUFSIZE
falsifier_params.compute_error_table = True
falsifier_params.fal_thres = 0.0

sampler_params = DotMap()
sampler_params.thres = 0.0
falsifier_params.sampler_params = sampler_params

falsifier = generic_falsifier(sample_space=sample_space,
                              sampler_type=SAMPLERTYPE,
                              monitor=mountaincar_spec(),
                              falsifier_params=falsifier_params)
falsifier.run_falsifier()
analysis_params = DotMap()
analysis_params.k_closest_params.k = 4
analysis_params.random_params.count = 4
falsifier.analyze_error_table(analysis_params=analysis_params)

print("Hyper-parameters leading to good controllers")
print(falsifier.error_table.table)

# To save all samples: uncomment this
# pickle.dump(falsifier.samples, open("generated_samples.pickle", "wb"))
Ejemplo n.º 4
0
        super().__init__(specification)


MAX_ITERS = 20
PORT = 8888
MAXREQS = 5
BUFSIZE = 4096

falsifier_params = DotMap()
falsifier_params.n_iters = MAX_ITERS
falsifier_params.compute_error_table = True
falsifier_params.fal_thres = 0.5

server_options = DotMap(port=PORT, bufsize=BUFSIZE, maxreqs=MAXREQS)

falsifier = generic_falsifier(sampler=sampler, server_options=server_options,
                             monitor=confidence_spec(), falsifier_params=falsifier_params)
falsifier.run_falsifier()

analysis_params = DotMap()
analysis_params.k_closest_params.k = 4
analysis_params.random_params.count = 4
analysis_params.pca = True
falsifier.analyze_error_table(analysis_params=analysis_params)
lib = getLib()

print("Error table")
print(falsifier.error_table.table)
print("Results of error table analysis")
print("Random samples from error table")
for i, sample in enumerate(falsifier.error_analysis.random_samples):
    print("Random Sample : ", i)
Ejemplo n.º 5
0
from verifai.falsifier import generic_falsifier

path_to_scenic_file = 'lane_cones.sc'
sampler = ScenicSampler.fromScenario(path_to_scenic_file)

MAX_ITERS = 20
PORT = 8888
MAXREQS = 5
BUFSIZE = 4096

falsifier_params = DotMap()
falsifier_params.port = PORT
falsifier_params.n_iters = MAX_ITERS
falsifier_params.maxreqs = MAXREQS
falsifier_params.bufsize = BUFSIZE
falsifier_params.save_error_table = False
falsifier_params.save_good_samples = False

falsifier = generic_falsifier(sampler=sampler,
                              sampler_type='scenic',
                              falsifier_params=falsifier_params)

falsifier.run_falsifier()

print("Scenic Samples")
for i in falsifier.samples.keys():
    print("Sample: ", i)
    print(falsifier.samples[i])

# To save all samples: uncomment this
# pickle.dump(falsifier.samples, open("generated_samples.pickle", "wb"))
Ejemplo n.º 6
0
path_to_scenic_file = 'lane_cones.sc'
sampler = ScenicSampler.fromScenario(path_to_scenic_file)

MAX_ITERS = 20
PORT = 8888
MAXREQS = 5
BUFSIZE = 4096

falsifier_params = DotMap()
falsifier_params.n_iters = MAX_ITERS
falsifier_params.save_error_table = False
falsifier_params.save_good_samples = False

server_options = DotMap(port=PORT, bufsize=BUFSIZE, maxreqs=MAXREQS)

falsifier = generic_falsifier(sampler=sampler,
                              sampler_type='scenic',
                              falsifier_params=falsifier_params,
                              server_options=server_options)

falsifier.run_falsifier()

print("Scenic Samples")
for i in falsifier.samples.keys():
    print("Sample: ", i)
    print(falsifier.samples[i])

# To save all samples: uncomment this
# pickle.dump(falsifier.samples, open("generated_samples.pickle", "wb"))
Ejemplo n.º 7
0
MAX_ITERS = 20
PORT = 8888
MAXREQS = 5
BUFSIZE = 4096

falsifier_params = DotMap()
falsifier_params.port = PORT
falsifier_params.n_iters = MAX_ITERS
falsifier_params.maxreqs = MAXREQS
falsifier_params.bufsize = BUFSIZE
falsifier_params.compute_error_table = True
falsifier_params.fal_thres = 0.5

falsifier = generic_falsifier(sampler=sampler,
                              monitor=confidence_spec(),
                              falsifier_params=falsifier_params)

falsifier.run_falsifier()

analysis_params = DotMap()
analysis_params.k_closest_params.k = 4
analysis_params.random_params.count = 4
analysis_params.pca_params.n_components = 2
analysis_params.pca = True
falsifier.analyze_error_table(analysis_params=analysis_params)
lib = getLib()

print("Error table")
print(falsifier.error_table.table)
print("Results of error table analysis")