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 18, 2024
1 parent 5f42179 commit d408ee8
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions GaSchedule.Algorithm/Dlba.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,11 @@ protected override void Reform()
private void UpdatePositions(List<T> population)
{
var mean = _loudness.Average();
var localBest = _prototype.MakeNewFromPrototype();
if(_gBest == null)
_gBest = _position[0];

_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 Expand Up @@ -112,11 +113,6 @@ private void UpdatePositions(List<T> population)
}

_gBest = _lf.UpdatePosition(population[i], _position, i, _gBest);

var localTemp = _prototype.MakeEmptyFromPrototype();
localTemp.UpdatePositions(_position[i]);
if (localTemp.Dominates(localBest))
localBest = localTemp;
}

var globalBest = _prototype.MakeEmptyFromPrototype(null);
Expand All @@ -131,7 +127,7 @@ private void UpdatePositions(List<T> population)
for(int j = 0; j < dim; ++j)
positionTemp[i][j] = _gBest[j] + (float) n * mean;

if (globalBest.Dominates(localBest)) {
if (prevBest.Dominates(globalBest)) {
_position[i] = positionTemp[i];
_rate[i] *= (float) Math.Pow(_currentGeneration / n, 3);
_loudness[i] *= (float) _alpha;
Expand Down

0 comments on commit d408ee8

Please sign in to comment.