Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
mcychan authored Jun 20, 2024
1 parent d408ee8 commit 03fab5f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 8 additions & 4 deletions GaSchedule.Algorithm/Dlba.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public class Dlba<T> : NsgaIII<T> where T : Chromosome<T>
// Initializes Bat algorithm
public Dlba(T prototype, int numberOfCrossoverPoints = 2, int mutationSize = 2, float crossoverProbability = 80, float mutationProbability = 3) : base(prototype, numberOfCrossoverPoints, mutationSize, crossoverProbability, mutationProbability)
{
// there should be at least 5 chromosomes in population
if (_populationSize < 5)
_populationSize = 5;

_alpha = 0.9;
_pa = .25;
}
Expand Down Expand Up @@ -81,10 +85,10 @@ private void UpdatePositions(List<T> population)
{
var mean = _loudness.Average();
if(_gBest == null)
_gBest = _position[0];
var prevBest = _prototype.MakeEmptyFromPrototype();
prevBest.UpdatePositions(_gBest);

_gBest = _position[0];
var prevBest = _prototype.MakeEmptyFromPrototype();
prevBest.UpdatePositions(_gBest);

for (int i = 0; i < _populationSize; ++i) {
var beta = (float) Configuration.Random();
var rand = Configuration.Random();
Expand Down
6 changes: 5 additions & 1 deletion GaSchedule.Algorithm/Fpa.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ public class Fpa<T> : NsgaIII<T> where T : Chromosome<T>

// Initializes Flower Pollination Algorithm
public Fpa(T prototype, int numberOfCrossoverPoints = 2, int mutationSize = 2, float crossoverProbability = 80, float mutationProbability = 3) : base(prototype, numberOfCrossoverPoints, mutationSize, crossoverProbability, mutationProbability)
{
{
// there should be at least 5 chromosomes in population
if (_populationSize < 5)
_populationSize = 5;

_pa = .25;
}

Expand Down

0 comments on commit 03fab5f

Please sign in to comment.