Skip to content

Commit

Permalink
Update SymuBeliefsAndInfluence
Browse files Browse the repository at this point in the history
  • Loading branch information
lmorisse committed May 17, 2020
1 parent 5c86911 commit 04a8d69
Show file tree
Hide file tree
Showing 26 changed files with 272 additions and 96 deletions.
129 changes: 76 additions & 53 deletions Symu examples/SymuBeliefsAndInfluence/Home.Designer.cs

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

4 changes: 4 additions & 0 deletions Symu examples/SymuBeliefsAndInfluence/Home.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using SymuBeliefsAndInfluence.Classes;
using SymuEngine.Classes.Scenario;
Expand Down Expand Up @@ -64,6 +65,8 @@ private void LoadSettings()
InfluencerBeliefLevel.Items.AddRange(BeliefLevelService.GetNames());
InfluencerBeliefLevel.SelectedItem = BeliefLevelService.GetName(OrganizationEntity.Templates.Human.Cognitive.KnowledgeAndBeliefs.DefaultBeliefLevel);
MandatoryRatio.Text = _environment.Model.MandatoryRatio.ToString();
BeliefWeight.Items.AddRange(BeliefWeightLevelService.GetNames());
BeliefWeight.SelectedItem = BeliefWeightLevelService.GetName(OrganizationEntity.Models.ImpactOfBeliefOnTask);
}

protected override void SetUpOrganization()
Expand Down Expand Up @@ -98,6 +101,7 @@ private void Button1_Click(object sender, EventArgs e)
_environment.WorkerTemplate.Cognitive.KnowledgeAndBeliefs.HasBelief = HasBeliefs.Checked;
_environment.WorkerTemplate.Cognitive.KnowledgeAndBeliefs.HasInitialBelief = HasInitialBeliefs.Checked;
_environment.WorkerTemplate.Cognitive.MessageContent.CanReceiveBeliefs = CanReceiveBeliefs.Checked;
OrganizationEntity.Models.ImpactOfBeliefOnTask = BeliefWeightLevelService.GetValue(BeliefWeight.SelectedItem.ToString());
#endregion

Start(_environment);
Expand Down
28 changes: 28 additions & 0 deletions Symu examples/SymuBeliefsAndInfluenceTests/IntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,34 @@ public void NoTaskBlockedTest()
(_environment.TimeStep.Step * _environment.WorkersCount);
Assert.AreEqual(100, tasksDoneRatio);
}

[TestMethod]
public void NoWeightTest()
{
_environment.Model.MandatoryRatio = 1;
_environment.WhitePages.Network.NetworkBeliefs.BeliefWeightLevel = BeliefWeightLevel.NoWeight;
_simulation.Process();
CheckNoChange();
var tasksDoneRatio = _environment.TimeStep.Step * _environment.WorkersCount < Constants.Tolerance
? 0
: _environment.IterationResult.Tasks.Total * 100 /
(_environment.TimeStep.Step * _environment.WorkersCount);
Assert.AreEqual(100, tasksDoneRatio);
}

[TestMethod]
public void FullWeightTest()
{
_environment.Model.MandatoryRatio = 1;
_environment.WhitePages.Network.NetworkBeliefs.BeliefWeightLevel = BeliefWeightLevel.FullWeight;
_simulation.Process();
CheckNoChange();
var tasksDoneRatio = _environment.TimeStep.Step * _environment.WorkersCount < Constants.Tolerance
? 0
: _environment.IterationResult.Tasks.Total * 100 /
(_environment.TimeStep.Step * _environment.WorkersCount);
Assert.AreNotEqual(100, tasksDoneRatio);
}
/// <summary>
/// Influencers strongly disagree
/// Belief should decrease
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using SymuEngine.Common;
using SymuEngine.Repository.Networks;
using SymuEngine.Repository.Networks.Activities;
using SymuEngine.Repository.Networks.Beliefs;
using SymuEngine.Repository.Networks.Knowledges;
using SymuTools.Math.ProbabilityDistributions;
using static SymuTools.Constants;
Expand Down Expand Up @@ -74,7 +75,6 @@ public void CopyTo(TasksAndPerformance tasksAndPerformance)
TasksLimit.CopyTo(tasksAndPerformance.TasksLimit);
}


#region Agent Learning

public ModelEntity LearningModel { get; set; } = new ModelEntity();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using SymuEngine.Classes.Agents.Models;
using SymuEngine.Common;
using SymuEngine.Engine;
using SymuEngine.Repository.Networks.Beliefs;

#endregion

Expand Down Expand Up @@ -62,6 +63,10 @@ public class OrganizationModels
/// Agent knowledge forgetting model
/// </summary>
public ModelEntity Forgetting { get; set; } = new ModelEntity();
/// <summary>
/// Impact level of agent's belief on how agent will accept to do the task
/// </summary>
public BeliefWeightLevel ImpactOfBeliefOnTask { get; set; } = BeliefWeightLevel.RandomWeight;

public InteractionSphereModel InteractionSphere { get; set; } = new InteractionSphereModel();

Expand Down Expand Up @@ -115,6 +120,7 @@ public void CopyTo(OrganizationModels entity)
entity.FollowGroupKnowledge = FollowGroupKnowledge;
entity.MultipleBlockers = MultipleBlockers;
entity.Generator = Generator;
entity.ImpactOfBeliefOnTask = ImpactOfBeliefOnTask;
}
}
}
2 changes: 1 addition & 1 deletion Symu source code/SymuEngine/Environment/SymuEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected SymuEnvironment()
public void SetOrganization(OrganizationEntity organization)
{
Organization = organization ?? throw new ArgumentNullException(nameof(organization));
WhitePages = new WhitePages(Organization.Templates, Organization.Models.InteractionSphere);
WhitePages = new WhitePages(Organization.Templates, Organization.Models);
}

/// <summary>
Expand Down

0 comments on commit 04a8d69

Please sign in to comment.