Skip to content

Commit

Permalink
V0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lmorisse committed Jun 9, 2020
1 parent 8de375e commit 1c88a5e
Show file tree
Hide file tree
Showing 304 changed files with 1,451 additions and 1,050 deletions.
13 changes: 7 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

## Unreleased

## 0.8.0 [](https://github.com/lmorisse/symu/compare/v0.8.0..v0.7.0) by [lmorisse](https://github.com/lmorisse)
* Refactoring IterationResult
* Add LearningModel.OnAfterLearning event
* Refactoring Agent constructor and CommunicationTemplates
* Add CyclicalIsolation by [lmorisse](https://github.com/lmorisse)
* Add PromoterTemplate by [lmorisse](https://github.com/lmorisse)
* Add Iterations and Charts in SymuMessageAndTask example by [lmorisse](https://github.com/lmorisse)
* Refactoring BlockerCollection, BlockerResults and TasksResults by [lmorisse](https://github.com/lmorisse)
* Add MessageResults by [lmorisse](https://github.com/lmorisse)

* Add CyclicalIsolation)
* Add PromoterTemplate
* Add Iterations and Charts in SymuMessageAndTask example
* Refactoring BlockerCollection, BlockerResults and TasksResults
* Add MessageResults

## 0.7.0 [](https://github.com/lmorisse/symu/compare/v0.7.0..v0.6.0) by [lmorisse](https://github.com/lmorisse)
* Renaming namespaces
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.8.0
This release contains refactoring and minor bug fixes

## 0.7.0
This release contains a new project example: [SymuScenariosAndEvents](https://github.com/lmorisse/Symu/tree/master/Symu%20examples/SymuScenariosAndEvents).

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#region Licence

// Description: Symu - SymuBeliefsAndInfluence
// Description: SymuBiz - SymuBeliefsAndInfluence
// Website: https://symu.org
// Copyright: (c) 2020 laurent morisseau
// License : the program is distributed under the terms of the GNU General Public License
Expand All @@ -14,10 +14,8 @@
using Symu.Classes.Agents;
using Symu.Classes.Agents.Models.CognitiveTemplates;
using Symu.Classes.Organization;
using Symu.Classes.Task;
using Symu.Common;
using Symu.Environment;
using Symu.Messaging.Messages;
using Symu.Repository.Networks.Knowledges;

#endregion
Expand All @@ -32,6 +30,7 @@ public class ExampleEnvironment : SymuEnvironment
public List<Knowledge> Knowledges { get; private set; }
public List<InfluencerAgent> Influencers { get; } = new List<InfluencerAgent>();
public PromoterTemplate InfluencerTemplate { get; } = new PromoterTemplate();

public SimpleHumanTemplate WorkerTemplate { get; } = new SimpleHumanTemplate();
//public MurphyTask Model { get; } = new MurphyTask();

Expand Down
11 changes: 7 additions & 4 deletions Symu examples/SymuBeliefsAndInfluence/Classes/InfluencerAgent.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#region Licence

// Description: Symu - SymuBeliefsAndInfluence
// Description: SymuBiz - SymuBeliefsAndInfluence
// Website: https://symu.org
// Copyright: (c) 2020 laurent morisseau
// License : the program is distributed under the terms of the GNU General Public License
Expand All @@ -26,13 +26,15 @@ namespace SymuBeliefsAndInfluence.Classes
public sealed class InfluencerAgent : Agent
{
public const byte ClassKey = SymuYellowPages.Actor;
public IEnumerable<Knowledge> Knowledges => ((ExampleEnvironment)Environment).Knowledges;

public InfluencerAgent(ushort agentKey, SymuEnvironment environment, CognitiveArchitectureTemplate template) : base(
public InfluencerAgent(ushort agentKey, SymuEnvironment environment,
CognitiveArchitectureTemplate template) : base(
new AgentId(agentKey, ClassKey), environment, template)
{
}

public IEnumerable<Knowledge> Knowledges => ((ExampleEnvironment) Environment).Knowledges;

/// <summary>
/// Customize the cognitive architecture of the agent
/// After setting the Agent template
Expand All @@ -56,7 +58,8 @@ protected override void SetModels()
base.SetModels();
foreach (var knowledge in Knowledges)
{
KnowledgeModel.AddKnowledge(knowledge.Id, KnowledgeLevel.FullKnowledge, Cognitive.InternalCharacteristics);
KnowledgeModel.AddKnowledge(knowledge.Id, KnowledgeLevel.FullKnowledge,
Cognitive.InternalCharacteristics);
BeliefsModel.AddBelief(knowledge.Id, Cognitive.KnowledgeAndBeliefs.DefaultBeliefLevel);
}
}
Expand Down
5 changes: 3 additions & 2 deletions Symu examples/SymuBeliefsAndInfluence/Classes/PersonAgent.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#region Licence

// Description: Symu - SymuBeliefsAndInfluence
// Description: SymuBiz - SymuBeliefsAndInfluence
// Website: https://symu.org
// Copyright: (c) 2020 laurent morisseau
// License : the program is distributed under the terms of the GNU General Public License
Expand Down Expand Up @@ -65,7 +65,8 @@ protected override void SetModels()
base.SetModels();
foreach (var knowledge in Knowledges)
{
KnowledgeModel.AddKnowledge(knowledge.Id, KnowledgeLevel.FullKnowledge, Cognitive.InternalCharacteristics);
KnowledgeModel.AddKnowledge(knowledge.Id, KnowledgeLevel.FullKnowledge,
Cognitive.InternalCharacteristics);
//Beliefs are added with knowledge based on DefaultBeliefLevel of the worker cognitive template
BeliefsModel.AddBelief(knowledge.Id, Cognitive.KnowledgeAndBeliefs.DefaultBeliefLevel);
}
Expand Down
70 changes: 41 additions & 29 deletions Symu examples/SymuBeliefsAndInfluence/Home.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#region Licence

// Description: Symu - SymuBeliefsAndInfluence
// Description: SymuBiz - SymuBeliefsAndInfluence
// Website: https://symu.org
// Copyright: (c) 2020 laurent morisseau
// License : the program is distributed under the terms of the GNU General Public License
Expand Down Expand Up @@ -42,17 +42,21 @@ private void LoadSettings()
DisplayButtons();

InfluenceModelOn.Checked = OrganizationEntity.Models.Influence.On;
InfluenceRateOfAgentsOn.Text = OrganizationEntity.Models.Influence.RateOfAgentsOn.ToString(CultureInfo.InvariantCulture);
InfluenceRateOfAgentsOn.Text =
OrganizationEntity.Models.Influence.RateOfAgentsOn.ToString(CultureInfo.InvariantCulture);

BeliefsModelOn.Checked = OrganizationEntity.Models.Beliefs.On;
BeliefsRateOfAgentsOn.Text = OrganizationEntity.Models.Beliefs.RateOfAgentsOn.ToString(CultureInfo.InvariantCulture);
BeliefsRateOfAgentsOn.Text =
OrganizationEntity.Models.Beliefs.RateOfAgentsOn.ToString(CultureInfo.InvariantCulture);

tbWorkers.Text = _environment.WorkersCount.ToString(CultureInfo.InvariantCulture);
tbInfluencers.Text = _environment.InfluencersCount.ToString(CultureInfo.InvariantCulture);
tbKnowledge.Text = _environment.KnowledgeCount.ToString(CultureInfo.InvariantCulture);

HasBeliefs.Checked = OrganizationEntity.Templates.Human.Cognitive.KnowledgeAndBeliefs.HasBelief;
ThresholdForReacting.Text = OrganizationEntity.Murphies.IncompleteBelief.ThresholdForReacting.ToString(CultureInfo.InvariantCulture);
ThresholdForReacting.Text =
OrganizationEntity.Murphies.IncompleteBelief.ThresholdForReacting
.ToString(CultureInfo.InvariantCulture);

#region Influencer

Expand All @@ -75,7 +79,8 @@ private void LoadSettings()

#region Worker

MandatoryRatio.Text = OrganizationEntity.Murphies.IncompleteBelief.MandatoryRatio.ToString(CultureInfo.InvariantCulture);
MandatoryRatio.Text =
OrganizationEntity.Murphies.IncompleteBelief.MandatoryRatio.ToString(CultureInfo.InvariantCulture);
RiskAversion.Text = _environment.WorkerTemplate.Cognitive.InternalCharacteristics.RiskAversionThreshold
.ToString(CultureInfo.InvariantCulture);
BeliefWeight.Items.AddRange(BeliefWeightLevelService.GetNames());
Expand Down Expand Up @@ -313,7 +318,8 @@ private void MinimumBeliefToSendPerBit_TextChanged(object sender, EventArgs e)
try
{
_environment.InfluencerTemplate.Cognitive.MessageContent
.MinimumBeliefToSendPerBit = float.Parse(MinimumBeliefToSendPerBit.Text, CultureInfo.InvariantCulture);
.MinimumBeliefToSendPerBit =
float.Parse(MinimumBeliefToSendPerBit.Text, CultureInfo.InvariantCulture);
MinimumBeliefToSendPerBit.BackColor = SystemColors.Window;
}
catch (FormatException)
Expand All @@ -332,7 +338,8 @@ private void MinimumNumberOfBitsOfBeliefToSend_TextChanged(object sender, EventA
try
{
_environment.InfluencerTemplate.Cognitive.MessageContent
.MinimumNumberOfBitsOfBeliefToSend = byte.Parse(MinimumNumberOfBitsOfBeliefToSend.Text, CultureInfo.InvariantCulture);
.MinimumNumberOfBitsOfBeliefToSend = byte.Parse(MinimumNumberOfBitsOfBeliefToSend.Text,
CultureInfo.InvariantCulture);
MinimumNumberOfBitsOfBeliefToSend.BackColor = SystemColors.Window;
}
catch (FormatException)
Expand All @@ -351,7 +358,8 @@ private void MaximumNumberOfBitsOfBeliefToSend_TextChanged(object sender, EventA
try
{
_environment.InfluencerTemplate.Cognitive.MessageContent
.MaximumNumberOfBitsOfBeliefToSend = byte.Parse(MaximumNumberOfBitsOfBeliefToSend.Text, CultureInfo.InvariantCulture);
.MaximumNumberOfBitsOfBeliefToSend = byte.Parse(MaximumNumberOfBitsOfBeliefToSend.Text,
CultureInfo.InvariantCulture);
MaximumNumberOfBitsOfBeliefToSend.BackColor = SystemColors.Window;
}
catch (FormatException)
Expand Down Expand Up @@ -387,7 +395,8 @@ private void MandatoryRatio_TextChanged(object sender, EventArgs e)
{
try
{
OrganizationEntity.Murphies.IncompleteBelief.MandatoryRatio = float.Parse(MandatoryRatio.Text, CultureInfo.InvariantCulture);
OrganizationEntity.Murphies.IncompleteBelief.MandatoryRatio =
float.Parse(MandatoryRatio.Text, CultureInfo.InvariantCulture);
MandatoryRatio.BackColor = SystemColors.Window;
}
catch (FormatException)
Expand All @@ -405,7 +414,8 @@ private void RateOfAgentsOn_TextChanged(object sender, EventArgs e)
{
try
{
OrganizationEntity.Models.Influence.RateOfAgentsOn = float.Parse(InfluenceRateOfAgentsOn.Text, CultureInfo.InvariantCulture);
OrganizationEntity.Models.Influence.RateOfAgentsOn =
float.Parse(InfluenceRateOfAgentsOn.Text, CultureInfo.InvariantCulture);
InfluenceRateOfAgentsOn.BackColor = SystemColors.Window;
}
catch (FormatException)
Expand Down Expand Up @@ -442,7 +452,8 @@ private void BeliefsRateOfAgentsOn_TextChanged(object sender, EventArgs e)
{
try
{
OrganizationEntity.Models.Beliefs.RateOfAgentsOn = float.Parse(BeliefsRateOfAgentsOn.Text, CultureInfo.InvariantCulture);
OrganizationEntity.Models.Beliefs.RateOfAgentsOn =
float.Parse(BeliefsRateOfAgentsOn.Text, CultureInfo.InvariantCulture);
BeliefsRateOfAgentsOn.BackColor = SystemColors.Window;
}
catch (FormatException)
Expand All @@ -456,6 +467,25 @@ private void BeliefsRateOfAgentsOn_TextChanged(object sender, EventArgs e)
}
}

private void textBox1_TextChanged(object sender, EventArgs e)
{
try
{
OrganizationEntity.Murphies.IncompleteBelief.ThresholdForReacting =
float.Parse(ThresholdForReacting.Text, CultureInfo.InvariantCulture);
ThresholdForReacting.BackColor = SystemColors.Window;
}
catch (FormatException)
{
ThresholdForReacting.BackColor = Color.Red;
}
catch (ArgumentOutOfRangeException exception)
{
ThresholdForReacting.BackColor = Color.Red;
MessageBox.Show(exception.Message);
}
}

#region Menu

private void symuorgToolStripMenuItem_Click(object sender, EventArgs e)
Expand All @@ -479,23 +509,5 @@ private void issuesToolStripMenuItem_Click(object sender, EventArgs e)
}

#endregion

private void textBox1_TextChanged(object sender, EventArgs e)
{
try
{
OrganizationEntity.Murphies.IncompleteBelief.ThresholdForReacting = float.Parse(ThresholdForReacting.Text, CultureInfo.InvariantCulture);
ThresholdForReacting.BackColor = SystemColors.Window;
}
catch (FormatException)
{
ThresholdForReacting.BackColor = Color.Red;
}
catch (ArgumentOutOfRangeException exception)
{
ThresholdForReacting.BackColor = Color.Red;
MessageBox.Show(exception.Message);
}
}
}
}
2 changes: 1 addition & 1 deletion Symu examples/SymuBeliefsAndInfluence/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#region Licence

// Description: Symu - SymuBeliefsAndInfluence
// Description: SymuBiz - SymuBeliefsAndInfluence
// Website: https://symu.org
// Copyright: (c) 2020 laurent morisseau
// License : the program is distributed under the terms of the GNU General Public License
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#region Licence

// Description: Symu - SymuBeliefsAndInfluence
// Description: SymuBiz - SymuBeliefsAndInfluence
// Website: https://symu.org
// Copyright: (c) 2020 laurent morisseau
// License : the program is distributed under the terms of the GNU General Public License
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataCopyTo="true">
<xsd:element name="root" msdata:IsDataClone="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
Expand Down
12 changes: 7 additions & 5 deletions Symu examples/SymuBeliefsAndInfluenceTests/IntegrationTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#region Licence

// Description: Symu - SymuBeliefsAndInfluenceTests
// Description: SymuBiz - SymuBeliefsAndInfluenceTests
// Website: https://symu.org
// Copyright: (c) 2020 laurent morisseau
// License : the program is distributed under the terms of the GNU General Public License
Expand All @@ -13,7 +13,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Symu.Classes.Organization;
using Symu.Classes.Scenario;
using Symu.Common;
using Symu.Engine;
using Symu.Repository.Networks.Beliefs;
using Symu.Tools;
Expand Down Expand Up @@ -248,8 +247,9 @@ public void NoWeightTest()
(_environment.Schedule.Step * _environment.WorkersCount);
Assert.AreEqual(100, tasksDoneRatio);
}

/// <summary>
/// Full risk aversion
/// Full risk aversion
/// </summary>
[TestMethod]
public void FullWeightTest()
Expand All @@ -266,10 +266,12 @@ public void FullWeightTest()
: _environment.IterationResult.Tasks.Done * 100 /
(_environment.Schedule.Step * _environment.WorkersCount);
Assert.AreEqual(0, tasksDoneRatio);
Assert.AreEqual(_environment.Schedule.Step * _environment.WorkersCount, _environment.IterationResult.Tasks.Cancelled);
Assert.AreEqual(_environment.Schedule.Step * _environment.WorkersCount,
_environment.IterationResult.Tasks.Cancelled);
}

/// <summary>
/// No risk aversion
/// No risk aversion
/// </summary>
[TestMethod]
public void FullWeightTest1()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#region Licence

// Description: Symu - SymuGroupAndInteraction
// Description: SymuBiz - SymuGroupAndInteraction
// Website: https://symu.org
// Copyright: (c) 2020 laurent morisseau
// License : the program is distributed under the terms of the GNU General Public License
Expand Down Expand Up @@ -29,7 +29,7 @@ public class ExampleEnvironment : SymuEnvironment
public byte Knowledge { get; set; } = 0;
public byte Activities { get; set; } = 0;
public KnowledgeLevel KnowledgeLevel { get; set; } = KnowledgeLevel.FullKnowledge;
public List<Knowledge> Knowledges { get; }= new List<Knowledge>();
public List<Knowledge> Knowledges { get; } = new List<Knowledge>();

public override void SetOrganization(OrganizationEntity organization)
{
Expand Down Expand Up @@ -65,7 +65,7 @@ public override void SetAgents()
for (var i = 0; i < GroupsCount; i++)
{
var group = new GroupAgent(Organization.NextEntityIndex(), this);

for (var j = 0; j < WorkersCount; j++)
{
var actor = new PersonAgent(Organization.NextEntityIndex(), this, Organization.Templates.Human)
Expand All @@ -86,16 +86,19 @@ private void SetKnowledge(Agent actor, IReadOnlyList<Knowledge> knowledges, int
{
case 0:
// same Knowledge for all
WhitePages.Network.NetworkKnowledges.Add(actor.Id, knowledges[0].Id, KnowledgeLevel, actor.Cognitive.InternalCharacteristics);
WhitePages.Network.NetworkKnowledges.Add(actor.Id, knowledges[0].Id, KnowledgeLevel,
actor.Cognitive.InternalCharacteristics);
break;
case 1:
// Knowledge is by group
WhitePages.Network.NetworkKnowledges.Add(actor.Id, knowledges[i].Id, KnowledgeLevel, actor.Cognitive.InternalCharacteristics);
WhitePages.Network.NetworkKnowledges.Add(actor.Id, knowledges[i].Id, KnowledgeLevel,
actor.Cognitive.InternalCharacteristics);
break;
case 2:
// Knowledge is randomly defined for agentId
var index = DiscreteUniform.Sample(0, GroupsCount - 1);
WhitePages.Network.NetworkKnowledges.Add(actor.Id, knowledges[index].Id, KnowledgeLevel, actor.Cognitive.InternalCharacteristics);
WhitePages.Network.NetworkKnowledges.Add(actor.Id, knowledges[index].Id, KnowledgeLevel,
actor.Cognitive.InternalCharacteristics);
break;
}
}
Expand Down
3 changes: 1 addition & 2 deletions Symu examples/SymuGroupAndInteraction/Classes/GroupAgent.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#region Licence

// Description: Symu - SymuGroupAndInteraction
// Description: SymuBiz - SymuGroupAndInteraction
// Website: https://symu.org
// Copyright: (c) 2020 laurent morisseau
// License : the program is distributed under the terms of the GNU General Public License
Expand All @@ -10,7 +10,6 @@
#region using directives

using Symu.Classes.Agents;
using Symu.Classes.Agents.Models.CognitiveTemplates;
using Symu.Environment;

#endregion
Expand Down

0 comments on commit 1c88a5e

Please sign in to comment.