Example #1
0
        /// <summary>
        /// Add a item to this cluster and adjust the cluster vector, itemship list and sum vector accordingly.
        /// </summary>
        /// <param name="item">The item to be added.</param>
        public void AddItemToCluster(FeatureItem item)
        {
            if (!ClusterItemList.Contains(item))
            {
                ClusterItemList.Add(item);
                AdaptiveIntersect.UpdateFeatureIntersectionByLast(ClusterItemList, ClusterVector);
                AdaptiveIntersect.UpdateFeatureSummaryByLast(ClusterItemList, ClusterVectorSummary);

                //----- remove for debugging and tests only
                tempClusterVectorMagnitude        = AdaptiveIntersect.CalculateVectorMagnitude(ClusterVector);        //remove for debugging and tests only
                tempClusterVectorSummaryMagnitude = AdaptiveIntersect.CalculateVectorMagnitude(ClusterVectorSummary); //remove for debugging and tests only
            }
        }
Example #2
0
        /// <summary>
        /// Constructor. Cluster vector is set to the initial feature vector.
        /// </summary>
        /// <param name="item">The item used to construct this cluster</param>
        public Cluster(FeatureItem item)
        {
            //resulting values should be copied
            ClusterVector = new double[item.FeatureVector.Length];
            Array.Copy(item.FeatureVector, ClusterVector, item.FeatureVector.Length);
            ClusterVectorSummary = new double[item.FeatureVector.Length];
            Array.Copy(item.FeatureVector, ClusterVectorSummary, item.FeatureVector.Length);
            ClusterItemList = new List <FeatureItem>();
            ClusterItemList.Add(item);

            //----- remove for debugging and tests only
            tempClusterVectorMagnitude        = AdaptiveIntersect.CalculateVectorMagnitude(ClusterVector);        //remove for debugging and tests only
            tempClusterVectorSummaryMagnitude = AdaptiveIntersect.CalculateVectorMagnitude(ClusterVectorSummary); //remove for debugging and tests only
        }
Example #3
0
        /// <summary>
        /// Remove a item from this cluster and update cluster Vector accordingly (basd on other assigned items)
        /// Return false if ItemList is empty
        /// </summary>
        /// <param name="item">The item to be removed</param>
        public bool RemoveItemFromCluster(FeatureItem item)
        {
            if (ClusterItemList.Remove(item) == true)
            {
                if (ClusterItemList.Count > 0)   //recalculate vector summary only if not empty
                {
                    AdaptiveIntersect.CalculateFeatureIntersection(ClusterItemList, ClusterVector);
                    AdaptiveIntersect.CalculateFeatureSummary(ClusterItemList, ClusterVectorSummary);

                    //----- remove for debugging and tests only
                    tempClusterVectorMagnitude        = AdaptiveIntersect.CalculateVectorMagnitude(ClusterVector);        //remove for debugging and tests only
                    tempClusterVectorSummaryMagnitude = AdaptiveIntersect.CalculateVectorMagnitude(ClusterVectorSummary); //remove for debugging and tests only
                }
            }
            return(ClusterItemList.Count > 0);
        }