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.