def main():

    Rho = namedtuple('Rho', ['lower', 'upper'])
    rhos = [Rho(lower=0.98, upper=1.04), Rho(lower=0.98, upper=1.04)]

#     # Case Study 1
#     with Timer('IJRR 2013 Case-Study 1'):
#         r1 = Ts.load('./robot_1.yaml')
#         r2 = Ts.load('./robot_2.yaml')
#         ts_tuple = (r1, r2)
#         formula = ('[]<>gather && [](r1gather -> X(!r1gather U r1upload)) '
#                   '&& [](r2gather -> X(!r2gather U r2upload))')
#         opt_prop = set(['gather'])
#         logger.info('Formula: %s', formula)
#         logger.info('opt_prop: %s', opt_prop)
#         prefix_length, prefixes, suffix_cycle_cost, suffix_cycles = \
#                     lomap.multi_agent_optimal_run(ts_tuple, formula, opt_prop)
#         logger.info('Cost: %d', suffix_cycle_cost)
#         logger.info('Prefix length: %d', prefix_length)
#         # Find the controls that will produce this run
#         control_prefixes = []
#         control_suffix_cycles = []
#         for i in range(0, len(ts_tuple)):
#             ts = ts_tuple[i]
#             control_prefixes.append(ts.controls_from_run(prefixes[i]))
#             control_suffix_cycles.append(ts.controls_from_run(suffix_cycles[i]))
#             logger.info('%s run prefix: %s', ts.name, prefixes[i])
#             logger.info('%s control perfix: %s', ts.name, control_prefixes[i])
#             logger.info('%s suffix cycle: %s', ts.name, suffix_cycles[i])
#             logger.info('%s control suffix cycle: %s', ts.name,
#                                                     control_suffix_cycles[i])
#
#     logger.info('<><><> <><><> <><><>')

    # Case Study 2
    with Timer('IJRR 2013 Case-Study 2'):
        r1 = Ts.load('./robot_1.yaml')
        r2 = Ts.load('./robot_2.yaml')
        ts_tuple = (r1, r2)
        formula = ('[]<>gather && [](gather->(r1gather && r2gather)) '
                   '&& [](r1gather -> X(!r1gather U r1upload)) '
                   '&& [](r2gather -> X(!r2gather U r2upload))')
        opt_prop = set(['r1gather','r2gather'])
        logger.info('Formula: %s', formula)
        logger.info('opt_prop: %s', opt_prop)
        prefix_length, prefixes, suffix_cycle_cost, suffix_cycles = \
         lomap.robust_multi_agent_optimal_run(ts_tuple, rhos, formula, opt_prop)
        logger.info('Cost: %d', suffix_cycle_cost)
        logger.info('Prefix length: %d', prefix_length)
        # Find the controls that will produce this run
        control_prefixes = []
        control_suffix_cycles = []
        for i in range(0, len(ts_tuple)):
            ts = ts_tuple[i]
            control_prefixes.append(ts.controls_from_run(prefixes[i]))
            control_suffix_cycles.append(ts.controls_from_run(suffix_cycles[i]))
            logger.info('%s run prefix: %s', ts.name, prefixes[i])
            logger.info('%s control perfix: %s', ts.name, control_prefixes[i])
            logger.info('%s suffix cycle: %s', ts.name, suffix_cycles[i])
            logger.info('%s control suffix cycle: %s', ts.name,
                                                    control_suffix_cycles[i])

    logger.info('<><><> <><><> <><><>')

    # Case Study 3
    with Timer('IJRR 2013 Case-Study 3'):
        r1 = Ts.load('./robot_1.yaml')
        r2 = Ts.load('./robot_2.yaml')
        ts_tuple = (r1, r2)
        formula = ('[]<>gather && [](gather->(r1gather && r2gather)) '
                   '&& [](r1gather -> X(!r1gather U r1upload)) '
                   '&& [](r2gather -> X(!r2gather U r2upload)) '
                   '&& [](!(r1gather1 && r2gather1) && !(r1gather2 && r2gather2)'
                   '&& !(r1gather3 && r2gather3) && !(r1gather4 && r2gather4))')
        opt_prop = set(['r1gather','r2gather'])
        logger.info('Formula: %s', formula)
        logger.info('opt_prop: %s', opt_prop)
        prefix_length, prefixes, suffix_cycle_cost, suffix_cycles = \
         lomap.robust_multi_agent_optimal_run(ts_tuple, rhos, formula, opt_prop)
        logger.info('Cost: %d', suffix_cycle_cost)
        logger.info('Prefix length: %d', prefix_length)
        # Find the controls that will produce this run
        control_prefixes = []
        control_suffix_cycles = []
        for i in range(0, len(ts_tuple)):
            ts = ts_tuple[i]
            control_prefixes.append(ts.controls_from_run(prefixes[i]))
            control_suffix_cycles.append(ts.controls_from_run(suffix_cycles[i]))
            logger.info('%s run prefix: %s', ts.name, prefixes[i])
            logger.info('%s control perfix: %s', ts.name, control_prefixes[i])
            logger.info('%s suffix cycle: %s', ts.name, suffix_cycles[i])
            logger.info('%s control suffix cycle: %s', ts.name,
                                                    control_suffix_cycles[i])

    logger.info('<><><> <><><> <><><>')

    # Case Study 4
    with Timer('IJRR 2013 Case-Study 4'):
        r1 = Ts.load('./robot_1.yaml')
        r2 = Ts.load('./robot_2.yaml')
        ts_tuple = (r1, r2)
        formula = ('[]<>gather && [](gather->(r1gather4 && r2gather2)) '
                   '&& [](r1gather -> X(!r1gather U r1upload)) '
                   '&& [](r2gather -> X(!r2gather U r2upload))')
        opt_prop = set(['r1gather4','r2gather2'])
        logger.info('Formula: %s', formula)
        logger.info('opt_prop: %s', opt_prop)
        prefix_length, prefixes, suffix_cycle_cost, suffix_cycles = \
                      lomap.multi_agent_optimal_run(ts_tuple, formula, opt_prop)
        logger.info('Cost: %d', suffix_cycle_cost)
        logger.info('Prefix length: %d', prefix_length)
        # Find the controls that will produce this run
        control_prefixes = []
        control_suffix_cycles = []
        for i in range(0, len(ts_tuple)):
            ts = ts_tuple[i]
            control_prefixes.append(ts.controls_from_run(prefixes[i]))
            control_suffix_cycles.append(ts.controls_from_run(suffix_cycles[i]))
            logger.info('%s run prefix: %s', ts.name, prefixes[i])
            logger.info('%s control perfix: %s', ts.name, control_prefixes[i])
            logger.info('%s suffix cycle: %s', ts.name, suffix_cycles[i])
            logger.info('%s control suffix cycle: %s', ts.name,
                                                    control_suffix_cycles[i])

    logger.info('<><><> <><><> <><><>')

    # Case Study 4 w/ sync
    with Timer('IJRR 2013 Case-Study 4 (w/ sync)'):
        r1 = Ts.load('./robot_1.yaml')
        r2 = Ts.load('./robot_2.yaml')
        ts_tuple = (r1, r2)
        formula = ('[]<>gather && [](gather->(r1gather4 && r2gather2)) '
                   '&& [](r1gather -> X(!r1gather U r1upload)) '
                   '&& [](r2gather -> X(!r2gather U r2upload))')
        opt_prop = set(['r1gather4','r2gather2'])
        logger.info('Formula: %s', formula)
        logger.info('opt_prop: %s', opt_prop)
        prefix_length, prefixes, suffix_cycle_cost, suffix_cycles = \
         lomap.robust_multi_agent_optimal_run(ts_tuple, rhos, formula, opt_prop)
        logger.info('Cost: %d', suffix_cycle_cost)
        logger.info('Prefix length: %d', prefix_length)
        # Find the controls that will produce this run
        control_prefixes = []
        control_suffix_cycles = []
        for i in range(0, len(ts_tuple)):
            ts = ts_tuple[i]
            control_prefixes.append(ts.controls_from_run(prefixes[i]))
            control_suffix_cycles.append(ts.controls_from_run(suffix_cycles[i]))
            logger.info('%s run prefix: %s', ts.name, prefixes[i])
            logger.info('%s control perfix: %s', ts.name, control_prefixes[i])
            logger.info('%s suffix cycle: %s', ts.name, suffix_cycles[i])
            logger.info('%s control suffix cycle: %s', ts.name,
                                                    control_suffix_cycles[i])
def main():

    Rho = namedtuple('Rho', ['lower', 'upper'])
    rhos = [Rho(lower=0.98, upper=1.04), Rho(lower=0.98, upper=1.04)]
    pdb.set_trace()

    # Case Study 1
    #	with lomap.Timer('IJRR 2013 Case-Study 1'):
    #		r1 = lomap.Ts()
    #		r2 = lomap.Ts()
    #		r1.read_from_file('./robot_1.txt')
    #		r2.read_from_file('./robot_2.txt')
    #		ts_tuple = (r1, r2)
    #		formula = '[]<>gather && [](r1gather -> X(!r1gather U r1upload)) && [](r2gather -> X(!r2gather U r2upload))'
    #		opt_prop = set(['gather'])
    #		logger.info('Formula: %s', formula)
    #		logger.info('opt_prop: %s', opt_prop)
    #		prefix_length, prefixes, suffix_cycle_cost, suffix_cycles = lomap.multi_agent_optimal_run(ts_tuple, formula, opt_prop)
    #		logger.info('Cost: %d', suffix_cycle_cost)
    #		logger.info('Prefix length: %d', prefix_length)
    #		# Find the controls that will produce this run
    #		control_prefixes = []
    #		control_suffix_cycles = []
    #		for i in range(0, len(ts_tuple)):
    #			ts = ts_tuple[i]
    #			control_prefixes.append(ts.controls_from_run(prefixes[i]))
    #			control_suffix_cycles.append(ts.controls_from_run(suffix_cycles[i]))
    #			logger.info('%s run prefix: %s', ts.name, prefixes[i])
    #			logger.info('%s control perfix: %s', ts.name, control_prefixes[i])
    #			logger.info('%s suffix cycle: %s', ts.name, suffix_cycles[i])
    #			logger.info('%s control suffix cycle: %s', ts.name, control_suffix_cycles[i])
    #
    #	logger.info('<><><> <><><> <><><>')

    # Case Study 4
    with lomap.Timer('IJRR 2013 Case-Study 4'):
        r1 = lomap.Ts()
        r2 = lomap.Ts()
        r1.read_from_file('./robot_1.txt')
        r2.read_from_file('./robot_2.txt')
        ts_tuple = (r1, r2)
        pdb.set_trace()
        formula = '[]<>gather && [](gather->(r1gather4 && r2gather2)) && [](r1gather -> X(!r1gather U r1upload)) && [](r2gather -> X(!r2gather U r2upload))'
        opt_prop = set(['r1gather4', 'r2gather2'])
        logger.info('Formula: %s', formula)
        logger.info('opt_prop: %s', opt_prop)
        prefix_length, prefixes, suffix_cycle_cost, suffix_cycles = lomap.multi_agent_optimal_run(
            ts_tuple, formula, opt_prop)
        logger.info('Cost: %d', suffix_cycle_cost)
        logger.info('Prefix length: %d', prefix_length)
        # Find the controls that will produce this run
        control_prefixes = []
        control_suffix_cycles = []
        for i in range(0, len(ts_tuple)):
            ts = ts_tuple[i]
            control_prefixes.append(ts.controls_from_run(prefixes[i]))
            control_suffix_cycles.append(ts.controls_from_run(
                suffix_cycles[i]))
            logger.info('%s run prefix: %s', ts.name, prefixes[i])
            logger.info('%s control perfix: %s', ts.name, control_prefixes[i])
            logger.info('%s suffix cycle: %s', ts.name, suffix_cycles[i])
            logger.info('%s control suffix cycle: %s', ts.name,
                        control_suffix_cycles[i])

    logger.info('<><><> <><><> <><><>')
Beispiel #3
0
def main():

	Rho = namedtuple('Rho', ['lower', 'upper'])
	rhos = [Rho(lower=0.98, upper=1.04), Rho(lower=0.98, upper=1.04)]

	# Case Study 1
#	with lomap.Timer('IJRR 2013 Case-Study 1'):
#		r1 = lomap.Ts()
#		r2 = lomap.Ts()
#		r1.read_from_file('./robot_1.txt')
#		r2.read_from_file('./robot_2.txt')
#		ts_tuple = (r1, r2)
#		formula = '[]<>gather && [](r1gather -> X(!r1gather U r1upload)) && [](r2gather -> X(!r2gather U r2upload))'
#		opt_prop = set(['gather'])
#		logger.info('Formula: %s', formula)
#		logger.info('opt_prop: %s', opt_prop)
#		prefix_length, prefixes, suffix_cycle_cost, suffix_cycles = lomap.multi_agent_optimal_run(ts_tuple, formula, opt_prop)
#		logger.info('Cost: %d', suffix_cycle_cost)
#		logger.info('Prefix length: %d', prefix_length)
#		# Find the controls that will produce this run
#		control_prefixes = []
#		control_suffix_cycles = []
#		for i in range(0, len(ts_tuple)):
#			ts = ts_tuple[i]
#			control_prefixes.append(ts.controls_from_run(prefixes[i]))
#			control_suffix_cycles.append(ts.controls_from_run(suffix_cycles[i]))
#			logger.info('%s run prefix: %s', ts.name, prefixes[i])
#			logger.info('%s control perfix: %s', ts.name, control_prefixes[i])
#			logger.info('%s suffix cycle: %s', ts.name, suffix_cycles[i])
#			logger.info('%s control suffix cycle: %s', ts.name, control_suffix_cycles[i])
#
#	logger.info('<><><> <><><> <><><>')

	# Case Study 2
	with lomap.Timer('IJRR 2013 Case-Study 2'):
		r1 = lomap.Ts()
		r2 = lomap.Ts()
		r1.read_from_file('./robot_1.txt')
		r2.read_from_file('./robot_2.txt')
		ts_tuple = (r1, r2)
		formula = '[]<>gather && [](gather->(r1gather && r2gather)) && [](r1gather -> X(!r1gather U r1upload)) && [](r2gather -> X(!r2gather U r2upload))'
		opt_prop = set(['r1gather','r2gather'])
		logger.info('Formula: %s', formula)
		logger.info('opt_prop: %s', opt_prop)
		prefix_length, prefixes, suffix_cycle_cost, suffix_cycles = lomap.robust_multi_agent_optimal_run(ts_tuple, rhos, formula, opt_prop)
		logger.info('Cost: %d', suffix_cycle_cost)
		logger.info('Prefix length: %d', prefix_length)
		# Find the controls that will produce this run
		control_prefixes = []
		control_suffix_cycles = []
		for i in range(0, len(ts_tuple)):
			ts = ts_tuple[i]
			control_prefixes.append(ts.controls_from_run(prefixes[i]))
			control_suffix_cycles.append(ts.controls_from_run(suffix_cycles[i]))
			logger.info('%s run prefix: %s', ts.name, prefixes[i])
			logger.info('%s control perfix: %s', ts.name, control_prefixes[i])
			logger.info('%s suffix cycle: %s', ts.name, suffix_cycles[i])
			logger.info('%s control suffix cycle: %s', ts.name, control_suffix_cycles[i])

	logger.info('<><><> <><><> <><><>')

	# Case Study 3
	with lomap.Timer('IJRR 2013 Case-Study 3'):
		r1 = lomap.Ts()
		r2 = lomap.Ts()
		r1.read_from_file('./robot_1.txt')
		r2.read_from_file('./robot_2.txt')
		ts_tuple = (r1, r2)
		formula = '[]<>gather && [](gather->(r1gather && r2gather)) && [](r1gather -> X(!r1gather U r1upload)) && [](r2gather -> X(!r2gather U r2upload)) && [](!(r1gather1 && r2gather1) && !(r1gather2 && r2gather2) && !(r1gather3 && r2gather3) && !(r1gather4 && r2gather4))'
		opt_prop = set(['r1gather','r2gather'])
		logger.info('Formula: %s', formula)
		logger.info('opt_prop: %s', opt_prop)
		prefix_length, prefixes, suffix_cycle_cost, suffix_cycles = lomap.robust_multi_agent_optimal_run(ts_tuple, rhos, formula, opt_prop)
		logger.info('Cost: %d', suffix_cycle_cost)
		logger.info('Prefix length: %d', prefix_length)
		# Find the controls that will produce this run
		control_prefixes = []
		control_suffix_cycles = []
		for i in range(0, len(ts_tuple)):
			ts = ts_tuple[i]
			control_prefixes.append(ts.controls_from_run(prefixes[i]))
			control_suffix_cycles.append(ts.controls_from_run(suffix_cycles[i]))
			logger.info('%s run prefix: %s', ts.name, prefixes[i])
			logger.info('%s control perfix: %s', ts.name, control_prefixes[i])
			logger.info('%s suffix cycle: %s', ts.name, suffix_cycles[i])
			logger.info('%s control suffix cycle: %s', ts.name, control_suffix_cycles[i])

	logger.info('<><><> <><><> <><><>')

	# Case Study 4
	with lomap.Timer('IJRR 2013 Case-Study 4'):
		r1 = lomap.Ts()
		r2 = lomap.Ts()
		r1.read_from_file('./robot_1.txt')
		r2.read_from_file('./robot_2.txt')
		ts_tuple = (r1, r2)
		formula = '[]<>gather && [](gather->(r1gather4 && r2gather2)) && [](r1gather -> X(!r1gather U r1upload)) && [](r2gather -> X(!r2gather U r2upload))'
		opt_prop = set(['r1gather4','r2gather2'])
		logger.info('Formula: %s', formula)
		logger.info('opt_prop: %s', opt_prop)
		prefix_length, prefixes, suffix_cycle_cost, suffix_cycles = lomap.multi_agent_optimal_run(ts_tuple, formula, opt_prop)
		logger.info('Cost: %d', suffix_cycle_cost)
		logger.info('Prefix length: %d', prefix_length)
		# Find the controls that will produce this run
		control_prefixes = []
		control_suffix_cycles = []
		for i in range(0, len(ts_tuple)):
			ts = ts_tuple[i]
			control_prefixes.append(ts.controls_from_run(prefixes[i]))
			control_suffix_cycles.append(ts.controls_from_run(suffix_cycles[i]))
			logger.info('%s run prefix: %s', ts.name, prefixes[i])
			logger.info('%s control perfix: %s', ts.name, control_prefixes[i])
			logger.info('%s suffix cycle: %s', ts.name, suffix_cycles[i])
			logger.info('%s control suffix cycle: %s', ts.name, control_suffix_cycles[i])

	logger.info('<><><> <><><> <><><>')

	# Case Study 4 w/ sync
	with lomap.Timer('IJRR 2013 Case-Study 4 (w/ sync)'):
		r1 = lomap.Ts()
		r2 = lomap.Ts()
		r1.read_from_file('./robot_1.txt')
		r2.read_from_file('./robot_2.txt')
		ts_tuple = (r1, r2)
		formula = '[]<>gather && [](gather->(r1gather4 && r2gather2)) && [](r1gather -> X(!r1gather U r1upload)) && [](r2gather -> X(!r2gather U r2upload))'
		opt_prop = set(['r1gather4','r2gather2'])
		logger.info('Formula: %s', formula)
		logger.info('opt_prop: %s', opt_prop)
		prefix_length, prefixes, suffix_cycle_cost, suffix_cycles = lomap.robust_multi_agent_optimal_run(ts_tuple, rhos, formula, opt_prop)
		logger.info('Cost: %d', suffix_cycle_cost)
		logger.info('Prefix length: %d', prefix_length)
		# Find the controls that will produce this run
		control_prefixes = []
		control_suffix_cycles = []
		for i in range(0, len(ts_tuple)):
			ts = ts_tuple[i]
			control_prefixes.append(ts.controls_from_run(prefixes[i]))
			control_suffix_cycles.append(ts.controls_from_run(suffix_cycles[i]))
			logger.info('%s run prefix: %s', ts.name, prefixes[i])
			logger.info('%s control perfix: %s', ts.name, control_prefixes[i])
			logger.info('%s suffix cycle: %s', ts.name, suffix_cycles[i])
			logger.info('%s control suffix cycle: %s', ts.name, control_suffix_cycles[i])