def test_should_copy_work_properly(self) -> None: solution = IntegerSolution(2, 3, [0, 5], [1, 2]) solution.variables = [1, 2] solution.objectives = [0.16, -2.34, 9.25] solution.attributes["attr"] = "value" new_solution = copy.copy(solution) self.assertEqual(solution.number_of_variables, new_solution.number_of_variables) self.assertEqual(solution.number_of_objectives, new_solution.number_of_objectives) self.assertEqual(solution.variables, new_solution.variables) self.assertEqual(solution.objectives, new_solution.objectives) self.assertEqual(solution.lower_bound, new_solution.lower_bound) self.assertEqual(solution.upper_bound, new_solution.upper_bound) self.assertIs(solution.lower_bound, solution.lower_bound) self.assertIs(solution.upper_bound, solution.upper_bound) self.assertEqual(solution.attributes, new_solution.attributes)
def test_should_copy_work_properly(self) -> None: solution = IntegerSolution(2, 3, 2, [0, 5], [1, 2]) solution.variables = [1, 2] solution.objectives = [0.16, -2.34, 9.25] solution.attributes["attr"] = "value" new_solution = copy.copy(solution) self.assertEqual(solution.number_of_variables, new_solution.number_of_variables) self.assertEqual(solution.number_of_objectives, new_solution.number_of_objectives) self.assertEqual(solution.number_of_constraints, new_solution.number_of_constraints) self.assertEqual(solution.variables, new_solution.variables) self.assertEqual(solution.objectives, new_solution.objectives) self.assertEqual(solution.lower_bound, new_solution.lower_bound) self.assertEqual(solution.upper_bound, new_solution.upper_bound) self.assertIs(solution.lower_bound, solution.lower_bound) self.assertIs(solution.upper_bound, solution.upper_bound) self.assertEqual({}, new_solution.attributes)
startTime = timeit.default_timer() BestTirf = [] BestInterfaceQuantity = [] solutionsResult = [] frontResult = 0 max_evaluations = MAX_EVALUATION Net = Network(folderName="Topologia2") problemOTN = OTNProblem(Net, len(Net.LinkBundles)) # problemOTN = OTNProblemFloat(Net, len(Net.LinkBundles)) stopCriterion = StoppingByEvaluationsCustom(max_evaluations, REFERENCE_POINT) # To topology 1, 200 is enough reference_point = IntegerSolution([LOWER_BOUND], [UPPER_BOUND], problemOTN.number_of_objectives, ) reference_point.objectives = REFERENCE_POINT # Mandatory for HYPE mutation_probability = 0.08 swarm_size = POPULATION_SIZE def configure_experiment(problems: dict, n_run: int): jobs = [] for run in range(n_run): for problem_tag, problem in problems.items(): jobs.append( Job( algorithm=NSGAII( problem=problem, population_size=POPULATION_SIZE, offspring_population_size=POPULATION_SIZE,