Skip to content

Commit

Permalink
(Mutator) Update comments of the mutateOutgoingEdge() method which di…
Browse files Browse the repository at this point in the history
…d not reflect the current behavior of the function.
  • Loading branch information
kdesnos committed Sep 15, 2022
1 parent 1298470 commit 03216f3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
18 changes: 7 additions & 11 deletions gegelatilib/include/mutator/tpgMutator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<const TPG::TPGTeam*>& preExistingTeams,
const std::vector<const TPG::TPGAction*>& preExistingActions,
std::list<std::shared_ptr<Program::Program>>& newPrograms,
Expand Down
8 changes: 4 additions & 4 deletions gegelatilib/src/mutator/tpgMutator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const TPG::TPGTeam*>& preExistingTeams,
const std::vector<const TPG::TPGAction*>& preExistingActions,
std::list<std::shared_ptr<Program::Program>>& newPrograms,
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions test/mutatorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ TEST_F(MutatorTest, TPGMutatorMutateOutgoingEdge)
std::list<std::shared_ptr<Program::Program>> 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
Expand Down Expand Up @@ -861,8 +861,8 @@ TEST_F(MutatorTest, TPGMutatorMutateProgramBehaviorAgainstArchive)

std::list<std::shared_ptr<Program::Program>> 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))
Expand Down

0 comments on commit 03216f3

Please sign in to comment.