/// <summary>
        /// Computes the score for the given current results.
        /// </summary>
        /// <param name="baselineMatrices">The baseline matrices.</param>
        /// <param name="currentResults">The current results.</param>
        /// <returns></returns>
        public static double ComputeScore(TLSimilarityMatricesCollection baselineMatrices, TLSimilarityMatricesCollection currentResultsMatrices, 
                                          TLDatasetsList datasets, MetricComputationComponentConfig config)
        {
            double score = 0.0;

            double sum = 0;
            double counts = 0;

            IMetricComputation metricComputation = GetMetricComputation(config);

            foreach (TLDataset dataset in datasets)
            {
                TLSimilarityMatrix baseline = baselineMatrices[dataset.Name];
                TLSimilarityMatrix current = currentResultsMatrices[dataset.Name];

                //score is computed based on delta between two techniques from metric computation
                SortedDictionary<string, double> baselineValues = metricComputation.Calculate(baseline, dataset);
                SortedDictionary<string, double> currentValues = metricComputation.Calculate(current, dataset);

                var deltas = ScoreComputationHelper.Delta(baselineValues, currentValues);

                //now compute average of computed deltas, and that's the score

                foreach (double delta in deltas.Values)
                {
                    sum += delta;
                }

                counts += deltas.Count;
            }

            score = sum / counts;

            return score;
        }
예제 #2
0
        /// <summary>
        /// Computes the score for the given current results.
        /// </summary>
        /// <param name="baselineMatrices">The baseline matrices.</param>
        /// <param name="currentResults">The current results.</param>
        /// <returns></returns>
        public static double ComputeScore(TLSimilarityMatricesCollection baselineMatrices, TLSimilarityMatricesCollection currentResultsMatrices,
                                          TLDatasetsList datasets, MetricComputationComponentConfig config)
        {
            double score = 0.0;

            double sum    = 0;
            double counts = 0;

            IMetricComputation metricComputation = GetMetricComputation(config);

            foreach (TLDataset dataset in datasets)
            {
                TLSimilarityMatrix baseline = baselineMatrices[dataset.Name];
                TLSimilarityMatrix current  = currentResultsMatrices[dataset.Name];

                //score is computed based on delta between two techniques from metric computation
                SortedDictionary <string, double> baselineValues = metricComputation.Calculate(baseline, dataset);
                SortedDictionary <string, double> currentValues  = metricComputation.Calculate(current, dataset);

                var deltas = ScoreComputationHelper.Delta(baselineValues, currentValues);

                //now compute average of computed deltas, and that's the score

                foreach (double delta in deltas.Values)
                {
                    sum += delta;
                }

                counts += deltas.Count;
            }

            score = sum / counts;

            return(score);
        }
예제 #3
0
        public override void Compute()
        {
            TLSimilarityMatricesCollection listOfMatrices = (TLSimilarityMatricesCollection)Workspace.Load("listOfMatrices");

            if (listOfMatrices == null)
            {
                throw new ComponentException("The 'listOfMatrices' is null or has not been found in the Workspace.");
            }

            TLSimilarityMatrix matrix = (TLSimilarityMatrix)Workspace.Load("matrix");

            if (matrix == null)
            {
                throw new ComponentException("The 'matrix' input is null or has not been found in the Workspace.");
            }

            string name = (string)Workspace.Load("name");

            if (name == null)
            {
                throw new ComponentException("The 'name' for matrix is null or has not been found in the Workspace. Please, provide the name for the matrix.");
            }

            matrix.Name = name;

            listOfMatrices.Add(matrix);

            Workspace.Store("listOfMatrices", listOfMatrices);
        }
예제 #4
0
        /// <summary>
        /// Adapts the specified collection of matrices into group of tracing results to comply with engine api
        /// </summary>
        /// <param name="matrices">The matrices.</param>
        /// <returns></returns>
        public static GroupOfTracingResults <SingleTracingResults> Adapt(TLSimilarityMatricesCollection matrices, string techniqueName)
        {
            GroupOfTracingResults <SingleTracingResults> results = new GroupOfTracingResults <SingleTracingResults>(techniqueName);

            if (matrices != null)
            {
                foreach (TLSimilarityMatrix matrix in matrices)
                {
                    results.Add(new SingleTracingResults(matrix));
                }
            }
            return(results);
        }
예제 #5
0
        public override void Compute()
        {
            // Loading artifacts & datasets from workspace
            TLArtifactsCollection sourceArtifacts  = (TLArtifactsCollection)Workspace.Load("sourceArtifacts");
            TLArtifactsCollection targetArtifacts  = (TLArtifactsCollection)Workspace.Load("targetArtifacts");
            TLSimilarityMatrix    answerMatrix     = (TLSimilarityMatrix)Workspace.Load("answerMatrix");
            TLSimilarityMatrix    similarityMatrix = (TLSimilarityMatrix)Workspace.Load("similarityMatrix");

            // Checking for null arguments
            if (sourceArtifacts == null)
            {
                throw new ComponentException("The loaded source artifacts cannot be null!");
            }
            if (targetArtifacts == null)
            {
                throw new ComponentException("The loaded target artifacts cannot be null!");
            }
            if (answerMatrix == null)
            {
                throw new ComponentException("The loaded answer matrix cannot be null!");
            }
            if (similarityMatrix == null)
            {
                throw new ComponentException("The loaded similarity matrix cannot be null!");
            }

            // Results calculation
            TLDatasetsList datasets = new TLDatasetsList();
            var            dataset  = new TLDataset("Experiment results");

            dataset.AnswerSet       = answerMatrix;
            dataset.SourceArtifacts = sourceArtifacts;
            dataset.TargetArtifacts = targetArtifacts;
            datasets.Add(dataset);

            TLSimilarityMatricesCollection similarityMatrices = new TLSimilarityMatricesCollection();

            similarityMatrix.Name = "Experiment results";
            similarityMatrices.Add(similarityMatrix);

            MetricComputationEngine engine = new MetricComputationEngine(datasets, Logger, m_config);

            //wrap result similarity matrix into TracingResult
            var tracingResults = GroupOfTracingResults <SingleTracingResults> .Adapt(similarityMatrices, "Experiment results");

            engine.AddTracingResults(tracingResults);
            var results = engine.ComputeResults();

            // Store the results in the workspace
            Workspace.Store("results", results);
        }
        public override void Compute()
        {
            // Loading artifacts & datasets from workspace
            TLArtifactsCollection sourceArtifacts = (TLArtifactsCollection)Workspace.Load("sourceArtifacts");
            TLArtifactsCollection targetArtifacts = (TLArtifactsCollection)Workspace.Load("targetArtifacts");
            TLSimilarityMatrix answerMatrix = (TLSimilarityMatrix)Workspace.Load("answerMatrix");
            TLSimilarityMatrix similarityMatrix = (TLSimilarityMatrix)Workspace.Load("similarityMatrix");

            // Checking for null arguments
            if (sourceArtifacts == null)
            {
                throw new ComponentException("The loaded source artifacts cannot be null!");
            }
            if (targetArtifacts == null)
            {
                throw new ComponentException("The loaded target artifacts cannot be null!");
            }
            if (answerMatrix == null)
            {
                throw new ComponentException("The loaded answer matrix cannot be null!");
            }
            if (similarityMatrix == null)
            {
                throw new ComponentException("The loaded similarity matrix cannot be null!");
            }

            // Results calculation
            TLDatasetsList datasets = new TLDatasetsList();
            var dataset = new TLDataset("Experiment results");
            dataset.AnswerSet = answerMatrix;
            dataset.SourceArtifacts = sourceArtifacts;
            dataset.TargetArtifacts = targetArtifacts;
            datasets.Add(dataset);

            TLSimilarityMatricesCollection similarityMatrices = new TLSimilarityMatricesCollection();
            similarityMatrix.Name = "Experiment results";
            similarityMatrices.Add(similarityMatrix);

            MetricComputationEngine engine = new MetricComputationEngine(datasets, Logger, m_config);

            //wrap result similarity matrix into TracingResult
            var tracingResults = GroupOfTracingResults<SingleTracingResults>.Adapt(similarityMatrices, "Experiment results");
            engine.AddTracingResults(tracingResults);
            var results = engine.ComputeResults();

            // Store the results in the workspace
            Workspace.Store("results", results);
        }
예제 #7
0
        public override void Compute()
        {
            //load dataset from workspace
            TLDatasetsList datasets = (TLDatasetsList)Workspace.Load("datasets");
            TLSimilarityMatricesCollection resultSimilarityMatrices = (TLSimilarityMatricesCollection)Workspace.Load("resultSimilarityMatrices");

            //wrap result similarity matrix into TracingResult
            var tracingResults = Adapt(resultSimilarityMatrices, "Current technique");

            MetricComputationEngine engine = new MetricComputationEngine(datasets, Logger, m_config);

            engine.AddTracingResults(tracingResults);

            TLExperimentsResultsCollection allExperimentResults = engine.ComputeResults();

            //set base data from which all metrics were computed from
            allExperimentResults["Current technique"].BaseData = resultSimilarityMatrices;

            //check if baseline results are in the workspace
            var baseline = (TLExperimentResults)Workspace.Load("BASELINE");

            if (baseline != null)
            {
                //if so, add them to collection of experiment results, so that it can be viewed by GUI component
                allExperimentResults.Add(baseline);

                TLSimilarityMatricesCollection baselineMatrices = baseline.BaseData as TLSimilarityMatricesCollection;

                //compute the score
                allExperimentResults["Current technique"].Score = ScoreComputation.ComputeScore(baselineMatrices, resultSimilarityMatrices, datasets, m_config);
            }
            else
            {
                allExperimentResults["Current technique"].Score = 0.0;
            }

            Workspace.Store("comparedResults", allExperimentResults);
            Workspace.Store("currentResults", allExperimentResults["Current technique"]);
        }
 /// <summary>
 /// Adapts the specified collection of matrices into group of tracing results to comply with engine api
 /// </summary>
 /// <param name="matrices">The matrices.</param>
 /// <returns></returns>
 private GroupOfTracingResults<SingleTracingResults> Adapt(TLSimilarityMatricesCollection matrices, string techniqueName)
 {
     GroupOfTracingResults<SingleTracingResults> results = new GroupOfTracingResults<SingleTracingResults>(techniqueName);
     if (matrices != null)
     {
         foreach (TLSimilarityMatrix matrix in matrices)
         {
             results.Add(new SingleTracingResults(matrix));
         }
     }
     return results;
 }