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 Jul 24, 2023
1 parent 8f3a874 commit d63b04b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions nQuant.Master/PnnLABGAQuantizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ private string RatioKey
private AmplifyFn GetAmplifyFn(bool tooSmall)
{
if (tooSmall)
return val => Math.Exp(val);
return val => Math.Log(val);
return val => Math.PI * val;
return val => .5 * Math.PI * val;
}

private void CalculateError(double[] errors)
Expand Down
9 changes: 5 additions & 4 deletions nQuant.Master/ga/NsgaIII.cs
Original file line number Diff line number Diff line change
Expand Up @@ -551,12 +551,13 @@ protected List<T> Selection(List<T> cur, List<ReferencePoint> rps)

protected virtual List<T> Crossing(List<T> population)
{
var offspring = new List<T>(_populationSize);
Parallel.ForEach(Enumerable.Range(0, _populationSize), i => {
var populationSize = population.Count;
var offspring = new List<T>(populationSize);
Parallel.ForEach(Enumerable.Range(0, populationSize), i => {
if (i % 2 == 0) {
int father = Rand(_populationSize), mother = Rand(_populationSize);
int father = Rand(populationSize), mother = Rand(populationSize);
offspring.Add(population[father].Crossover(population[mother], _numberOfCrossoverPoints, _crossoverProbability));
if((i + 1) < _populationSize)
if((i + 1) < populationSize)
offspring.Add(population[mother].Crossover(population[father], _numberOfCrossoverPoints, _crossoverProbability));
}
});
Expand Down

0 comments on commit d63b04b

Please sign in to comment.