Skip to content

Commit b91cd50

Browse files
committed
Merge branch 'release/3.1.2'
2 parents a3e29ab + 6e2da87 commit b91cd50

40 files changed

+525
-200
lines changed

.github/CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
## How to contribute to GeneticSharp
2+
The idea behind GeneticSharp is to provide the basic and classic components that allow any programmer to quickly create a genetic algorithm using the .NET platform. Therefore, most of the basics and classic operators (crossovers, mutations, selections, reinsertions, and terminations) are implemented on it.
3+
4+
Having said that is not the goal of GeneticSharp to implement or provide all the possible ways to use a genetic algorithm, so, any PR that is not related to new operators, performance improvements, or bug fixing has a great chance to be rejected, but, feel free to read the contributing guidelines below and give a try.
25

36
### Did you find a bug?
47

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Steps to reproduce the behavior:
1313
**Expected behavior**
1414
A clear and concise description of what you expected to happen.
1515

16+
**Sample code**
17+
Provide a sample code exposing the bug.
18+
1619
**Screenshots**
1720
If applicable, add screenshots to help explain your problem.
1821

.github/ISSUE_TEMPLATE/question.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ Did you search for your answer at GeneticSharp's Stack Overflow [tag](https://st
1212

1313
**Ask a question**
1414
If you did not find your answer at wiki and Stack Overflow tag, please, describe your question.
15+
16+
** Sample code **
17+
Provide a sample code of what you have tried so far.

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: 3.0.{build}
1+
version: 3.1.2.{build}
22
os: Visual Studio 2022
33
configuration: Release
44
environment:

buildLibrariesNuget.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SET PACKAGE_VERSION="3.0.0"
1+
SET PACKAGE_VERSION="3.1.2"
22

33
mkdir .\src\nuget
44

buildTemplatesNuget.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SET PACKAGE_VERSION=3.0.0
1+
SET PACKAGE_VERSION=3.1.2
22

33
cd .\src\Templates
44

src/GeneticSharp.Benchmarks/RandomizationsBenchmark.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using BenchmarkDotNet.Attributes;
2+
using System.Threading.Tasks;
23

34
namespace GeneticSharp.Benchmarks
45
{
@@ -53,6 +54,15 @@ public void Basic_GetUniqueInts()
5354
{
5455
_basic.GetUniqueInts(_arrayLength, _min, _max);
5556
}
57+
58+
[Benchmark]
59+
public void Basic_GetInt_Threads()
60+
{
61+
Parallel.For(0, 100, i =>
62+
{
63+
_basic.GetInt(_min, _max);
64+
});
65+
}
5666
#endregion
5767

5868
#region FastRandom
@@ -97,6 +107,15 @@ public void FastRandom_GetUniqueInts()
97107
{
98108
_fastRandom.GetUniqueInts(_arrayLength, _min, _max);
99109
}
110+
111+
[Benchmark]
112+
public void FastRandom_GetInt_Threads()
113+
{
114+
Parallel.For(0, 100, i =>
115+
{
116+
_fastRandom.GetInt(_min, _max);
117+
});
118+
}
100119
#endregion
101120
}
102121
}

src/GeneticSharp.Benchmarks/SelectionsBenchmark.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,21 @@ public ISelection Tournament()
5454
target.SelectChromosomes(_chromosomesNumber, _generation);
5555
return target;
5656
}
57+
58+
[Benchmark]
59+
public ISelection Rank()
60+
{
61+
var target = new RankSelection();
62+
target.SelectChromosomes(_chromosomesNumber, _generation);
63+
return target;
64+
}
65+
66+
[Benchmark]
67+
public ISelection Truncation()
68+
{
69+
var target = new TruncationSelection();
70+
target.SelectChromosomes(_chromosomesNumber, _generation);
71+
return target;
72+
}
5773
}
5874
}

src/GeneticSharp.Domain.UnitTests/Chromosomes/ChromosomeBaseTest.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -125,22 +125,6 @@ public void ReplaceGenes_NullGenes_Exception()
125125
});
126126
}
127127

128-
[Test]
129-
public void ReplaceGenes_GenesExceedChromosomeLength_Exception()
130-
{
131-
var target = Substitute.For<ChromosomeBase>(3);
132-
133-
Assert.Catch<ArgumentException>(() =>
134-
{
135-
target.ReplaceGenes(0, new Gene[] { new Gene(1), new Gene(2), new Gene(3), new Gene(4) });
136-
}, "The number of genes to be replaced is greater than available space, there is 3 genes between the index 0 and the end of chromosome, but there is 4 genes to be replaced.");
137-
138-
Assert.Catch<ArgumentException>(() =>
139-
{
140-
target.ReplaceGenes(1, new Gene[] { new Gene(1), new Gene(2), new Gene(3) });
141-
}, "The number of genes to be replaced is greater than available space, there is 2 genes between the index 1 and the end of chromosome, but there is 3 genes to be replaced.");
142-
}
143-
144128
[Test]
145129
public void ReplaceGenes_ValidIndex_Replaced()
146130
{

src/GeneticSharp.Domain.UnitTests/FlowAssert.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public static void IsAtLeastOneOk(params Action[] flows)
4949
public static void IsAtLeastOneAttemptOk(int maxAttempts, Action flow)
5050
{
5151
bool ok = false;
52+
string failedMessage = null;
5253

5354
for(int i = 0; i < maxAttempts; i++)
5455
{
@@ -63,10 +64,11 @@ public static void IsAtLeastOneAttemptOk(int maxAttempts, Action flow)
6364
Debug.WriteLine(ex.Message);
6465
Debug.WriteLine(ex.StackTrace);
6566
ok = false;
67+
failedMessage = ex.Message;
6668
}
6769
}
6870

69-
Assert.IsTrue(ok);
71+
Assert.IsTrue(ok, $"All {maxAttempts} attempts failed\n\n{failedMessage}");
7072
}
7173
}
7274
}

0 commit comments

Comments
 (0)