Exemple #1
0
        public void SelectBest() // Select the best fragment with the highest relevance which is not disabled (that is, compatible with other selections)
        {
            var    relevantAlternatives          = Alternatives.Where(f => f.IsRelevant == true);
            double bestRelevance                 = relevantAlternatives.Max(f => f.Relevance);
            RecommendedFragment <T> bestFragment = relevantAlternatives.First(f => f.Relevance == bestRelevance);

            SelectedFragment = bestFragment; // Can be null which means reset selection
        }
Exemple #2
0
        public override void Recommend()
        {
            base.Recommend();

            // Add more for aggregations
            MeasureDimensions.Alternatives.Clear();
            if (this.TargetSet != null)
            {
                foreach (ComColumn dim in this.TargetSet.GreaterDims)
                {
                    var frag = new RecommendedFragment <ComColumn>(dim, 1.0);
                    MeasureDimensions.Alternatives.Add(frag);
                }
            }

            AggregationFunctions.Alternatives.Clear();
            AggregationFunctions.Alternatives.Add(new RecommendedFragment <string>("SUM", 1.0));
            AggregationFunctions.Alternatives.Add(new RecommendedFragment <string>("AVG", 1.0));
        }
Exemple #3
0
        /// <summary>
        /// Find all possible relationship paths from this set to the specified destination set via the specified lesser set.
        /// </summary>
        public override void Recommend()
        {
            //
            // 1. Find all possible lesser sets (relationship or fact sets)
            //
            var lesserSets = new List <ComTable>();

            if (this.FactSet != null) // Lesser set is provided
            {
                lesserSets.Add(this.FactSet);
            }
            else // Generate all possible lesser sets
            {
                // All least sets of the source set(s)
                var allPaths = new PathEnumerator(null, new List <ComTable> {
                    this.SourceSet
                }, true, DimensionType.IDENTITY_ENTITY).ToList();
                // All lesser sets of the source set(s)
                foreach (var path in allPaths)
                {
                    foreach (ComColumn seg in path.Path)
                    {
                        if (!lesserSets.Contains(seg.LesserSet))
                        {
                            lesserSets.Add(seg.LesserSet);
                        }
                    }
                }
            }

            //
            // 2. Given a lesser set, find all relationship paths as pairs of <grouping path, measure path>
            //
            foreach (ComTable set in lesserSets)
            {
                var gPaths = new PathEnumerator(new List <ComTable> {
                    set
                }, new List <ComTable> {
                    this.SourceSet
                }, false, DimensionType.IDENTITY_ENTITY).ToList();
                var mPaths = new PathEnumerator(new List <ComTable> {
                    set
                }, new List <ComTable> {
                    this.TargetSet
                }, false, DimensionType.IDENTITY_ENTITY).ToList();

                if (gPaths.Count == 0)
                {
                    continue;              // In fact, there must be at least one path - because the set is known to be a lesser set
                }
                if (set == this.TargetSet) // Target (measure) set is the same as fact set
                {
                    List <ComColumn> loop = new List <ComColumn>();
                    loop.Add(new Dim(set));
                    mPaths.Add(new DimPath(loop));
                }

                if (mPaths.Count == 0)
                {
                    continue;
                }

                RecommendedFragment <ComTable> frag = new RecommendedFragment <ComTable>(set, 1.0);
                this.FactSets.Alternatives.Add(frag);

                gPaths.ForEach(gp => this.GroupingPaths.Alternatives.Add(new RecommendedFragment <List <ComColumn> >(gp.Path, 1.0)));
                mPaths.ForEach(mp => this.MeasurePaths.Alternatives.Add(new RecommendedFragment <List <ComColumn> >(mp.Path, 1.0)));

                // For each pair of grouping paths build a complete relationship path
                foreach (var gp in gPaths)
                {
                    foreach (var mp in mPaths)
                    {
                        this.Recommendations.Alternatives.Add(new RecommendedFragment <object>(null, 1.0)); // TODO: build complete path or an object (tuple of indexes) representing a complete path
                    }
                }
            }
        }