예제 #1
0
파일: FedKF.cs 프로젝트: homoluden/fedkf-ga
 public FedKF(KF[] filters, DenseMatrix dcm, DenseMatrix covariances)
 {
     _filters = filters;
     _filteredSignals = new DenseMatrix(_filters.Length, 1);
     _dcm = dcm;
     _dcmt = dcm.Transpose();
     _cInv = covariances.Inverse();
 }
예제 #2
0
        public static FedKF ToFedKf(this Specimen spec)
        {
            int totalLength = SensorsCount * (NumOrder + DenOrder);
            if (totalLength > spec.Genes.Length)
            {
                throw new ArgumentException("Genome of the specimen is too short;");
            }

            var filters = new KF[SensorsCount];
            var numDenLength = NumOrder + DenOrder;
            var partitioner = Partitioner.Create(0, totalLength, numDenLength);

            Parallel.ForEach(
                partitioner,
                (range, loopstate) =>
                {
                    int sensorIdx = range.Item1 / numDenLength;

                    var numParams = new double[NumOrder];
                    var denParams = new double[DenOrder];
                    for (int i = range.Item1, j = 0; i < range.Item2; i++, j++)
                    {
                        if (j < NumOrder)
                        {
                            numParams[j] = spec.Genes[i];
                        }
                        else
                        {
                            denParams[j - NumOrder] = spec.Genes[i];
                        }
                    }

                    filters[sensorIdx] = KFBuilder.BuildKf(numParams, denParams, new DenseMatrix(1, 1, SensorsOutputCovariances[sensorIdx, sensorIdx]), ProcessCovariances);
                });

            var fkf = new FedKF(filters, DirectCosinsMatrix, SensorsOutputCovariances);
            return fkf;
        }