def main(): scenario_list = Parameter().list_scenarios n_scenario = Parameter().scenarios strategy = Environment.NEAR duty_cicle = False while True: option = input('\nOpções:\n' + ' 1. Imprime cenários\n' + ' 2. Executar todos os cenários\n' + ' 3. Escolher cenários\n' + ' 4. Escolher número de visitas\n' + ' 5. Duty-cicle\n' + ' 0. Sair\n') if option == '0': exit() elif option == '1': print(scenario_list) elif option == '2': execute_scenarios(1, n_scenario, strategy, duty_cicle) elif option == '3': ok = False while not ok: start, end = input('Imprima intervalo de cenários: ').split() start, end = int(start), int(end) if start > end: start, end = end, start if end <= n_scenario: ok = True execute_scenarios(start, end, strategy, duty_cicle) elif option == '4': turns = int(input('\nNúmero de visitas: ')) print(scenario_list) scenario = int(input('\nCenário: ')) parameter = Parameter() parameter.current = scenario - 1 results = execute_turn(parameter, strategy, turns, duty_cicle) more = 'Número de viagens Sink: ' + str(turns) + '\n' #more += 'Duty-cycle: ' #if duty_cicle: # more += 'habilitado' #else: # more += 'desabilitado' print_results(parameter, scenario, results, more) elif option == '5': if duty_cicle: dc = input('\nDesabilitar duty-cicle? [S/n]') if dc in ['s', 'S', '']: duty_cicle = False else: dc = input('\nHabilitar duty-cicle? [S/n]') if dc in ['s', 'S', '']: duty_cicle = True
def execute_scenarios(init, end, strategy, duty_cicle): parameter = Parameter() counter = init parameter.current = init - 1 while parameter.current < end: results = execute_turn(parameter, strategy, 1, duty_cicle) more = 'Duty-cycle: ' if duty_cicle: more += 'habilitado' else: more += 'desabilitado' print_results(parameter, counter, results, '') parameter.next() counter += 1
def main(): scenario_list = Parameter().list_scenarios n_scenario = Parameter().scenarios strategy = Environment.NEAR duty_cicle = False while True: option = input('\nOpções:\n' + ' 1. Imprime cenários\n' + ' 2. Executar todos os cenários\n' + ' 3. Escolher cenários\n' + ' 4. Escolher número de visitas\n' + ' 5. Duty-cicle\n' + ' 0. Sair\n') if option == '0': exit() elif option == '1': print(scenario_list) elif option == '2': execute_scenarios(1, n_scenario, strategy, duty_cicle) elif option == '3': ok = False while not ok: start, end = input('Imprima intervalo de cenários: ').split() start, end = int(start), int(end) if start > end: start, end = end, start if end <= n_scenario: ok = True execute_scenarios(start, end, strategy, duty_cicle) elif option == '4': turns = int(input('\nNúmero de visitas: ')) print(scenario_list) scenario = int(input('\nCenário: ')) parameter = Parameter() parameter.current = scenario - 1 results = execute_turn(parameter, strategy, turns, duty_cicle) more = 'Número de viagens Sink: ' + str(turns) + '\n' #more += 'Duty-cycle: ' #if duty_cicle: # more += 'habilitado' #else: # more += 'desabilitado' print_results(parameter, scenario, results, more) elif option == '5': if duty_cicle: dc = input('\nDesabilitar duty-cicle? [S/n]') if dc in ['s', 'S', '']: duty_cicle = False else: dc = input('\nHabilitar duty-cicle? [S/n]') if dc in ['s', 'S', '']: duty_cicle = True
def execute_scenarios(init, end, strategy, duty_cicle): parameter = Parameter() counter = init parameter.current = init - 1 while parameter.current < end: results = execute_turn(parameter, strategy, 1, duty_cicle) more = 'Duty-cycle: ' if duty_cicle: more += 'habilitado' else: more += 'desabilitado' print_results(parameter, counter, results, '') parameter.next() counter += 1