Ejemplo n.º 1
0
def case_1():

    # Read the vehicle model
    vehicle = lomap.Ts()
    vehicle.read_from_file('./vehicle_1.txt')
    # Convert the vehicle model to an MDP
    vehicle_mdp = lomap.Markov()
    vehicle_mdp.mdp_from_det_ts(vehicle)

    # Read the models of the pedestrians
    targets = []
    for i in range(1, 6):
        t = lomap.Markov()
        t.read_from_file('./target_%d.txt' % i)
        targets.append(t)

    formula = '! col U end'

    # Construct the full-state fsa using scheck
    # (full-state ensures proper MDP after product)
    logger.info('Formula: %s' % formula)
    fsa = lomap.Fsa()
    fsa.fsa_from_cosafe_formula(formula)
    fsa.add_trap_state()

    # Classical
    with lomap.Timer(
            'Classical (non-incremental) Method: Case 1 - Avoid pedestrians'):
        lomap.classical_synthesis(vehicle_mdp, fsa, targets, set_props_1)
        pass

    # Incremental
    with lomap.Timer('Incremental Method: Case 1 - Avoid pedestrians'):
        lomap.incremental_synthesis(vehicle_mdp, fsa, targets, set_props_1)
Ejemplo n.º 2
0
def case_1():

	# Read the vehicle model
	vehicle = lomap.Ts()
	vehicle.read_from_file('./vehicle_1.txt')
	# Convert the vehicle model to an MDP
	vehicle_mdp = lomap.Markov()
	vehicle_mdp.mdp_from_det_ts(vehicle)

	# Read the models of the pedestrians
	targets = []
	for i in range(1,6):
		t = lomap.Markov()
		t.read_from_file('./target_%d.txt' % i)
		targets.append(t)

	formula = '! col U end'

	# Construct the full-state fsa using scheck
	# (full-state ensures proper MDP after product)
	logger.info('Formula: %s' % formula)
	fsa = lomap.Fsa()
	fsa.fsa_from_cosafe_formula(formula)
	fsa.add_trap_state()

	# Classical
	with lomap.Timer('Classical (non-incremental) Method: Case 1 - Avoid pedestrians'):
		lomap.classical_synthesis(vehicle_mdp, fsa, targets, set_props_1)
		pass

	# Incremental
	with lomap.Timer('Incremental Method: Case 1 - Avoid pedestrians'):
		lomap.incremental_synthesis(vehicle_mdp, fsa, targets, set_props_1)
Ejemplo n.º 3
0
def case_3b():

    # Read the vehicle model
    vehicle = lomap.Ts.load('./vehicle_2.yaml')
    # Convert the vehicle model to an MDP
    vehicle_mdp = lomap.Markov()
    vehicle_mdp.mdp_from_det_ts(vehicle)

    # Read the models of the guards
    targets = []
    for i in range(1,7):
        t = lomap.Markov.load('./trap_{}.yaml'.format(i))
        targets.append(t)

    # Reach end safely
    formula = '! unsafe U end'
    # Construct the full-state fsa using scheck
    # (full-state ensures proper MDP after product)
    logger.info('Formula: %s' % formula)
    fsa = lomap.Fsa()
    fsa.from_formula(formula)
    fsa.add_trap_state()
    #fsa.visualize()

    # Classical
    with lomap.Timer('Classical (non-incremental) Method: Case 3b - Order 2'):
        lomap.classical_synthesis(vehicle_mdp, fsa, targets, set_props_3)
        pass

    # Incremental
    targets_inc = [targets[2], targets[3], targets[0], targets[1], targets[5],
                   targets[4]]
    with lomap.Timer('Incremental Method: Case 3b - Order 2'):
        lomap.incremental_synthesis(vehicle_mdp, fsa, targets_inc, set_props_3)
        pass
Ejemplo n.º 4
0
def case_2b():

    # Read the vehicle model
    vehicle = lomap.Ts()
    vehicle.read_from_file('./vehicle_1.txt')
    # Convert the vehicle model to an MDP
    vehicle_mdp = lomap.Markov()
    vehicle_mdp.mdp_from_det_ts(vehicle)

    # Read the models of the pedestrians
    targets = []
    for i in range(1, 6):
        t = lomap.Markov()
        t.read_from_file('./target_%d.txt' % i)
        targets.append(t)

    formula = '( F catch0 | F catch1 | F catch2 | F catch3 ) & ( ! col4 U end )'

    # Construct the full-state fsa using scheck
    # (full-state ensures proper MDP after product)
    logger.info('Formula: %s' % formula)
    fsa = lomap.Fsa()
    fsa.fsa_from_cosafe_formula(formula)
    fsa.add_trap_state()

    # Classical
    with lomap.Timer(
            'Classical (non-incremental) Method: Case 2b - Save at least one friendly'
    ):
        lomap.classical_synthesis(vehicle_mdp, fsa, targets, set_props_2)
        pass

    # Incremental
    targets_inc = [targets[-1]] + targets[:-1]
    assumed_props = [('ped0c2', 'ped1c2', 'ped2c2', 'ped3c2'),
                     ('ped1c2', 'ped2c2', 'ped3c2'), ('ped2c2', 'ped3c2'),
                     ('ped3c2'), ()]

    with lomap.Timer(
            'Incremental Method: Case 2b - Save at least one friendly'):
        lomap.incremental_synthesis(vehicle_mdp, fsa, targets_inc, set_props_2,
                                    assumed_props)
        pass
Ejemplo n.º 5
0
def case_2b():

	# Read the vehicle model
	vehicle = lomap.Ts()
	vehicle.read_from_file('./vehicle_1.txt')
	# Convert the vehicle model to an MDP
	vehicle_mdp = lomap.Markov()
	vehicle_mdp.mdp_from_det_ts(vehicle)

	# Read the models of the pedestrians
	targets = []
	for i in range(1,6):
		t = lomap.Markov()
		t.read_from_file('./target_%d.txt' % i)
		targets.append(t)

	formula = '( F catch0 | F catch1 | F catch2 | F catch3 ) & ( ! col4 U end )'

	# Construct the full-state fsa using scheck
	# (full-state ensures proper MDP after product)
	logger.info('Formula: %s' % formula)
	fsa = lomap.Fsa()
	fsa.fsa_from_cosafe_formula(formula)
	fsa.add_trap_state()

	# Classical
	with lomap.Timer('Classical (non-incremental) Method: Case 2b - Save at least one friendly'):
		lomap.classical_synthesis(vehicle_mdp, fsa, targets, set_props_2)
		pass

	# Incremental
	targets_inc = [targets[-1]] + targets[:-1]
	assumed_props = [('ped0c2','ped1c2','ped2c2','ped3c2'),
		('ped1c2','ped2c2','ped3c2'),
		('ped2c2','ped3c2'),
		('ped3c2'),
		()]

	with lomap.Timer('Incremental Method: Case 2b - Save at least one friendly'):
		lomap.incremental_synthesis(vehicle_mdp, fsa, targets_inc, set_props_2, assumed_props)
		pass
Ejemplo n.º 6
0
def case_2a():

    # Read the vehicle model
    vehicle = lomap.Ts.load('./vehicle_1.yaml')
    # Convert the vehicle model to an MDP
    vehicle_mdp = lomap.Markov()
    vehicle_mdp.mdp_from_det_ts(vehicle)

    # Read the models of the pedestrians
    targets = []
    for i in range(1,6):
        t = lomap.Markov.load('./target_{}.yaml'.format(i))
        targets.append(t)

    formula = 'F catch0 & F catch1 & F catch2 & F catch3 & ( ! col4 U end )'

    # Construct the full-state fsa using scheck
    # (full-state ensures proper MDP after product)
    logger.info('Formula: %s' % formula)
    fsa = lomap.Fsa()
    fsa.from_formula(formula)
    fsa.add_trap_state()

    # Classical
    with lomap.Timer('Classical (non-incremental) Method: Case 2a - '
                     'Save all friendlies'):
        lomap.classical_synthesis(vehicle_mdp, fsa, targets, set_props_2)
        pass

    # Incremental
    targets_inc = [targets[-1]] + targets[:-1]
    assumed_props = [('ped0c2','ped1c2','ped2c2','ped3c2'),
        ('ped1c2','ped2c2','ped3c2'),
        ('ped2c2','ped3c2'),
        ('ped3c2'),
        ()]

    with lomap.Timer('Incremental Method: Case 2a - Save all friendlies'):
        lomap.incremental_synthesis(vehicle_mdp, fsa, targets_inc, set_props_2,
                                    assumed_props)
        pass
Ejemplo n.º 7
0
def case_3b():

    # Read the vehicle model
    vehicle = lomap.Ts()
    vehicle.read_from_file('./vehicle_2.txt')
    # Convert the vehicle model to an MDP
    vehicle_mdp = lomap.Markov()
    vehicle_mdp.mdp_from_det_ts(vehicle)

    # Read the models of the guards
    targets = []
    for i in range(1, 7):
        t = lomap.Markov()
        t.read_from_file('./trap_%d.txt' % i)
        targets.append(t)

    # Reach end safely
    formula = '! unsafe U end'
    # Construct the full-state fsa using scheck
    # (full-state ensures proper MDP after product)
    logger.info('Formula: %s' % formula)
    fsa = lomap.Fsa()
    fsa.fsa_from_cosafe_formula(formula)
    fsa.add_trap_state()
    #fsa.visualize()

    # Classical
    with lomap.Timer('Classical (non-incremental) Method: Case 3b - Order 2'):
        lomap.classical_synthesis(vehicle_mdp, fsa, targets, set_props_3)
        pass

    # Incremental
    targets_inc = [
        targets[2], targets[3], targets[0], targets[1], targets[5], targets[4]
    ]
    with lomap.Timer('Incremental Method: Case 3b - Order 2'):
        lomap.incremental_synthesis(vehicle_mdp, fsa, targets_inc, set_props_3)
        pass
Ejemplo n.º 8
0
def case_3a():

	# Read the vehicle model
	vehicle = lomap.Ts()
	vehicle.read_from_file('./vehicle_2.txt')
	# Convert the vehicle model to an MDP
	vehicle_mdp = lomap.Markov()
	vehicle_mdp.mdp_from_det_ts(vehicle)

	# Read the models of the guards
	targets = []
	for i in range(1,7):
		t = lomap.Markov()
		t.read_from_file('./trap_%d.txt' % i)
		targets.append(t)

	# Reach end safely
	formula = '! unsafe U end'
	# Construct the full-state fsa using scheck
	# (full-state ensures proper MDP after product)
	logger.info('Formula: %s' % formula)
	fsa = lomap.Fsa()
	fsa.fsa_from_cosafe_formula(formula)
	fsa.add_trap_state()
	#fsa.visualize()

	# Classical
	with lomap.Timer('Classical (non-incremental) Method: Case 3a - Order 1'):
		lomap.classical_synthesis(vehicle_mdp, fsa, targets, set_props_3)
		pass

	# Incremental
	targets_inc = targets
	with lomap.Timer('Incremental Method: Case 3a - Order 1'):
		lomap.incremental_synthesis(vehicle_mdp, fsa, targets_inc, set_props_3)
		pass