public List <FuzzyFact> GetAmperageCircuitFact(List <FuzzyFuncStatement> statements, CustomSocket socket)
        {
            var values = new List <double>();

            foreach (var statement in statements)
            {
                values.Add(statement.Result(socket));
            }
            var domain = new FuzzyDomain(CustomSocketDomain.SocketDomain.AmperageCircuit, new FuzzyDomainOption
            {
                ClusterCount =
                    FuzzyCustomSocket.GetFuzzySocketDomains()[CustomSocketDomain.SocketDomain.AmperageCircuit],
                Min = values.Min(),
                Max = values.Max()
            });

            var facts = new List <FuzzyFact>();

            foreach (var value in ClusteringService.CMeans(domain.Clusters.Count, values))
            {
                facts.Add(new FuzzyFact(domain, value.Value, value.ClusterDegree));
            }

            return(facts);
        }
        public List <FuzzyFuncStatement> GetFuzzyFuncStatements(List <FuzzyDomain> domains)
        {
            var statements = new List <FuzzyFuncStatement>();

            var rulesSets = new List <IEnumerable <FuzzyRule> >();

            foreach (var domain in domains)
            {
                rulesSets.Add(domain.Clusters.Select(cluster => new FuzzyRule(domain, cluster)));
            }

            foreach (var rules in SetOperation.CartesianProduct(rulesSets))
            {
                statements.Add(
                    new FuzzyFuncStatement(
                        new FuzzyRuleSet(rules.ToArray()),
                        FuzzyCustomSocket.GetAmperageCircuitFormula(rules.ToDictionary(p => p.Domain.Domain))
                        )
                    );
            }

            return(statements);
        }
        public List <FuzzyDomain> GetFuzzyDomains(List <CustomSocket> sockets)
        {
            var socketType        = typeof(CustomSocket);
            var fuzzyDomains      = new List <FuzzyDomain>();
            var fuzzySocketDomain = FuzzyCustomSocket.GetFuzzySocketDomains();

            foreach (var domain in fuzzySocketDomain.Keys.Where(p => !CustomSocketDomain.DomainIgnore.Contains(p)))
            {
                var type         = CustomSocketDomain.SocketDomainType[domain];
                var domainValues = sockets.Select(p => socketType.GetProperty(domain.ToString()).GetValue(p))
                                   .Where(p => !CustomSocketDomain.SocketDefaultValue[type].Equals(p));

                fuzzyDomains.Add(new FuzzyDomain(
                                     domain, new FuzzyDomainOption
                {
                    ClusterCount = fuzzySocketDomain[domain],
                    Min          = domainValues.Min(),
                    Max          = domainValues.Max()
                }
                                     ));
            }

            return(fuzzyDomains);
        }