@classmethod<EOL><INDENT>def divide(cls, divisions, problem_data):<DEDENT>
tspp = TSPProblem(**problem_data)<EOL>def routes_for_subgroup(cs):<EOL><INDENT>for city in cs:<EOL><INDENT>if city == tspp.start_city:<EOL><INDENT>continue<EOL><DEDENT>cities = tspp.cities.keys()<EOL>cities.remove(tspp.start_city)<EOL>cities.remove(city)<EOL>random.shuffle(cities)<EOL>route = [tspp.start_city, city] + cities<EOL>assert len(set(route)) == len(route)<EOL>assert len(route) == len(tspp.cities)<EOL>yield json.dumps(route)<EOL><DEDENT><DEDENT>if divisions:<EOL><INDENT>chunk_size = int(math.ceil(len(tspp.cities) / divisions))<EOL><DEDENT>else:<EOL><INDENT>chunk_size = <NUM_LIT:1><EOL><DEDENT>for subgroup in chunks(tspp.cities.keys(), chunk_size):<EOL><INDENT>routes = list(routes_for_subgroup(subgroup))<EOL>if routes:<EOL><INDENT>yield routes<EOL><DEDENT><DEDENT>
divide

        :type problem_data: dict