mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2025-06-27 05:23:13 +00:00
PID
This commit is contained in:
@ -1,12 +1,14 @@
|
||||
using Esiur.Data;
|
||||
using Esiur.Resource;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Esiur.Analysis.Optimization
|
||||
{
|
||||
@ -57,10 +59,18 @@ namespace Esiur.Analysis.Optimization
|
||||
|
||||
KeyValuePair<T, double>[] GetFitness()
|
||||
{
|
||||
var rt = new List<KeyValuePair<T, double>>();
|
||||
//var rt = new List<KeyValuePair<T, double>>();
|
||||
var rt = new ConcurrentBag<KeyValuePair<T, double>>();
|
||||
|
||||
foreach (var record in Population)
|
||||
rt.Add(new KeyValuePair<T, double>( record, FitnessFunction(record)));
|
||||
|
||||
Parallel.ForEach(Population, record =>
|
||||
{
|
||||
rt.Add(new KeyValuePair<T, double>(record, FitnessFunction(record)));
|
||||
|
||||
});
|
||||
|
||||
//foreach (var record in Population)
|
||||
// rt.Add(new KeyValuePair<T, double>( record, FitnessFunction(record)));
|
||||
|
||||
return rt.ToArray();
|
||||
}
|
||||
|
@ -35,9 +35,9 @@ namespace Esiur.Analysis.Statistics
|
||||
|
||||
public static double RMS(this double[] x)
|
||||
{
|
||||
var r = Math.Sqrt(x.Sum(x => x * x) / x.Length);
|
||||
if (double.IsNaN(r))
|
||||
Console.WriteLine();
|
||||
var r = Math.Sqrt(x.Sum(x =>(float) x * (float) x) / x.Length);
|
||||
//if (double.IsNaN(r) || double.IsInfinity(r))
|
||||
// Console.WriteLine();
|
||||
return r;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user