Skip to content

Commit

Permalink
Update SymuMurphiesAndBlockers
Browse files Browse the repository at this point in the history
  • Loading branch information
lmorisse committed May 27, 2020
1 parent dc25030 commit 8316d50
Show file tree
Hide file tree
Showing 68 changed files with 3,841 additions and 1,497 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Changelog

## Unreleased
* Renaming SimulationEngine (SymuEngine), TimeStep (Schedule)
* Add MurphyIncompleteInformation by [@lmorisse]
* Renaming SimulationEngine (SymuEngine), TimeStep (Schedule) by [@lmorisse]
* Refactoring Murphies by [@lmorisse]
* Add Agent.TimeSpent by [@lmorisse]
* Add new project example: [SymuMurphiesAndBlockers](https://github.com/lmorisse/Symu/tree/master/Symu%20examples/SymuMurphiesAndBlockers) by [@lmorisse]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ public override void SetOrganization(OrganizationEntity organization)
organization.Models.Generator = RandomGenerator.RandomUniform;
organization.Models.FollowGroupKnowledge = true;
organization.Models.FollowGroupFlexibility = true;
organization.Models.FollowTasks = true;
organization.Murphies.Off();
organization.Murphies.IncompleteBelief.On = true;
organization.Murphies.IncompleteBelief.RateOfAgentsOn = 1;
IterationResult.Tasks.On = true;
organization.Models.InteractionSphere.On = true;
organization.Models.InteractionSphere.SphereUpdateOverTime = true;
organization.Models.InteractionSphere.FrequencyOfSphereUpdate = TimeStepType.Monthly;
Expand Down
190 changes: 115 additions & 75 deletions Symu examples/SymuBeliefsAndInfluence/Home.Designer.cs

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion Symu examples/SymuBeliefsAndInfluence/Home.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private void UpdateAgents()
.ToString("F1", CultureInfo.InvariantCulture));
var tasksDoneRatio = _environment.Schedule.Step * _environment.WorkersCount < Constants.Tolerance
? 0
: _environment.IterationResult.Tasks.Total * 100 /
: _environment.IterationResult.Tasks.Done * 100 /
(_environment.Schedule.Step * _environment.WorkersCount);
if (_environment.Schedule.Step == 1)
{
Expand All @@ -177,6 +177,8 @@ private void UpdateAgents()
.ToString("F1", CultureInfo.InvariantCulture));
WriteTextSafe(TasksDone, tasksDoneRatio
.ToString("F1", CultureInfo.InvariantCulture));
WriteTextSafe(TasksCancelled, _environment.IterationResult.Tasks.Cancelled
.ToString("F0", CultureInfo.InvariantCulture));
}

private void button4_Click(object sender, EventArgs e)
Expand Down
50 changes: 25 additions & 25 deletions Symu examples/SymuBeliefsAndInfluenceTests/IntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ public class IntegrationTests
private const int NumberOfSteps = 61; // 3 IterationResult computations
private readonly ExampleEnvironment _environment = new ExampleEnvironment();
private readonly OrganizationEntity _organization = new OrganizationEntity("1");
private readonly SymuEngine _symu = new SymuEngine();
private readonly SymuEngine _simulation = new SymuEngine();

[TestInitialize]
public void Initialize()
{
_environment.SetOrganization(_organization);
_symu.SetEnvironment(_environment);
_simulation.SetEnvironment(_environment);
_environment.SetDebug(true);
var scenario = new TimeStepScenario(_environment)
{
NumberOfSteps = NumberOfSteps
};
_symu.AddScenario(scenario);
_simulation.AddScenario(scenario);
}

/// <summary>
Expand All @@ -54,7 +54,7 @@ public void Initialize()
public void NoBeliefTest()
{
_environment.KnowledgeCount = 0;
_symu.Process();
_simulation.Process();
Assert.AreEqual(0, _environment.IterationResult.OrganizationKnowledgeAndBelief.Beliefs.First().Sum);
Assert.AreEqual(100, _environment.IterationResult.OrganizationFlexibility.Triads.First().Density);
}
Expand All @@ -67,7 +67,7 @@ public void HasBeliefsTest()
{
_environment.InfluencerTemplate.Cognitive.KnowledgeAndBeliefs.HasBelief = false;
_environment.WorkerTemplate.Cognitive.KnowledgeAndBeliefs.HasBelief = false;
_symu.Process();
_simulation.Process();
Assert.AreEqual(0, _environment.IterationResult.OrganizationKnowledgeAndBelief.Beliefs.First().Sum);
Assert.AreEqual(100, _environment.IterationResult.OrganizationFlexibility.Triads.First().Density);
}
Expand All @@ -79,7 +79,7 @@ public void HasBeliefsTest()
public void InfluenceModelTest()
{
_environment.Organization.Models.Influence.On = false;
_symu.Process();
_simulation.Process();
CheckNoChange();
}

Expand All @@ -90,7 +90,7 @@ public void InfluenceModelTest()
public void InfluenceModelTest1()
{
_environment.Organization.Models.Influence.RateOfAgentsOn = 0;
_symu.Process();
_simulation.Process();
CheckNoChange();
}

Expand All @@ -101,7 +101,7 @@ public void InfluenceModelTest1()
public void NoInfluencerTest()
{
_environment.InfluencersCount = 0;
_symu.Process();
_simulation.Process();
CheckNoChange();
}

Expand All @@ -113,7 +113,7 @@ public void NoInfluencerTest()
public void CantSendBeliefsTest()
{
_environment.InfluencerTemplate.Cognitive.MessageContent.CanSendBeliefs = false;
_symu.Process();
_simulation.Process();
CheckNoChange();
}

Expand All @@ -128,7 +128,7 @@ public void MinimumBeliefsToSendTest()
_environment.InfluencerTemplate.Cognitive.MessageContent.MinimumBeliefToSendPerBit = 1;
_environment.InfluencerTemplate.Cognitive.KnowledgeAndBeliefs.DefaultBeliefLevel =
BeliefLevel.StronglyDisagree;
_symu.Process();
_simulation.Process();
CheckNoChange();
}

Expand All @@ -143,7 +143,7 @@ public void BeliefBitsToSendTest()
_environment.InfluencerTemplate.Cognitive.MessageContent.MaximumNumberOfBitsOfBeliefToSend = 0;
_environment.InfluencerTemplate.Cognitive.KnowledgeAndBeliefs.DefaultBeliefLevel =
BeliefLevel.StronglyDisagree;
_symu.Process();
_simulation.Process();
CheckNoChange();
}

Expand All @@ -158,7 +158,7 @@ public void MinimumBeliefsToSendTest2()
_environment.InfluencerTemplate.Cognitive.MessageContent.MinimumBeliefToSendPerBit = 1;
_environment.InfluencerTemplate.Cognitive.KnowledgeAndBeliefs.DefaultBeliefLevel =
BeliefLevel.StronglyAgree;
_symu.Process();
_simulation.Process();
CheckNoChange();
}

Expand All @@ -170,7 +170,7 @@ public void MinimumBeliefsToSendTest2()
public void CantReceiveBeliefsTest()
{
_environment.WorkerTemplate.Cognitive.MessageContent.CanReceiveBeliefs = false;
_symu.Process();
_simulation.Process();
CheckNoChange();
}

Expand All @@ -182,7 +182,7 @@ public void CantReceiveBeliefsTest()
public void NoInfluentialnessTest()
{
_environment.InfluencerTemplate.Cognitive.InternalCharacteristics.InfluentialnessRateMax = 0;
_symu.Process();
_simulation.Process();
CheckNoChange();
}

Expand All @@ -194,7 +194,7 @@ public void NoInfluentialnessTest()
public void NoInfluenceabilityTest()
{
_environment.WorkerTemplate.Cognitive.InternalCharacteristics.InfluenceabilityRateMax = 0;
_symu.Process();
_simulation.Process();
CheckNoChange();
}

Expand All @@ -210,7 +210,7 @@ private void CheckNoChange()
public void NoTaskBlockedTest()
{
_environment.Model.MandatoryRatio = 0;
_symu.Process();
_simulation.Process();
CheckNoChange();
var tasksDoneRatio = _environment.Schedule.Step * _environment.WorkersCount < Constants.Tolerance
? 0
Expand All @@ -224,7 +224,7 @@ public void NoRiskAversionTest()
{
_environment.Model.MandatoryRatio = 1;
_environment.WorkerTemplate.Cognitive.InternalCharacteristics.RiskAversionThreshold = 1;
_symu.Process();
_simulation.Process();
CheckNoChange();
var tasksDoneRatio = _environment.Schedule.Step * _environment.WorkersCount < Constants.Tolerance
? 0
Expand All @@ -238,7 +238,7 @@ public void NoWeightTest()
{
_environment.Model.MandatoryRatio = 1;
_environment.WhitePages.Network.NetworkBeliefs.BeliefWeightLevel = BeliefWeightLevel.NoWeight;
_symu.Process();
_simulation.Process();
CheckNoChange();
var tasksDoneRatio = _environment.Schedule.Step * _environment.WorkersCount < Constants.Tolerance
? 0
Expand All @@ -254,11 +254,11 @@ public void FullWeightTest()
_environment.WorkerTemplate.Cognitive.InternalCharacteristics.RiskAversionThreshold =
0; // Full risk aversion
_environment.WhitePages.Network.NetworkBeliefs.BeliefWeightLevel = BeliefWeightLevel.FullWeight;
_symu.Process();
_simulation.Process();
CheckNoChange();
var tasksDoneRatio = _environment.Schedule.Step * _environment.WorkersCount < Constants.Tolerance
? 0
: _environment.IterationResult.Tasks.Total * 100 /
: _environment.IterationResult.Tasks.Done * 100 /
(_environment.Schedule.Step * _environment.WorkersCount);
Assert.AreNotEqual(100, tasksDoneRatio);
}
Expand All @@ -272,12 +272,12 @@ public void FullWeightTest()
public void StronglyDisagreeTest()
{
_environment.WorkerTemplate.Cognitive.InternalCharacteristics.RiskAversionThreshold =
0; // Full risk aversion
1; // no risk aversion
_environment.InfluencerTemplate.Cognitive.InternalCharacteristics.InfluentialnessRateMax = 1;
_environment.InfluencerTemplate.Cognitive.InternalCharacteristics.InfluentialnessRateMin = 1;
_environment.InfluencerTemplate.Cognitive.KnowledgeAndBeliefs.DefaultBeliefLevel =
BeliefLevel.StronglyDisagree;
_symu.Process();
_simulation.Process();
Assert.IsTrue(_environment.IterationResult.OrganizationKnowledgeAndBelief.Beliefs.First().Sum >
_environment.IterationResult.OrganizationKnowledgeAndBelief.Beliefs.Last().Sum);
Assert.IsTrue(_environment.IterationResult.OrganizationKnowledgeAndBelief.Beliefs.First().Mean >
Expand All @@ -295,12 +295,12 @@ public void StronglyDisagreeTest()
public void StronglyAgreeTest()
{
_environment.WorkerTemplate.Cognitive.InternalCharacteristics.RiskAversionThreshold =
0; // Full risk aversion
1; // no risk aversion
_environment.InfluencerTemplate.Cognitive.InternalCharacteristics.InfluentialnessRateMax = 1;
_environment.InfluencerTemplate.Cognitive.InternalCharacteristics.InfluentialnessRateMin = 1;
_environment.InfluencerTemplate.Cognitive.KnowledgeAndBeliefs.DefaultBeliefLevel =
BeliefLevel.StronglyAgree;
_symu.Process();
_simulation.Process();
Assert.IsTrue(_environment.IterationResult.OrganizationKnowledgeAndBelief.Beliefs.First().Sum <
_environment.IterationResult.OrganizationKnowledgeAndBelief.Beliefs.Last().Sum);
Assert.IsTrue(_environment.IterationResult.OrganizationKnowledgeAndBelief.Beliefs.First().Mean <
Expand All @@ -321,7 +321,7 @@ public void NeitherAgreeNorDisagreeTest()
_environment.InfluencerTemplate.Cognitive.InternalCharacteristics.InfluentialnessRateMin = 1;
_environment.InfluencerTemplate.Cognitive.KnowledgeAndBeliefs.DefaultBeliefLevel =
BeliefLevel.NeitherAgreeNorDisagree;
_symu.Process();
_simulation.Process();
CheckNoChange();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public override void GetNewTasks()
{
Parent = Schedule.Step,
// Cost impact of learning by doing
Weight = 1 * Cognitive.TasksAndPerformance.CostFactorOfLearningByDoing
Weight = 1 * Environment.Organization.Murphies.IncompleteKnowledge.CostFactorOfGuessing
};
Post(task);
}
Expand Down
8 changes: 4 additions & 4 deletions Symu examples/SymuLearnAndForget/Home.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private void LoadSettings()
cbHasKnowledge.Checked =
OrganizationEntity.Templates.Human.Cognitive.KnowledgeAndBeliefs.HasKnowledge;
tbKnowledgeThreshold.Text =
OrganizationEntity.Murphies.IncompleteKnowledge.KnowledgeThresholdForDoing
OrganizationEntity.Murphies.IncompleteKnowledge.ThresholdForReacting
.ToString(CultureInfo.InvariantCulture);
tbTimeToLive.Text =
OrganizationEntity.Templates.Human.Cognitive.InternalCharacteristics.TimeToLive.ToString(
Expand All @@ -73,7 +73,7 @@ private void LoadSettings()
OrganizationEntity.Templates.Human.Cognitive.TasksAndPerformance.LearningByDoingRate.ToString(
CultureInfo.InvariantCulture);
tbTaskCostFactor.Text =
OrganizationEntity.Templates.Human.Cognitive.TasksAndPerformance.CostFactorOfLearningByDoing
OrganizationEntity.Murphies.IncompleteKnowledge.CostFactorOfGuessing
.ToString(CultureInfo.InvariantCulture);
cbCanSendKnowledge.Checked =
OrganizationEntity.Templates.Human.Cognitive.MessageContent.CanSendKnowledge;
Expand Down Expand Up @@ -374,7 +374,7 @@ private void tbKnowledgeThreshold_TextChanged(object sender, EventArgs e)
{
try
{
OrganizationEntity.Murphies.IncompleteKnowledge.KnowledgeThresholdForDoing=
OrganizationEntity.Murphies.IncompleteKnowledge.ThresholdForReacting=
float.Parse(tbKnowledgeThreshold.Text, CultureInfo.InvariantCulture);
tbKnowledgeThreshold.BackColor = SystemColors.Window;
}
Expand Down Expand Up @@ -431,7 +431,7 @@ private void tbTaskCostFactor_TextChanged(object sender, EventArgs e)
{
try
{
OrganizationEntity.Templates.Human.Cognitive.TasksAndPerformance.CostFactorOfLearningByDoing =
OrganizationEntity.Murphies.IncompleteKnowledge.CostFactorOfGuessing =
float.Parse(tbTaskCostFactor.Text, CultureInfo.InvariantCulture);
tbTaskCostFactor.BackColor = SystemColors.Window;
}
Expand Down
2 changes: 1 addition & 1 deletion Symu examples/SymuLearnAndForgetTests/IntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void LearnByDoingTest3()
_organization.Models.Learning.RateOfAgentsOn = 1;
_organization.Templates.Human.Cognitive.KnowledgeAndBeliefs.HasInitialKnowledge = true;
_organization.Models.Generator = RandomGenerator.RandomBinary;
_organization.Murphies.IncompleteKnowledge.KnowledgeThresholdForDoing= 0;
_organization.Murphies.IncompleteKnowledge.ThresholdForReacting= 0;
_environment.KnowledgeLevel = KnowledgeLevel.BasicKnowledge;
_symu.Process();
// Should be > 0 because Knowledge threshold for doing is == 0, agent has the knowledge or not but he can't learn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public override void SetOrganization(OrganizationEntity organization)
base.SetOrganization(organization);

organization.Templates.Human.Cognitive.InteractionPatterns.IsolationIsRandom = true;
organization.Models.FollowTasks = true;
IterationResult.Tasks.On = true;
organization.Murphies.Off();

SetDebug(false);
Expand Down
3 changes: 2 additions & 1 deletion Symu examples/SymuMessageAndTask/Home.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Symu examples/SymuMessageAndTaskTests/IntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public void TaskModelOffTest()
[TestMethod]
public void TaskModelOnTest()
{
_organization.Templates.Human.Cognitive.InteractionPatterns.AgentCanBeIsolated = Frequency.Never;
_organization.Templates.Human.Cognitive.TasksAndPerformance.CanPerformTask = true;
_symu.Process();
var total = _environment.IterationResult.Tasks.Total;
Expand Down

0 comments on commit 8316d50

Please sign in to comment.