Skip to content

Commit

Permalink
Clean code for V0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lmorisse committed Jun 1, 2020
1 parent 61ea6d8 commit 843cc63
Show file tree
Hide file tree
Showing 40 changed files with 356 additions and 191 deletions.
15 changes: 8 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

## Unreleased

## 0.7.0 [](https://github.com/lmorisse/symu/compare/v0.7.0..v0.6.0)
* Renaming namespaces by [lmorisse](https://github.com/lmorisse)
* Update SymuForm, IterationResult for multiple iterations by [lmorisse](https://github.com/lmorisse)
* Add new project example: [SymuScenariosAndMonteCarlo](https://github.com/lmorisse/Symu/tree/master/Symu%20examples/SymuScenariosAndMonteCarlo) by [lmorisse](https://github.com/lmorisse)
* Add new project example: [SymuScenariosAndMonteCarloTests](https://github.com/lmorisse/Symu/tree/master/Symu%20examples/SymuScenariosAndMonteCarloTests) by [lmorisse](https://github.com/lmorisse)
* Add new project example: [SymuScenariosAndEvents](https://github.com/lmorisse/Symu/tree/master/Symu%20examples/SymuScenariosAndEvents) by [lmorisse](https://github.com/lmorisse)
* Add new project test: [SymuScenariosAndEventsTests](https://github.com/lmorisse/Symu/tree/master/Symu%20examples/SymuScenariosAndEventsTests) by [lmorisse](https://github.com/lmorisse)


## 0.6.0 [](https://github.com/lmorisse/symu/compare/v0.6.0..v0.5.0)
Expand All @@ -14,26 +15,26 @@
* Refactoring Murphies by [lmorisse](https://github.com/lmorisse)
* Add Agent.TimeSpent by [lmorisse](https://github.com/lmorisse)
* Add new project example: [SymuMurphiesAndBlockers](https://github.com/lmorisse/Symu/tree/master/Symu%20examples/SymuMurphiesAndBlockers) by [lmorisse](https://github.com/lmorisse)
* Add new project example: [SymuMurphiesAndBlockersTests](https://github.com/lmorisse/Symu/tree/master/Symu%20examples/SymuMurphiesAndBlockersTests) by [lmorisse](https://github.com/lmorisse)
* Add new project test: [SymuMurphiesAndBlockersTests](https://github.com/lmorisse/Symu/tree/master/Symu%20examples/SymuMurphiesAndBlockersTests) by [lmorisse](https://github.com/lmorisse)

## 0.5.0 [](https://github.com/lmorisse/symu/compare/v0.5.0..v0.4.0)
* Add new models : knowledge, Beliefs, Influence by [lmorisse](https://github.com/lmorisse)
* Add SymuTask.SetKnowledgesBits by [lmorisse](https://github.com/lmorisse)
* Refactoring NetworkBeliefs by [lmorisse](https://github.com/lmorisse)
* Add new project example: [SymuGroupAndInteraction](https://github.com/lmorisse/Symu/tree/master/Symu%20examples/SymuBeliefsAndInfluence) by [lmorisse](https://github.com/lmorisse)
* Add new project example: [SymuGroupAndInteractionTests](https://github.com/lmorisse/Symu/tree/master/Symu%20examples/SymuBeliefsAndInfluenceTests) by [lmorisse](https://github.com/lmorisse)
* Add new project test: [SymuGroupAndInteractionTests](https://github.com/lmorisse/Symu/tree/master/Symu%20examples/SymuBeliefsAndInfluenceTests) by [lmorisse](https://github.com/lmorisse)

## 0.4.0 [](https://github.com/lmorisse/symu/compare/v0.4.0..v0.3.0)
* Add new project example: [SymuGroupAndInteraction](https://github.com/lmorisse/Symu/tree/master/Symu%20examples/SymuGroupAndInteraction) by [lmorisse](https://github.com/lmorisse)
* Add new project example: [SymuGroupAndInteractionTests](https://github.com/lmorisse/Symu/tree/master/Symu%20examples/SymuGroupAndInteractionTests) by [lmorisse](https://github.com/lmorisse)
* Add new project test: [SymuGroupAndInteractionTests](https://github.com/lmorisse/Symu/tree/master/Symu%20examples/SymuGroupAndInteractionTests) by [lmorisse](https://github.com/lmorisse)
* SymuEngine - add InteractionSphereModel by [lmorisse](https://github.com/lmorisse)
* SymuEngine - update InteractionPatterns by [lmorisse](https://github.com/lmorisse)

## 0.3.0 [](https://github.com/lmorisse/symu/compare/v0.3.0..v0.2.0)
* Add new project example: [SymuMessageAndTask](https://github.com/lmorisse/Symu/tree/master/Symu%20examples/SymuMessageAndTask) by [lmorisse](https://github.com/lmorisse)
* Add new project example: [SymuMessageAndTaskTest](https://github.com/lmorisse/Symu/tree/master/Symu%20examples/SymuMessageAndTaskTests) by [lmorisse](https://github.com/lmorisse)
* Add new project test: [SymuMessageAndTaskTest](https://github.com/lmorisse/Symu/tree/master/Symu%20examples/SymuMessageAndTaskTests) by [lmorisse](https://github.com/lmorisse)
* SymuEngine - delete EnvironmentEntity => OrganizationModels by [lmorisse](https://github.com/lmorisse)

## 0.2.0 [](https://github.com/lmorisse/symu/compare/v0.2.0..v0.1.0)
* Add new project example: [SymuLearnAndForget](https://github.com/lmorisse/Symu/tree/master/Symu%20examples/SymuLearnAndForget) by [lmorisse](https://github.com/lmorisse)
* Add new project example: [SymuLearnAndForgetTest](https://github.com/lmorisse/Symu/tree/master/Symu%20examples/SymuLearnAndForgetTests) by [lmorisse](https://github.com/lmorisse)
* Add new project test: [SymuLearnAndForgetTest](https://github.com/lmorisse/Symu/tree/master/Symu%20examples/SymuLearnAndForgetTests) by [lmorisse](https://github.com/lmorisse)
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.7.0
This release contains a new project example: [SymuScenariosAndEvents](https://github.com/lmorisse/Symu/tree/master/Symu%20examples/SymuScenariosAndEvents).

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

Expand Down
4 changes: 3 additions & 1 deletion Symu examples/SymuBeliefsAndInfluence/Home.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
using System.Linq;
using System.Windows.Forms;
using Symu.Classes.Scenario;
using Symu.Common;
using Symu.Environment;
using Symu.Forms;
using Symu.Repository.Networks.Beliefs;
Expand Down Expand Up @@ -454,7 +453,9 @@ private void BeliefsRateOfAgentsOn_TextChanged(object sender, EventArgs e)
MessageBox.Show(exception.Message);
}
}

#region Menu

private void symuorgToolStripMenuItem_Click(object sender, EventArgs e)
{
Process.Start("https://symu.org");
Expand All @@ -474,6 +475,7 @@ private void issuesToolStripMenuItem_Click(object sender, EventArgs e)
{
Process.Start("http://github.symu.org/issues");
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
using Symu.Classes.Scenario;
using Symu.Engine;
using Symu.Repository.Networks.Beliefs;
using SymuBeliefsAndInfluence.Classes;
using Symu.Tools;
using SymuBeliefsAndInfluence.Classes;

#endregion

Expand Down
22 changes: 16 additions & 6 deletions Symu examples/SymuExamples.sln
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SymuMurphiesAndBlockers", "
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SymuMurphiesAndBlockersTests", "SymuMurphiesAndBlockersTests\SymuMurphiesAndBlockersTests.csproj", "{979382EC-EC34-4284-9E6A-018A40CA82F1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SymuScenariosAndMonteCarlo", "SymuScenariosAndMonteCarlo\SymuScenariosAndMonteCarlo.csproj", "{5E1F9690-2B9C-4354-9AD7-9D9CD873965B}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SymuScenariosAndEvents", "SymuScenariosAndEvents\SymuScenariosAndEvents.csproj", "{5E1F9690-2B9C-4354-9AD7-9D9CD873965B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SymuScenariosAndMonteCarloTests", "SymuScenariosAndMonteCarloTests\SymuScenariosAndMonteCarloTests.csproj", "{35B38D26-104A-45AC-A13B-EAD8F4CC088A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SymuScenariosAndEventsTests", "SymuScenariosAndEventsTests\SymuScenariosAndEventsTests.csproj", "{1117A229-1A21-477D-A580-AAB984884F92}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests projects", "Tests projects", "{CDF38E4B-8B2A-4110-8404-3DB5F276940D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -77,14 +79,22 @@ Global
{5E1F9690-2B9C-4354-9AD7-9D9CD873965B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5E1F9690-2B9C-4354-9AD7-9D9CD873965B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5E1F9690-2B9C-4354-9AD7-9D9CD873965B}.Release|Any CPU.Build.0 = Release|Any CPU
{35B38D26-104A-45AC-A13B-EAD8F4CC088A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{35B38D26-104A-45AC-A13B-EAD8F4CC088A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{35B38D26-104A-45AC-A13B-EAD8F4CC088A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{35B38D26-104A-45AC-A13B-EAD8F4CC088A}.Release|Any CPU.Build.0 = Release|Any CPU
{1117A229-1A21-477D-A580-AAB984884F92}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1117A229-1A21-477D-A580-AAB984884F92}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1117A229-1A21-477D-A580-AAB984884F92}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1117A229-1A21-477D-A580-AAB984884F92}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{03DD3D3E-58EA-47C9-8AE3-B35D0E3DE5DB} = {CDF38E4B-8B2A-4110-8404-3DB5F276940D}
{4A229EF5-31C6-4B55-902A-9FAFDE901595} = {CDF38E4B-8B2A-4110-8404-3DB5F276940D}
{CBAC9A57-6A83-4F7B-8254-BE452BDE5468} = {CDF38E4B-8B2A-4110-8404-3DB5F276940D}
{49C4CE6F-AA8D-46D0-AB88-C3E3D754606A} = {CDF38E4B-8B2A-4110-8404-3DB5F276940D}
{979382EC-EC34-4284-9E6A-018A40CA82F1} = {CDF38E4B-8B2A-4110-8404-3DB5F276940D}
{1117A229-1A21-477D-A580-AAB984884F92} = {CDF38E4B-8B2A-4110-8404-3DB5F276940D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F00944D1-83EF-4E6C-BDD2-784EC80CE225}
EndGlobalSection
Expand Down
4 changes: 3 additions & 1 deletion Symu examples/SymuGroupAndInteraction/Home.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
using System.Windows.Forms;
using Symu.Classes.Agents.Models.CognitiveModel;
using Symu.Classes.Scenario;
using Symu.Common;
using Symu.Environment;
using Symu.Forms;
using Symu.Repository.Networks.Knowledges;
Expand Down Expand Up @@ -489,7 +488,9 @@ private void Homophily_CheckedChanged(object sender, EventArgs e)
InteractionKnowledge.Text = "0";
InteractionSocialDemographics.Text = "0";
}

#region Menu

private void symuorgToolStripMenuItem_Click(object sender, EventArgs e)
{
Process.Start("https://symu.org");
Expand All @@ -509,6 +510,7 @@ private void issuesToolStripMenuItem_Click(object sender, EventArgs e)
{
Process.Start("http://github.symu.org/issues");
}

#endregion
}
}
3 changes: 2 additions & 1 deletion Symu examples/SymuLearnAndForget/Home.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ private void button3_Click(object sender, EventArgs e)

private void DisplayButtons()
{

DisplayButtons(btnStart, btnStop, btnPause, btnResume);
}

Expand Down Expand Up @@ -618,6 +617,7 @@ private void tbSteps_TextChanged(object sender, EventArgs e)
}

#region Menu

private void symuorgToolStripMenuItem_Click(object sender, EventArgs e)
{
Process.Start("https://symu.org");
Expand All @@ -637,6 +637,7 @@ private void issuesToolStripMenuItem_Click(object sender, EventArgs e)
{
Process.Start("http://github.symu.org/issues");
}

#endregion
}
}
3 changes: 2 additions & 1 deletion Symu examples/SymuMessageAndTask/Home.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ private void button3_Click(object sender, EventArgs e)

private void DisplayButtons()
{

DisplayButtons(btnStart, btnStop, btnPause, btnResume);
}

Expand Down Expand Up @@ -391,6 +390,7 @@ private void tbWorkers_TextChanged(object sender, EventArgs e)


#region Menu

private void symuorgToolStripMenuItem_Click(object sender, EventArgs e)
{
Process.Start("https://symu.org");
Expand All @@ -410,6 +410,7 @@ private void issuesToolStripMenuItem_Click(object sender, EventArgs e)
{
Process.Start("http://github.symu.org/issues");
}

#endregion
}
}
6 changes: 4 additions & 2 deletions Symu examples/SymuMurphiesAndBlockers/Home.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using System.Globalization;
using System.Windows.Forms;
using Symu.Classes.Scenario;
using Symu.Common;
using Symu.Environment;
using Symu.Forms;
using Symu.Messaging.Messages;
Expand Down Expand Up @@ -182,7 +181,8 @@ protected override void UpdateSettings()

OrganizationEntity.Models.Learning.On = EmailSearching.Checked;

OrganizationEntity.Templates.Human.Cognitive.InteractionCharacteristics.PreferredCommunicationMediums = EmailComm.Checked ? CommunicationMediums.Email : CommunicationMediums.FaceToFace;
OrganizationEntity.Templates.Human.Cognitive.InteractionCharacteristics.PreferredCommunicationMediums =
EmailComm.Checked ? CommunicationMediums.Email : CommunicationMediums.FaceToFace;


var scenario = new TimeBasedScenario(_environment)
Expand Down Expand Up @@ -810,6 +810,7 @@ private void InformationLimitOfTries_CheckedChanged(object sender, EventArgs e)
}

#region Menu

private void symuorgToolStripMenuItem_Click(object sender, EventArgs e)
{
Process.Start("https://symu.org");
Expand All @@ -829,6 +830,7 @@ private void issuesToolStripMenuItem_Click(object sender, EventArgs e)
{
Process.Start("http://github.symu.org/issues");
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
using Symu.Messaging.Messages;
using Symu.Repository.Networks.Beliefs;
using Symu.Repository.Networks.Knowledges;
using SymuMurphiesAndBlockers.Classes;
using Symu.Tools;
using SymuMurphiesAndBlockers.Classes;

#endregion

Expand Down
29 changes: 18 additions & 11 deletions Symu examples/SymuScenariosAndEvents/ChartAppearance.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
#region Copyright Syncfusion Inc. 2001-2020.
// Copyright Syncfusion Inc. 2001-2020. All rights reserved.
// Use of this code is subject to the terms of our license.
// A copy of the current license can be obtained at any time by e-mailing
// licensing@syncfusion.com. Any infringement will be prosecuted under
// applicable laws.
#region Licence

// Description: Symu - SymuScenariosAndEvents
// Website: https://symu.org
// Copyright: (c) 2020 laurent morisseau
// License : the program is distributed under the terms of the GNU General Public License

#endregion

#region using directives

using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using Syncfusion.Windows.Forms.Chart;

#endregion

namespace SymuScenariosAndEvents
{
public static class ChartAppearance
Expand All @@ -26,7 +32,7 @@ public static void ApplyChartStyles(ChartControl chart)
chart.Skins = Skins.Metro;
chart.BorderAppearance.SkinStyle = ChartBorderSkinStyle.None;
chart.BorderAppearance.FrameThickness = new ChartThickness(-2, -2, 2, 2);
chart.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
chart.SmoothingMode = SmoothingMode.AntiAlias;
chart.ChartArea.PrimaryXAxis.HidePartialLabels = true;
chart.ElementsSpacing = 5;

Expand All @@ -40,6 +46,7 @@ public static void ApplyChartStyles(ChartControl chart)
{
return;
}

var max = chart.Series[0].Points[0].YValues[0];
for (var i = 0; i < chart.Series.Count; i++)
{
Expand All @@ -48,6 +55,7 @@ public static void ApplyChartStyles(ChartControl chart)
max = Math.Max(max, chart.Series[i].Points[j].YValues[0]);
}
}

chart.PrimaryYAxis.Range = new MinMaxInfo(0, max + 1, Math.Round(max / 10));
var min = chart.Series[0].Points[0].X;
max = min;
Expand All @@ -59,16 +67,15 @@ public static void ApplyChartStyles(ChartControl chart)
max = Math.Max(max, chart.Series[i].Points[j].X);
}
}
chart.PrimaryXAxis.Range = new MinMaxInfo(min-10, max+10, Math.Round((max-min)/10));

chart.PrimaryXAxis.Range = new MinMaxInfo(min - 10, max + 10, Math.Round((max - min) / 10));

chart.PrimaryXAxis.LabelRotate = true;
chart.PrimaryXAxis.LabelRotateAngle = 270;

chart.Series[0].Style.Border.Color = Color.Transparent;

#endregion


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

// Description: Symu - SymuMurphiesAndBlockers
// Description: Symu - SymuScenariosAndEvents
// 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 @@ -11,15 +11,12 @@

using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Symu.Classes.Agents;
using Symu.Classes.Agents.Models.Templates.Communication;
using Symu.Classes.Organization;
using Symu.Classes.Task;
using Symu.Common;
using Symu.Environment;
using Symu.Environment.Events;
using Symu.Messaging.Messages;
using Symu.Repository.Networks.Knowledges;

#endregion
Expand All @@ -34,7 +31,7 @@ public class ExampleEnvironment : SymuEnvironment

public List<Knowledge> Knowledges { get; private set; }
public MurphyTask Model => Organization.Murphies.IncompleteKnowledge;

public override void SetOrganization(OrganizationEntity organization)
{
if (organization == null)
Expand All @@ -45,6 +42,7 @@ public override void SetOrganization(OrganizationEntity organization)
base.SetOrganization(organization);

#region Template

organization.Templates.Human.Cognitive.KnowledgeAndBeliefs.HasKnowledge = true;
organization.Templates.Human.Cognitive.KnowledgeAndBeliefs.HasInitialKnowledge = true;
organization.Templates.Human.Cognitive.KnowledgeAndBeliefs.HasBelief = true;
Expand All @@ -56,11 +54,14 @@ public override void SetOrganization(OrganizationEntity organization)
organization.Templates.Human.Cognitive.InteractionPatterns.IsolationIsRandom = false;
organization.Templates.Human.Cognitive.InteractionPatterns.AgentCanBeIsolated = Frequency.Never;
organization.Templates.Human.Cognitive.InteractionPatterns.AllowNewInteractions = true;

#endregion

#region Results

IterationResult.Blockers.On = true;
IterationResult.Tasks.On = true;

#endregion

SetDebug(false);
Expand Down Expand Up @@ -99,6 +100,7 @@ private void SetKnowledge(Agent actor, IReadOnlyList<Knowledge> knowledges)
actor.BeliefsModel.AddBelief(knowledges[i].Id);
}
}

private PersonAgent AddPersonAgent()
{
var actor = new PersonAgent(Organization.NextEntityIndex(), this)
Expand Down
Loading

0 comments on commit 843cc63

Please sign in to comment.