Skip to content

Commit 362508f

Browse files
committed
Merge branch 'release/2.6.0'
2 parents 2a9847f + c31103a commit 362508f

File tree

141 files changed

+6527
-51
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+6527
-51
lines changed

README.md

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
21
![](docs/logo/logo-small.png)
32

4-
53
[![Build status](https://ci.appveyor.com/api/projects/status/h9ptxpyj30ah3mva/branch/master?svg=true)](https://ci.appveyor.com/project/giacomelli/geneticsharp)
64
[![Quality status](https://sonarcloud.io/api/project_badges/measure?project=GeneticSharp&metric=alert_status)](https://sonarcloud.io/dashboard?id=GeneticSharp)
75
[![Coverage Status](https://sonarcloud.io/api/project_badges/measure?project=GeneticSharp&metric=coverage)](https://sonarcloud.io/dashboard?id=GeneticSharp)
@@ -12,31 +10,36 @@
1210

1311
GeneticSharp is a fast, extensible, multi-platform and multithreading C# Genetic Algorithm library that simplifies the development of applications using Genetic Algorithms (GAs).
1412

15-
Can be used in any kind of .NET Core and .NET Framework apps, like ASP .NET MVC, ASP .NET Core, Web Forms, UWP, Windows Forms, GTK#, Xamarin and Unity3D games.
13+
Can be used in any kind of .NET Core and .NET Framework apps, like ASP .NET MVC, ASP .NET Core, Blazor, Web Forms, UWP, Windows Forms, GTK#, Xamarin and Unity3D games.
1614

1715

1816
--------
1917

2018
## Projects, papers, journals, books, tutorials, courses and apps using GeneticSharp
2119
* [AeroVision: aircraft trajectories optimization and visualization (paper)](https://github.com/giacomelli/GeneticSharp/blob/master/docs/mentioning-GeneticSharp/AeroVision-Aircraft-trajectories-optimization-and-visualization.pdf)
2220
* [Artificial Intelligence course in French engineering schools (course)](https://github.com/giacomelli/GeneticSharp/pull/43#issuecomment-433662175)
23-
* [Analysis and comparison between Black-Scholes and Merton and Corrado-Su for options pricing (paper)](https://github.com/giacomelli/GeneticSharp/blob/master/docs/mentioning-GeneticSharp/Analysis-and-comparison-between-Black-Scholes-and-Merton-and-Corrado-Su-for-options-pricing.pdf) 🇧🇷
21+
* [Analysis and comparison between Black-Scholes and Merton and Corrado-Su for options pricing (paper)](https://github.com/giacomelli/GeneticSharp/blob/master/docs/mentioning-GeneticSharp/Analysis-and-comparison-between-Black-Scholes-and-Merton-and-Corrado-Su-for-options-pricing.pdf) ![](https://img.shields.io/badge/BR-green.svg)
2422
* [Context-Sensitive Code Completion: improving predictions with genetic algorithms (paper)](https://github.com/giacomelli/GeneticSharp/blob/master/docs/mentioning-GeneticSharp/Context-Sensitive-Code-Completion-improving-predictions-with-genetic-algorithms.pdf) [(Github)](https://github.com/godtopus/GeneCSCC)
2523
* [Deriving Functions for Pareto Optimal Fronts Using Genetic Programming (paper/book)](https://books.google.com.br/books?id=w_lcDwAAQBAJ&lpg=PA473&ots=Rv7O6FhCSM&dq=%22GeneticSharp%22&hl=pt-BR&pg=PA464#v=onepage&q=%22GeneticSharp%22&f=false)
2624
* [Designing and creating a self managing distributed file system (paper)](https://github.com/giacomelli/GeneticSharp/blob/master/docs/mentioning-GeneticSharp/Designing-and-creating-a-self-managing-distributed-file-system.pdf)
25+
* [Design of a warehouse order picking policy using genetic algorithm (paper)](https://github.com/giacomelli/GeneticSharp/blob/master/docs/mentioning-GeneticSharp/Design-of-a-warehouse-order-picking-policy-using-genetic-algorithm.pdf)
2726
* [Developing trading strategies with genetic algorithms (forum)](https://www.quantconnect.com/forum/discussion/2396/developing-trading-strategies-with-genetic-algorithms) [(paper)](https://github.com/giacomelli/GeneticSharp/blob/master/docs/mentioning-GeneticSharp/Developing-Trading-Strategies-with-Genetic-Algorithms.pdf)
27+
* [Fabrication of Adiabatic Quantum-Flux-Parametron Integrated Circuits Using an Automatic Placement Tool Based on Genetic Algorithms (paper)](https://ieeexplore.ieee.org/document/8643945)
2828
* [Frixel: 2D framing / pixel structural optimization (project)](https://github.com/EmilPoulsen/Frixel)
2929
* [Function optimization with GeneticSharp (tutorial)](http://diegogiacomelli.com.br/function-optimization-with-geneticsharp/)
3030
* [GeneticSharp Car2D (sample)](http://diegogiacomelli.com.br/GeneticSharp-Car2D/)
3131
* [GeneticSharp Unity3d Samples (Android app)](https://play.google.com/store/apps/details?id=br.com.diegogiacomelli.geneticsharprunnersunityapp)
32-
* [Genetic Scheduler: a genetic algorithm for scheduling tasks with temporal restriction in distributed systems (paper)](https://github.com/giacomelli/GeneticSharp/blob/master/docs/mentioning-GeneticSharp/Genetic-Scheduler.pdf) 🇧🇷
32+
* [Genetic Scheduler: a genetic algorithm for scheduling tasks with temporal restriction in distributed systems (paper)](https://github.com/giacomelli/GeneticSharp/blob/master/docs/mentioning-GeneticSharp/Genetic-Scheduler.pdf) ![](https://img.shields.io/badge/BR-green.svg)
3333
* [Lean Optimization: genetic optimization using LEAN (GitHub)](https://github.com/Jay-Jay-D/LeanOptimization)
3434
* [OpenFMSL: simulate stationary chemical processes using mass and energy balances (project)](https://github.com/Nukleon84/OpenFMSL)
35+
* [Modelling and Simulation Analysis of Goal-Oriented Business Process (paper)](https://github.com/giacomelli/GeneticSharp/blob/master/docs/mentioning-GeneticSharp/Modelling-and-Simulation-Analysis-of-Goal-Oriented-Business-Process.pdf) ![](https://img.shields.io/badge/LT-red.svg)
3536
* [Optimization of patient flow in emergency departments using Genetic Algorithms (paper)](https://github.com/giacomelli/GeneticSharp/blob/master/docs/mentioning-GeneticSharp/Optimization-of-Patient-Flow-in-Emergency-Departments-using-Genetic-Algorithms.pdf)
37+
* [Optimization by genetic algorithm of lattices structures for the media generation in additive manufacturing (paper)](https://github.com/giacomelli/GeneticSharp/blob/master/docs/mentioning-GeneticSharp/Optimisation-par-algorithme-genetique-de-structures-lattices.pdf) ![](https://img.shields.io/badge/FR-blue.svg)
3638
* [Overload journal 142: Evolutionary computing frameworks for optimisation (journal)](https://accu.org/var/uploads/journals/Overload142.pdf)
3739
* [Path Finding with Genetic Algorithms (project)](https://yoloprogramming.com/post/2017/01/11/path-finding-with-genetic-algorithms)
3840
* [SurvivorAI: some experiments of survival scenarios (project)](https://github.com/giacomelli/SurvivorAI)
3941
* [ThermalDesign (project)](https://github.com/simonjduff/ThermalDesign)
42+
* [TrussOptimization (project)](https://trussoptimizationweb.herokuapp.com)
4043
* [TSP with GeneticSharp and Unity3D (tutorial)](http://diegogiacomelli.com.br/tsp-with-GeneticSharp-and-Unity3d/)
4144
* [VetMedData.NET: a .NET Core class library for obtaining structured data on UK-licensed Veterinary Medicines (project)](https://github.com/Jongmassey/VetMedData.NET)
4245
* Are you using GeneticSharp in your project? Please, [let me know!](https://twitter.com/ogiacomelli)
@@ -127,6 +130,9 @@ Add your own fitness evaluation, implementing [IFitness](src/GeneticSharp.Domain
127130
- Others task executors can be added implementing [ITaskExecutor](src/GeneticSharp.Infrastructure.Framework/Threading/ITaskExecutor.cs) interface.
128131

129132
## Samples
133+
### [Blazor samples](src/GeneticSharp.Runner.BlacorApp)
134+
- [TSP (Travelling Salesman Problem) [online]](http://diegogiacomelli.com.br/apps/geneticsharp-runner-blazorapp)
135+
130136
### [Console samples](src/GeneticSharp.Runner.ConsoleApp)
131137
- AutoConfig
132138
- Bitmap equality
@@ -183,7 +189,9 @@ GeneticSharp and extensions (TSP, AutoConfig, Bitmap equality, Equality equation
183189
install-package GeneticSharp.Extensions
184190
```
185191
## Unity3D
186-
If want to use GeneticSharp on Unity3D you can use the latest GeneticSharp.unitypackage available on our [release page](https://github.com/giacomelli/GeneticSharp/releases).
192+
You should use the [UnityNuGet](https://github.com/xoofx/UnityNuGet) to install GeneticSharp directly from NuGet.
193+
194+
Or you can use the latest GeneticSharp.unitypackage available on our [release page](https://github.com/giacomelli/GeneticSharp/releases).
187195

188196
## Mono and .NET Framework 3.5
189197
To install previous version that support .NET Framework 3.5:
@@ -217,7 +225,7 @@ public class MyProblemFitness : IFitness
217225

218226
public class MyProblemChromosome : ChromosomeBase
219227
{
220-
// Change the argument value passed to base construtor to change the length
228+
// Change the argument value passed to base constructor to change the length
221229
// of your chromosome.
222230
public MyProblemChromosome() : base(10)
223231
{
@@ -255,6 +263,39 @@ ga.Start();
255263

256264
Console.WriteLine("Best solution found has {0} fitness.", ga.BestChromosome.Fitness);
257265
```
266+
267+
268+
## Templates for `dotnet new`
269+
If you're using .NET Core, you can install GeneticSharp.Templates:
270+
271+
```shell
272+
dotnet new -i GeneticSharp.Templates
273+
```
274+
275+
There are 4 templates in GeneticSharp.Templates:
276+
### TSP Blazor application
277+
A Blazor client application template with GeneticSharp ready to run a Travelling Salesman Problem (TSP).
278+
```shell
279+
dotnet new GeneticSharpTspBlazorApp -n MyNamespace -o MyOutoputFolder
280+
```
281+
282+
### Console application
283+
A console application template with GeneticSharp, you just need to implement the chromosome and fitness function.
284+
```shell
285+
dotnet new GeneticSharpConsoleApp -n MyNamespace -o MyOutoputFolder
286+
```
287+
288+
### TSP Console application
289+
A console application template with GeneticSharp ready to run a Travelling Salesman Problem (TSP).
290+
```shell
291+
dotnet new GeneticSharpTspConsoleApp -n MyNamespace -o MyOutoputFolder
292+
```
293+
294+
### TSP Unity3D
295+
A Unity3D template with GeneticSharp ready to run a Travelling Salesman Problem (TSP).
296+
```shell
297+
dotnet new GeneticSharpTspUnity3d -n MyNamespace -o MyOutoputFolder
298+
```
258299

259300
--------
260301

@@ -264,7 +305,8 @@ Having troubles?
264305

265306
- Read our [wiki](https://github.com/giacomelli/GeneticSharp/wiki).
266307
- Tutorials
267-
- [Function optimization with GeneticSharp](http://diegogiacomelli.com.br/function-optimization-with-geneticsharp/)
308+
- [Function optimization with GeneticSharp](http://diegogiacomelli.com.br/function-optimization-with-geneticsharp/)
309+
- [TSP with GeneticSharp and Blazor](http://diegogiacomelli.com.br/tsp-with-geneticsharp-and-blazor)
268310
- [TSP with GeneticSharp and Unity3D](http://diegogiacomelli.com.br/tsp-with-GeneticSharp-and-Unity3d/)
269311
- Ask on [Stack Overflow](http://stackoverflow.com/questions/tagged/geneticsharp) using the tag [GeneticSharp](http://stackoverflow.com/questions/tagged/geneticsharp).
270312
- Open an [issue](https://github.com/giacomelli/GeneticSharp/issues).
@@ -289,4 +331,4 @@ In others words, you can use this library for developement any kind of software:
289331

290332

291333
[![](docs/images/appveyor-logo.png)](https://www.appveyor.com/)|[![](docs/images/jetbrains-logo.png)](https://www.jetbrains.com/)|[![](docs/images/smashinglogo-logo.png)](https://smashinglogo.com/)|[![](docs/images/sonarcloud-logo.png)](https://sonarcloud.io)|
292-
|:-:|:-:|:-:|:-:|
334+
|:-:|:-:|:-:|:-:|

appveyor.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,11 @@ build_script:
4040
- cmd: dotnet build src/GeneticSharp.Runner.ConsoleApp -f netcoreapp2.0
4141

4242
after_build:
43-
- cmd: >-
44-
mkdir .\src\nuget
43+
# Build the GeneticSharp and GeneticSharp.Extensions NuGet packages.
44+
- cmd: tools/buildLibrariesNuget.cmd
4545

46-
dotnet pack src/GeneticSharp.Domain/GeneticSharp.Domain.csproj -c release --no-build --output ../nuget /p:PackageVersion=2.5.2
47-
48-
dotnet pack src/GeneticSharp.Extensions/GeneticSharp.Extensions.csproj -c release --no-build --output ../nuget /p:PackageVersion=2.5.2
46+
# Build the GeneticSharp.Templates NuGet package.
47+
- cmd: tools/buildTemplatesNuget.cmd
4948

5049
test_script:
5150
- cmd: dotnet clean src/GeneticSharp.Domain.UnitTests
@@ -59,4 +58,7 @@ test_script:
5958

6059
artifacts:
6160
- path: .\src\nuget\*.nupkg
62-
name: NuGet packages
61+
name: Libraries NuGet packages
62+
63+
- path: .\src\Templates\*.nupkg
64+
name: Templates NuGet package
Binary file not shown.

src/GeneticSharp.Domain/Chromosomes/ChromosomeExtensions.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ public static class ChromosomeExtensions
2222
/// <param name="chromosomes">The chromosomes.</param>
2323
public static bool AnyHasRepeatedGene(this IList<IChromosome> chromosomes)
2424
{
25-
foreach (var p in chromosomes)
25+
for (int i = 0; i < chromosomes.Count; i++)
2626
{
27-
var notRepeatedGenesLength = p.GetGenes().Distinct().Count();
27+
var c = chromosomes[i];
28+
var notRepeatedGenesLength = c.GetGenes().Distinct().Count();
2829

29-
if (notRepeatedGenesLength < p.Length)
30+
if (notRepeatedGenesLength < c.Length)
3031
{
3132
return true;
3233
}

src/GeneticSharp.Domain/DefaultOperatorsStrategy.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ public class DefaultOperatorsStrategy : IOperatorsStrategy
2222
/// <returns>The result chromosomes.</returns>
2323
public IList<IChromosome> Cross(IPopulation population, ICrossover crossover, float crossoverProbability, IList<IChromosome> parents)
2424
{
25-
var offspring = new List<IChromosome>();
25+
var minSize = population.MinSize;
26+
var offspring = new List<IChromosome>(minSize);
2627

27-
for (int i = 0; i < population.MinSize; i += crossover.ParentsNumber)
28+
for (int i = 0; i < minSize; i += crossover.ParentsNumber)
2829
{
2930
var selectedParents = parents.Skip(i).Take(crossover.ParentsNumber).ToList();
3031

@@ -48,9 +49,9 @@ public IList<IChromosome> Cross(IPopulation population, ICrossover crossover, fl
4849
/// <param name="chromosomes">The chromosomes.</param>
4950
public void Mutate(IMutation mutation, float mutationProbability, IList<IChromosome> chromosomes)
5051
{
51-
foreach (var c in chromosomes)
52+
for (int i = 0; i < chromosomes.Count; i++)
5253
{
53-
mutation.Mutate(c, mutationProbability);
54+
mutation.Mutate(chromosomes[i], mutationProbability);
5455
}
5556
}
5657
}

src/GeneticSharp.Domain/Mutations/UniformMutation.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,18 @@ protected override void PerformMutate(IChromosome chromosome, float probability)
7575
}
7676
}
7777

78-
foreach (var i in m_mutableGenesIndexes)
78+
for (int i = 0; i < m_mutableGenesIndexes.Length; i++)
7979
{
80-
if (i >= genesLength)
80+
var geneIndex = m_mutableGenesIndexes[i];
81+
82+
if (geneIndex >= genesLength)
8183
{
82-
throw new MutationException(this, "The chromosome has no gene on index {0}. The chromosome genes length is {1}.".With(i, genesLength));
84+
throw new MutationException(this, "The chromosome has no gene on index {0}. The chromosome genes length is {1}.".With(geneIndex, genesLength));
8385
}
8486

8587
if (RandomizationProvider.Current.GetDouble() <= probability)
8688
{
87-
chromosome.ReplaceGene(i, chromosome.GenerateGene(i));
89+
chromosome.ReplaceGene(geneIndex, chromosome.GenerateGene(geneIndex));
8890
}
8991
}
9092
}

src/GeneticSharp.Domain/Populations/Generation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public Generation(int number, IList<IChromosome> chromosomes)
7373
public void End(int chromosomesNumber)
7474
{
7575
Chromosomes = Chromosomes
76-
.Where(c => ValidateChromosome(c))
76+
.Where(ValidateChromosome)
7777
.OrderByDescending(c => c.Fitness.Value)
7878
.ToList();
7979

src/GeneticSharp.Domain/Properties/SolutionInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
[assembly: AssemblyConfiguration("Release")]
99
#endif
1010

11-
[assembly: AssemblyVersion("2.5.2")]
12-
[assembly: AssemblyFileVersion("2.5.2.0")]
11+
[assembly: AssemblyVersion("2.6.0")]
12+
[assembly: AssemblyFileVersion("2.6.0.0")]

0 commit comments

Comments
 (0)