Skip to content

Commit

Permalink
Refactoring agent into reactive and cognitiveAgent
Browse files Browse the repository at this point in the history
  • Loading branch information
lmorisse committed Aug 16, 2020
1 parent 8e9510c commit e9dbb1f
Show file tree
Hide file tree
Showing 41 changed files with 1,447 additions and 892 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

## 0.91 [](https://github.com/lmorisse/symu/compare/v0.9.1..v0.9.0) by [lmorisse](https://github.com/lmorisse)
* Split Agent into ReactiveAgent and CognitiveAgent

## 0.9 [](https://github.com/lmorisse/symu/compare/v0.9.0..v0.8.0) by [lmorisse](https://github.com/lmorisse)
* Remove InteractionSphereModel.FrequencyOfSphereUpdate
* Schedule Bug fixe
Expand Down
3 changes: 3 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Release notes

## 0.9.1
This release contains a refactoring of the agent class

## 0.9.0
This release contains refactoring and minor bug fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

namespace SymuBeliefsAndInfluence.Classes
{
public sealed class InfluencerAgent : Agent
public sealed class InfluencerAgent : CognitiveAgent
{
public const byte ClassKey = SymuYellowPages.Actor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

namespace SymuBeliefsAndInfluence.Classes
{
public sealed class PersonAgent : Agent
public sealed class PersonAgent : CognitiveAgent
{
public const byte ClassKey = SymuYellowPages.Actor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public override void SetAgents()
}
}

private void SetKnowledge(Agent actor, IReadOnlyList<Knowledge> knowledges, int i)
private void SetKnowledge(CognitiveAgent actor, IReadOnlyList<Knowledge> knowledges, int i)
{
switch (Knowledge)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace SymuGroupAndInteraction.Classes
{
public sealed class GroupAgent : Agent
public sealed class GroupAgent : ReactiveAgent
{
public const byte ClassKey = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

namespace SymuGroupAndInteraction.Classes
{
public sealed class PersonAgent : Agent
public sealed class PersonAgent : CognitiveAgent
{
public const byte ClassKey = SymuYellowPages.Actor;

Expand Down
2 changes: 1 addition & 1 deletion Symu examples/SymuLearnAndForget/Classes/ExpertAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

namespace SymuLearnAndForget.Classes
{
public sealed class ExpertAgent : Agent
public sealed class ExpertAgent : CognitiveAgent
{
public const byte ClassKey = 2;

Expand Down
2 changes: 1 addition & 1 deletion Symu examples/SymuLearnAndForget/Classes/LearnAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

namespace SymuLearnAndForget.Classes
{
public class LearnAgent : Agent
public class LearnAgent : CognitiveAgent
{
public const byte ClassKey = 2;

Expand Down
2 changes: 1 addition & 1 deletion Symu examples/SymuMessageAndTask/Classes/GroupAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

namespace SymuMessageAndTask.Classes
{
public sealed class GroupAgent : Agent
public sealed class GroupAgent : ReactiveAgent
{
public const byte ClassKey = 1;

Expand Down
2 changes: 1 addition & 1 deletion Symu examples/SymuMessageAndTask/Classes/PersonAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

namespace SymuMessageAndTask.Classes
{
public sealed class PersonAgent : Agent
public sealed class PersonAgent : CognitiveAgent
{
public const byte ClassKey = 2;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace SymuMurphiesAndBlockers.Classes
{
public sealed class GroupAgent : Agent
public sealed class GroupAgent : ReactiveAgent
{
public const byte ClassKey = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace SymuMurphiesAndBlockers.Classes
/// <summary>
/// Provide an access to internet information if DynamicEnvironmentModel is On
/// </summary>
public sealed class InternetAccessAgent : Agent
public sealed class InternetAccessAgent : CognitiveAgent
{
public const byte ClassKey = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

namespace SymuMurphiesAndBlockers.Classes
{
public sealed class PersonAgent : Agent
public sealed class PersonAgent : CognitiveAgent
{
public const byte ClassKey = SymuYellowPages.Actor;

Expand Down
80 changes: 23 additions & 57 deletions Symu examples/SymuMurphiesAndBlockersTests/IntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,7 @@ private float CapacityRatio()
public void NoMurphiesTest(int knowledgeCount)
{
_environment.KnowledgeCount = (byte) knowledgeCount;
_environment.Organization.Murphies.IncompleteBelief.On = false;
_environment.Organization.Murphies.IncompleteKnowledge.On = false;
_environment.Organization.Murphies.UnAvailability.On = false;
_environment.Organization.Murphies.IncompleteInformation.On = false;
_environment.Organization.Murphies.Off();
_environment.Organization.Templates.Human.Cognitive.InternalCharacteristics.RiskAversionLevel =
GenericLevel.None;

Expand Down Expand Up @@ -162,9 +159,7 @@ public void OnlyUnavailabilityTest2()
[TestMethod]
public void OnlyKnowledgeTest()
{
_environment.Organization.Murphies.IncompleteBelief.On = false;
_environment.Organization.Murphies.UnAvailability.On = false;
_environment.Organization.Murphies.IncompleteInformation.On = false;
_environment.Organization.Murphies.Off();
_environment.Organization.Murphies.IncompleteKnowledge.On = true;
_environment.Organization.Murphies.IncompleteKnowledge.RateOfAgentsOn = 0;
_environment.Organization.Templates.Human.Cognitive.InternalCharacteristics.RiskAversionLevel =
Expand All @@ -185,9 +180,7 @@ public void OnlyKnowledgeTest()
[TestMethod]
public void OnlyKnowledgeTest1()
{
_environment.Organization.Murphies.IncompleteBelief.On = false;
_environment.Organization.Murphies.UnAvailability.On = false;
_environment.Organization.Murphies.IncompleteInformation.On = false;
_environment.Organization.Murphies.Off();
_environment.Organization.Murphies.IncompleteKnowledge.On = true;
_environment.Organization.Murphies.IncompleteKnowledge.RateOfAgentsOn = 1;
_environment.Organization.Murphies.IncompleteKnowledge.MandatoryRatio = 0;
Expand All @@ -210,9 +203,7 @@ public void OnlyKnowledgeTest1()
[TestMethod]
public void OnlyKnowledgeTest2()
{
_environment.Organization.Murphies.IncompleteBelief.On = false;
_environment.Organization.Murphies.UnAvailability.On = false;
_environment.Organization.Murphies.IncompleteInformation.On = false;
_environment.Organization.Murphies.Off();
_environment.Organization.Murphies.IncompleteKnowledge.On = true;
_environment.Organization.Murphies.IncompleteKnowledge.RateOfAgentsOn = 1;
_environment.Organization.Murphies.IncompleteKnowledge.MandatoryRatio = 1;
Expand All @@ -234,9 +225,7 @@ public void OnlyKnowledgeTest2()
[TestMethod]
public void OnlyKnowledgeTest3()
{
_environment.Organization.Murphies.IncompleteBelief.On = false;
_environment.Organization.Murphies.UnAvailability.On = false;
_environment.Organization.Murphies.IncompleteInformation.On = false;
_environment.Organization.Murphies.Off();
_environment.Organization.Murphies.IncompleteKnowledge.On = true;
_environment.Organization.Murphies.IncompleteKnowledge.RateOfAgentsOn = 1;
_environment.Organization.Murphies.IncompleteKnowledge.MandatoryRatio = 1;
Expand All @@ -256,9 +245,7 @@ public void OnlyKnowledgeTest3()
[TestMethod]
public void OnlyKnowledgeTest4()
{
_environment.Organization.Murphies.IncompleteBelief.On = false;
_environment.Organization.Murphies.UnAvailability.On = false;
_environment.Organization.Murphies.IncompleteInformation.On = false;
_environment.Organization.Murphies.Off();
_environment.Organization.Murphies.IncompleteKnowledge.On = true;
_environment.Organization.Murphies.IncompleteKnowledge.RateOfAgentsOn = 1;
_environment.Organization.Murphies.IncompleteKnowledge.MandatoryRatio = 1;
Expand All @@ -281,9 +268,7 @@ public void OnlyKnowledgeTest4()
[TestMethod]
public void OnlyKnowledgeTest5()
{
_environment.Organization.Murphies.IncompleteBelief.On = false;
_environment.Organization.Murphies.UnAvailability.On = false;
_environment.Organization.Murphies.IncompleteInformation.On = false;
_environment.Organization.Murphies.Off();
_environment.Organization.Murphies.IncompleteKnowledge.On = true;
_environment.Organization.Murphies.IncompleteKnowledge.RateOfAgentsOn = 1;
_environment.Organization.Murphies.IncompleteKnowledge.MandatoryRatio = 1;
Expand All @@ -304,9 +289,7 @@ public void OnlyKnowledgeTest5()
[TestMethod]
public void OnlyKnowledgeTest6()
{
_environment.Organization.Murphies.IncompleteBelief.On = false;
_environment.Organization.Murphies.UnAvailability.On = false;
_environment.Organization.Murphies.IncompleteInformation.On = false;
_environment.Organization.Murphies.Off();
_environment.Organization.Murphies.IncompleteKnowledge.On = true;
_environment.Organization.Murphies.IncompleteKnowledge.RateOfAgentsOn = 1;
_environment.Organization.Murphies.IncompleteKnowledge.MandatoryRatio = 1;
Expand All @@ -323,8 +306,11 @@ public void OnlyKnowledgeTest6()
Assert.IsTrue(TasksRatio() < 100);
Assert.AreEqual(0, _environment.IterationResult.Blockers.TotalInternalHelp);
Assert.AreEqual(0, _environment.IterationResult.Blockers.TotalSearches);
Assert.AreNotEqual(0, _environment.IterationResult.Blockers.TotalGuesses);
Assert.AreNotEqual(0, _environment.IterationResult.Blockers.TotalCancelled);
if (_environment.IterationResult.Blockers.Done > 0)
{
Assert.AreNotEqual(0, _environment.IterationResult.Blockers.TotalGuesses);
Assert.AreNotEqual(0, _environment.IterationResult.Blockers.TotalCancelled);
}
}

/// <summary>
Expand All @@ -333,9 +319,7 @@ public void OnlyKnowledgeTest6()
[TestMethod]
public void OnlyKnowledgeTest7()
{
_environment.Organization.Murphies.IncompleteBelief.On = false;
_environment.Organization.Murphies.UnAvailability.On = false;
_environment.Organization.Murphies.IncompleteInformation.On = false;
_environment.Organization.Murphies.Off();
_environment.Organization.Murphies.IncompleteKnowledge.On = true;
_environment.Organization.Murphies.IncompleteKnowledge.RateOfAgentsOn = 1;
_environment.Organization.Murphies.IncompleteKnowledge.MandatoryRatio = 1;
Expand Down Expand Up @@ -363,9 +347,7 @@ public void OnlyKnowledgeTest7()
[TestMethod]
public void OnlyKnowledgeTest8()
{
_environment.Organization.Murphies.IncompleteBelief.On = false;
_environment.Organization.Murphies.UnAvailability.On = false;
_environment.Organization.Murphies.IncompleteInformation.On = false;
_environment.Organization.Murphies.Off();
_environment.Organization.Murphies.IncompleteKnowledge.On = true;
_environment.Organization.Murphies.IncompleteKnowledge.RateOfAgentsOn = 1;
_environment.Organization.Murphies.IncompleteKnowledge.MandatoryRatio = 1;
Expand All @@ -388,9 +370,7 @@ public void OnlyKnowledgeTest8()
[TestMethod]
public void OnlyKnowledgeTest9()
{
_environment.Organization.Murphies.IncompleteBelief.On = false;
_environment.Organization.Murphies.UnAvailability.On = false;
_environment.Organization.Murphies.IncompleteInformation.On = false;
_environment.Organization.Murphies.Off();
_environment.Organization.Murphies.IncompleteKnowledge.On = true;
_environment.Organization.Murphies.IncompleteKnowledge.RateOfAgentsOn = 1;
_environment.Organization.Murphies.IncompleteKnowledge.MandatoryRatio = 1;
Expand Down Expand Up @@ -437,9 +417,7 @@ public void OnlyKnowledgeTest10()
[TestMethod]
public void OnlyBeliefsTest()
{
_environment.Organization.Murphies.IncompleteKnowledge.On = false;
_environment.Organization.Murphies.UnAvailability.On = false;
_environment.Organization.Murphies.IncompleteInformation.On = false;
_environment.Organization.Murphies.Off();
_environment.Organization.Murphies.IncompleteBelief.On = true;
_environment.Organization.Murphies.IncompleteBelief.RateOfAgentsOn = 0;
_environment.Organization.Templates.Human.Cognitive.InternalCharacteristics.RiskAversionLevel =
Expand All @@ -459,9 +437,7 @@ public void OnlyBeliefsTest()
[TestMethod]
public void OnlyBeliefsTest1()
{
_environment.Organization.Murphies.IncompleteKnowledge.On = false;
_environment.Organization.Murphies.UnAvailability.On = false;
_environment.Organization.Murphies.IncompleteInformation.On = false;
_environment.Organization.Murphies.Off();
_environment.Organization.Murphies.IncompleteBelief.On = true;
_environment.Organization.Murphies.IncompleteBelief.RateOfAgentsOn = 1;
_environment.Organization.Templates.Human.Cognitive.KnowledgeAndBeliefs.DefaultBeliefLevel =
Expand All @@ -481,9 +457,7 @@ public void OnlyBeliefsTest1()
[TestMethod]
public void OnlyBeliefsTest2()
{
_environment.Organization.Murphies.IncompleteKnowledge.On = false;
_environment.Organization.Murphies.UnAvailability.On = false;
_environment.Organization.Murphies.IncompleteInformation.On = false;
_environment.Organization.Murphies.Off();
_environment.Organization.Murphies.IncompleteBelief.On = true;
_environment.Organization.Murphies.IncompleteBelief.RateOfAgentsOn = 1;
_environment.Organization.Murphies.IncompleteBelief.ThresholdForReacting = 1;
Expand All @@ -504,9 +478,7 @@ public void OnlyBeliefsTest2()
[TestMethod]
public void OnlyBeliefsTest3()
{
_environment.Organization.Murphies.IncompleteKnowledge.On = false;
_environment.Organization.Murphies.UnAvailability.On = false;
_environment.Organization.Murphies.IncompleteInformation.On = false;
_environment.Organization.Murphies.Off();
_environment.Organization.Murphies.IncompleteBelief.On = true;
_environment.Organization.Murphies.IncompleteBelief.RateOfAgentsOn = 1;
_environment.Organization.Murphies.IncompleteBelief.ThresholdForReacting = 0;
Expand All @@ -532,9 +504,7 @@ public void OnlyBeliefsTest3()
[TestMethod]
public void OnlyBeliefsTest4()
{
_environment.Organization.Murphies.IncompleteKnowledge.On = false;
_environment.Organization.Murphies.UnAvailability.On = false;
_environment.Organization.Murphies.IncompleteInformation.On = false;
_environment.Organization.Murphies.Off();
_environment.Organization.Murphies.IncompleteBelief.On = true;
_environment.Organization.Murphies.IncompleteBelief.RateOfAgentsOn = 1;
//_environment.Organization.Templates.Human.Cognitive.InternalCharacteristics.RiskAversionThreshold = 0;
Expand All @@ -561,9 +531,7 @@ public void OnlyBeliefsTest4()
[TestMethod]
public void OnlyBeliefsTest5()
{
_environment.Organization.Murphies.IncompleteKnowledge.On = false;
_environment.Organization.Murphies.UnAvailability.On = false;
_environment.Organization.Murphies.IncompleteInformation.On = false;
_environment.Organization.Murphies.Off();
_environment.Organization.Murphies.IncompleteBelief.On = true;
_environment.Organization.Murphies.IncompleteBelief.RateOfAgentsOn = 1;
_environment.Organization.Murphies.IncompleteBelief.ThresholdForReacting = 0;
Expand All @@ -589,9 +557,7 @@ public void OnlyBeliefsTest5()
[TestMethod]
public void OnlyBeliefsTest6()
{
_environment.Organization.Murphies.IncompleteKnowledge.On = false;
_environment.Organization.Murphies.UnAvailability.On = false;
_environment.Organization.Murphies.IncompleteInformation.On = false;
_environment.Organization.Murphies.Off();
_environment.Organization.Murphies.IncompleteBelief.On = true;
_environment.Organization.Murphies.IncompleteBelief.RateOfAgentsOn = 1;
_environment.Organization.Murphies.IncompleteBelief.ThresholdForReacting = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void KnowledgeEvent(object sender, EventArgs e)
var knowledge = new Knowledge(KnowledgeCount, KnowledgeCount.ToString(), 10);
WhitePages.Network.AddKnowledge(knowledge);

foreach (var person in WhitePages.FilteredAgentsByClassKey(PersonAgent.ClassKey))
foreach (var person in WhitePages.FilteredCognitiveAgentsByClassKey(PersonAgent.ClassKey))
{
person.KnowledgeModel.AddKnowledge(knowledge.Id, KnowledgeLevel.BasicKnowledge, 0.15F, -1);
person.KnowledgeModel.InitializeKnowledge(knowledge.Id, Schedule.Step);
Expand Down
2 changes: 1 addition & 1 deletion Symu examples/SymuScenariosAndEvents/Classes/GroupAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace SymuScenariosAndEvents.Classes
{
public sealed class GroupAgent : Agent
public sealed class GroupAgent : ReactiveAgent
{
public const byte ClassKey = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

namespace SymuScenariosAndEvents.Classes
{
public sealed class PersonAgent : Agent
public sealed class PersonAgent : CognitiveAgent
{
public const byte ClassKey = SymuYellowPages.Actor;

Expand Down
Loading

0 comments on commit e9dbb1f

Please sign in to comment.