DarwinGA 1.0.0
See the version list below for details.
dotnet add package DarwinGA --version 1.0.0
NuGet\Install-Package DarwinGA -Version 1.0.0
<PackageReference Include="DarwinGA" Version="1.0.0" />
<PackageVersion Include="DarwinGA" Version="1.0.0" />
<PackageReference Include="DarwinGA" />
paket add DarwinGA --version 1.0.0
#r "nuget: DarwinGA, 1.0.0"
#:package DarwinGA@1.0.0
#addin nuget:?package=DarwinGA&version=1.0.0
#tool nuget:?package=DarwinGA&version=1.0.0
π§© Creating a Custom Evolutionary Problem
DarwinGA is designed to be problem-agnostic.
That means you donβt solve a problem directly β you define how a solution behaves, and the algorithm evolves it.
To use DarwinGA, you only need to define 3 things:
1οΈβ£ Define your Solution (Chromosome)
This represents a candidate solution.
public class MySolution
{
public double Price { get; set; }
}
π This is what evolves.
You can model anything:
- numbers
- arrays
- objects
- strategies
2οΈβ£ Define the Fitness Function
This is the most important part.
It tells the algorithm:
βHow good is this solution?β
public class MyFitnessEvaluator : IFitnessEvaluator<MySolution>
{
public double Evaluate(MySolution solution)
{
// Example: maximize profit
double demand = 100 - solution.Price;
double profit = solution.Price * demand;
return profit;
}
}
π The algorithm will try to maximize this value.
3οΈβ£ (Optional) Customize Mutation & Crossover
You can control how solutions evolve.
Mutation
public class MyMutation : IMutationStrategy<MySolution>
{
public void Mutate(MySolution solution)
{
solution.Price += Random.Shared.NextDouble() * 2 - 1;
}
}
Crossover
public class MyCrossover : ICrossoverStrategy<MySolution>
{
public MySolution Crossover(MySolution a, MySolution b)
{
return new MySolution
{
Price = (a.Price + b.Price) / 2
};
}
}
π These define how evolution behaves.
π Running the Algorithm
Once defined, you plug everything into the engine:
var ga = new GeneticAlgorithm<MySolution>(
populationSize: 100,
mutationRate: 0.05,
crossoverRate: 0.7,
fitnessEvaluator: new MyFitnessEvaluator(),
mutationStrategy: new MyMutation(),
crossoverStrategy: new MyCrossover()
);
ga.Initialize(() => new MySolution
{
Price = Random.Shared.NextDouble() * 100
});
ga.Run(generations: 200);
var best = ga.GetBestSolution();
Console.WriteLine($"Best price found: {best.Price}");
π§ How to Think in Evolutionary Terms
Instead of asking:
β βHow do I solve this problem?β
You ask:
β βWhat does a solution look like?β β βHow do I measure if it's good?β β βHow can I slightly modify it?β
Thatβs it.
The algorithm does the rest.
π‘ Key Insight
A good evolutionary setup depends on:
- βοΈ A meaningful fitness function
- βοΈ A representation that can evolve smoothly
- βοΈ Balanced mutation (not too random, not too rigid)
β οΈ Common Mistakes
- β Fitness function too simple β no evolution
- β Mutation too aggressive β chaos
- β No diversity β early stagnation
- β Overfitting to a specific case
π₯ Real Example Ideas
You can build custom evolutions for:
- π° Pricing optimization
- π¦ Warehouse distribution
- π Delivery routes
- π§ AI parameter tuning
- π― Strategy optimization
𧬠Final Mental Model
Think of DarwinGA as:
A system where you define the rules of survival, and solutions fight to become the best.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Accord.Neuro (>= 3.8.0)
- Accord.Statistics (>= 3.8.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.