Skip to content

Commit

Permalink
Merge pull request gegelati#105 from gegelati/addLAGetEnvironment
Browse files Browse the repository at this point in the history
Add la get environment
  • Loading branch information
kdesnos authored Aug 29, 2022
2 parents f5b1267 + 38341a4 commit bad80b6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ _yyyy.mm.dd_
### New features
* Add `Data::PointerWrapper` class to simplify interracing of GEGELATI with primitive variables (non-array) data from a learning environment.
* Add `TPG::ExecutionsStats` class to analyze and export execution statistics gathered using an instrumented TPGGraph. Statistics include averages on numbers of evaluated teams, programs, program lines and instructions, execution traces and various distributions based on execution traces. The class also provides a method to export these statistics to a JSon file, which can be used by other programs and scripts.
* Add a new `Learn::LearningAgent::EvaluateOneRoot()` method to ease the evaluation of individual policies in a trained TPG.
* Add a new `Learn::LearningAgent::evaluateOneRoot()` method to ease the evaluation of individual policies in a trained TPG.
* Add a new `Learn::LearningAgent::getEnvironment()` method for convenience.

### Changes
* CodeGen TPGs (Switch and Stack modes) now match the execution behaviour of `TPGExecutionEngine`, especially regarding cycle handling. Now, a team can't be visited more than once per inference, and edges leading to an already visited team are not evaluated (their program are not executed).
Expand Down
7 changes: 7 additions & 0 deletions gegelatilib/include/learn/learningAgent.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ namespace Learn {
*/
const Archive& getArchive() const;

/**
* \brief Accessor to the Environment of the TPGGraph.
*
* \return the const reference to the env attribute.
*/
const Environment& getEnvironment() const;

/**
* \brief Getter for the RNG used by the LearningAgent.
*
Expand Down
5 changes: 5 additions & 0 deletions gegelatilib/src/learn/learningAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ const Archive& Learn::LearningAgent::getArchive() const
return this->archive;
}

const Environment& Learn::LearningAgent::getEnvironment() const
{
return this->env;
}

Mutator::RNG& Learn::LearningAgent::getRNG()
{
return this->rng;
Expand Down
9 changes: 9 additions & 0 deletions test/learningAgentTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,15 @@ TEST_F(LearningAgentTest, GetArchive)
<< "Cannot get the archive of a LearningAgent.";
}

TEST_F(LearningAgentTest, GetEnvironment)
{
Learn::LearningAgent la(le, set, params);

const Environment* env;
ASSERT_NO_THROW(env = &la.getEnvironment())
<< "Getting the environment of the learning agent failed unexpectedly.";
}

TEST_F(LearningAgentTest, UpdateEvaluationRecords)
{
// test bestRoot methods
Expand Down

0 comments on commit bad80b6

Please sign in to comment.