From 03216f33ec5459a7de55cd855434374219e95f0f Mon Sep 17 00:00:00 2001 From: kdesnos Date: Thu, 15 Sep 2022 10:52:47 +0200 Subject: [PATCH] (Mutator) Update comments of the mutateOutgoingEdge() method which did not reflect the current behavior of the function. --- gegelatilib/include/mutator/tpgMutator.h | 18 +++++++----------- gegelatilib/src/mutator/tpgMutator.cpp | 8 ++++---- test/mutatorTest.cpp | 6 +++--- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/gegelatilib/include/mutator/tpgMutator.h b/gegelatilib/include/mutator/tpgMutator.h index 35d0caa5..c443791b 100644 --- a/gegelatilib/include/mutator/tpgMutator.h +++ b/gegelatilib/include/mutator/tpgMutator.h @@ -139,19 +139,16 @@ namespace Mutator { const Mutator::MutationParameters& params, Mutator::RNG& rng); /** - * \brief Mutate the Program and the Destination of the given TPGEdge. + * \brief Prepares the mutation of a TPGEdge. * - * This function mutates the behavior of the given TPGEdge Program, - * using the ProgramMutator functions, until the Program behavior is - * unique according to recordings held in the given Archive. - * The Program mutation is applied systematically, and a call to - * MutateEdgeDestination is also made with a probability from the - * given MutationParameters. + * This function creates a copy of the program associated to the TPGEdge + * in preparation of its mutation. The methods also takes care of + * stochastically mutating the destination of the TPGEdge. The copied + * program are referenced in the newProgram list, and their behavior + * must be mutated after this function to complete the mutation process. * * \param[in,out] graph the TPGGraph within which the team and edge are * stored. - * \param[in] archive Archive used to assess the uniqueness of the - * mutated Program behavior. * \param[in] edge the TPGEdge whose destination will be altered. * \param[in] preExistingTeams the TPGTeam candidates for destination. * \param[in] preExistingActions the TPGAction candidates for @@ -164,8 +161,7 @@ namespace Mutator { * \param[in] rng Random Number Generator used in the mutation process. */ void mutateOutgoingEdge( - TPG::TPGGraph& graph, const Archive& archive, - const TPG::TPGEdge* edge, + TPG::TPGGraph& graph, const TPG::TPGEdge* edge, const std::vector& preExistingTeams, const std::vector& preExistingActions, std::list>& newPrograms, diff --git a/gegelatilib/src/mutator/tpgMutator.cpp b/gegelatilib/src/mutator/tpgMutator.cpp index 2454ed81..cf6be20d 100644 --- a/gegelatilib/src/mutator/tpgMutator.cpp +++ b/gegelatilib/src/mutator/tpgMutator.cpp @@ -236,7 +236,7 @@ void Mutator::TPGMutator::mutateEdgeDestination( } void Mutator::TPGMutator::mutateOutgoingEdge( - TPG::TPGGraph& graph, const Archive& archive, const TPG::TPGEdge* edge, + TPG::TPGGraph& graph, const TPG::TPGEdge* edge, const std::vector& preExistingTeams, const std::vector& preExistingActions, std::list>& newPrograms, @@ -295,17 +295,17 @@ void Mutator::TPGMutator::mutateTPGTeam( } } - // 3. Mutate program of the team + // 3. Mutate edges of the team { bool anyMutationDone = false; do { // Process edge-by-edge - // And possibly modify their behavior and their target + // And possibly modify their target for (TPG::TPGEdge* edge : team.getOutgoingEdges()) { // Edge->Program bid modification if (rng.getDouble(0.0, 1.0) < params.tpg.pProgramMutation) { // Mutate the edge - mutateOutgoingEdge(graph, archive, edge, preExistingTeams, + mutateOutgoingEdge(graph, edge, preExistingTeams, preExistingActions, newPrograms, params, rng); anyMutationDone = true; diff --git a/test/mutatorTest.cpp b/test/mutatorTest.cpp index 8fad47bd..706f7d2d 100644 --- a/test/mutatorTest.cpp +++ b/test/mutatorTest.cpp @@ -767,7 +767,7 @@ TEST_F(MutatorTest, TPGMutatorMutateOutgoingEdge) std::list> newPrograms; ASSERT_NO_THROW(Mutator::TPGMutator::mutateOutgoingEdge( - tpg, arch, &edge0, {&vertex0}, {&vertex1}, newPrograms, params, rng)); + tpg, &edge0, {&vertex0}, {&vertex1}, newPrograms, params, rng)); // Check that progPointer use count was decreased since the mutated program // is a copy of the original @@ -861,8 +861,8 @@ TEST_F(MutatorTest, TPGMutatorMutateProgramBehaviorAgainstArchive) std::list> newPrograms; - Mutator::TPGMutator::mutateOutgoingEdge( - tpg, arch, &edge0, {&vertex0}, {&vertex1}, newPrograms, params, rng); + Mutator::TPGMutator::mutateOutgoingEdge(tpg, &edge0, {&vertex0}, {&vertex1}, + newPrograms, params, rng); ASSERT_NO_THROW(Mutator::TPGMutator::mutateProgramBehaviorAgainstArchive( newPrograms.front(), params, arch, rng))