Beispiel #1
0
        public override global::System.Data.DataSet Clone()
        {
            DatasetResults cln = ((DatasetResults)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
Beispiel #2
0
        public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs)
        {
            DatasetResults ds = new DatasetResults();

            global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
            global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
            global::System.Xml.Schema.XmlSchemaAny         any      = new global::System.Xml.Schema.XmlSchemaAny();
            any.Namespace = ds.Namespace;
            sequence.Items.Add(any);
            type.Particle = sequence;
            global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
            if (xs.Contains(dsSchema.TargetNamespace))
            {
                global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                try {
                    global::System.Xml.Schema.XmlSchema schema = null;
                    dsSchema.Write(s1);
                    for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                    {
                        schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                        s2.SetLength(0);
                        schema.Write(s2);
                        if ((s1.Length == s2.Length))
                        {
                            s1.Position = 0;
                            s2.Position = 0;
                            for (; ((s1.Position != s1.Length) &&
                                    (s1.ReadByte() == s2.ReadByte()));)
                            {
                                ;
                            }
                            if ((s1.Position == s1.Length))
                            {
                                return(type);
                            }
                        }
                    }
                }
                finally {
                    if ((s1 != null))
                    {
                        s1.Close();
                    }
                    if ((s2 != null))
                    {
                        s2.Close();
                    }
                }
            }
            xs.Add(dsSchema);
            return(type);
        }
 /// <summary>
 /// Generates a TLExperimentsResultsCollection containing summary data of results.
 /// This operation is thread-safe.
 /// </summary>
 /// <returns>Results summaries</returns>
 public TLExperimentsResultsCollection GenerateSummaryResults()
 {
     lock (_lock)
     {
         TLExperimentsResultsCollection ExperimentsResultsCollection = new TLExperimentsResultsCollection();
         // iterate over techniques
         foreach (string technique in _techniques)
         {
             TLExperimentResults TechniqueResults = new TLExperimentResults(technique);
             // iterate over datasets
             foreach (string dataset in _datasets)
             {
                 // get list of results for technique + dataset
                 List <IMetricComputation> list = null;
                 string key = ComputeKey(technique, dataset);
                 _results.TryGetValue(key, out list);
                 if (list != null)
                 {
                     DatasetResults data = new DatasetResults(dataset);
                     // add results to dataset
                     foreach (IMetricComputation computation in list)
                     {
                         if (!computation.HasRun)
                         {
                             computation.Compute();
                         }
                         data.AddMetric(computation.GenerateSummary());
                     }
                     // add dataset to technique
                     if (data.Metrics.Count() > 0)
                     {
                         TechniqueResults.AddDatasetResult(data);
                     }
                 }
             }
             // add technique to collection
             if (TechniqueResults.DatasetsResults.Count() > 0)
             {
                 ExperimentsResultsCollection.Add(TechniqueResults);
             }
         }
         return(ExperimentsResultsCollection);
     }
 }
        private TLExperimentResults ComputeMetricResultsForDataset(GroupOfTracingResults <T> tracingResults)
        {
            //create experiment results container for this technique
            TLExperimentResults experimentResult = new TLExperimentResults(tracingResults.TechniqueName);

            foreach (TLDataset dataset in m_datasets)
            {
                DatasetResults datasetResults = new DatasetResults(dataset.Name);

                //iterate through all computation and calculate metric results for this dataset
                foreach (MetricComputationForSingleDataset <T> computation in metricComputationsPerDataset)
                {
                    T tracingResult = default(T);
                    if (tracingResults.Contains(dataset.Name))
                    {
                        tracingResult = tracingResults[dataset.Name];
                    }

                    var metric = computation.Compute(tracingResult, dataset);
                    if (metric == null)
                    {
                        throw new InvalidOperationException("The metric computation method failed to return the metric. " +
                                                            "Even if tracing results are empty computation must return metric with name and description, although it may have empty data");
                    }
                    if (computation is IStatisticallyComparableMetric <T> )
                    {
                        //collect results, so that statistical comparison can be computed afterwards, if there are two techniques
                    }

                    datasetResults.AddMetric(metric);
                }

                experimentResult.AddDatasetResult(datasetResults);
            }

            //compute also set of metrics across all datasets combined
            //experimentResult.AcrossAllDatasetsResults = ComputeMetricResultsAcrossAllDatasets(tracingResults);

            return(experimentResult);
        }
Beispiel #5
0
            public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs)
            {
                global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
                global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
                DatasetResults ds = new DatasetResults();

                global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
                any1.Namespace       = "http://www.w3.org/2001/XMLSchema";
                any1.MinOccurs       = new decimal(0);
                any1.MaxOccurs       = decimal.MaxValue;
                any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any1);
                global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
                any2.Namespace       = "urn:schemas-microsoft-com:xml-diffgram-v1";
                any2.MinOccurs       = new decimal(1);
                any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any2);
                global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute1.Name       = "namespace";
                attribute1.FixedValue = ds.Namespace;
                type.Attributes.Add(attribute1);
                global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute2.Name       = "tableTypeName";
                attribute2.FixedValue = "ResultsDataTable";
                type.Attributes.Add(attribute2);
                type.Particle = sequence;
                global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
                if (xs.Contains(dsSchema.TargetNamespace))
                {
                    global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                    global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                    try {
                        global::System.Xml.Schema.XmlSchema schema = null;
                        dsSchema.Write(s1);
                        for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                        {
                            schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                            s2.SetLength(0);
                            schema.Write(s2);
                            if ((s1.Length == s2.Length))
                            {
                                s1.Position = 0;
                                s2.Position = 0;
                                for (; ((s1.Position != s1.Length) &&
                                        (s1.ReadByte() == s2.ReadByte()));)
                                {
                                    ;
                                }
                                if ((s1.Position == s1.Length))
                                {
                                    return(type);
                                }
                            }
                        }
                    }
                    finally {
                        if ((s1 != null))
                        {
                            s1.Close();
                        }
                        if ((s2 != null))
                        {
                            s2.Close();
                        }
                    }
                }
                xs.Add(dsSchema);
                return(type);
            }
Beispiel #6
0
        public void ExperimentResultsRawSerializationTest()
        {
            int n = 0;
            TLExperimentResults expResultsIn = new TLExperimentResults("Technique " + n++);

            for (int k = 0; k < 5; k++)
            {
                DatasetResults dataResults = new DatasetResults("Dataset " + n++);
                for (int i = 0; i < 10; i++)
                {
                    LineSeries line = new LineSeries("Line " + i, "Description " + n++);
                    for (int j = 1000 * i; j < 1000; j++)
                    {
                        line.AddPoint(new Point(j, j + 1));
                    }
                    dataResults.AddMetric(line);

                    BoxSummaryData box = new BoxSummaryData("Box " + i, "Description " + n++);
                    for (int j = 0; j < 100; j++)
                    {
                        box.AddPoint(new BoxPlotPoint(j, j + 1, j + 2, j + 3, j + 4, j + 5, j + 6, j + 7));
                    }
                    dataResults.AddMetric(box);
                }
                expResultsIn.AddDatasetResult(dataResults);
            }

            BinaryWriter binWriter = new BinaryWriter(new MemoryStream());
            BinaryReader binReader = new BinaryReader(binWriter.BaseStream);

            expResultsIn.WriteData(binWriter);
            binReader.BaseStream.Position = 0;
            TLExperimentResults expResultsOut = (TLExperimentResults)Activator.CreateInstance(typeof(TLExperimentResults), true);

            expResultsOut.ReadData(binReader);

            Assert.AreEqual(expResultsIn.TechniqueName, expResultsOut.TechniqueName);
            Assert.AreEqual(expResultsIn.DatasetsResults.Count(), expResultsOut.DatasetsResults.Count());

            foreach (DatasetResults result1 in expResultsIn.DatasetsResults)
            {
                bool           sameDatasetResultExists = false;
                DatasetResults result2 = null;
                foreach (DatasetResults res in expResultsOut.DatasetsResults)
                {
                    if (res.DatasetName == result1.DatasetName)
                    {
                        sameDatasetResultExists = true;
                        result2 = res;
                        break;
                    }
                }
                Assert.IsTrue(sameDatasetResultExists);

                Assert.AreEqual(result1.DatasetName, result2.DatasetName);
                Assert.AreEqual(result1.Metrics.Count(), result2.Metrics.Count());

                foreach (Metric m1 in result1.Metrics)
                {
                    bool   sameMetricExists = false;
                    Metric m2 = null;
                    foreach (Metric metric in result2.Metrics)
                    {
                        if (m1.MetricName == metric.MetricName)
                        {
                            sameMetricExists = true;
                            m2 = metric;
                            break;
                        }
                    }

                    Assert.IsTrue(sameMetricExists);
                    Assert.AreEqual(m1.Description, m2.Description);

                    if (m1 is LineSeries)
                    {
                        Assert.IsTrue(m2 is LineSeries);
                        LineSeries l1 = (LineSeries)m1;
                        LineSeries l2 = (LineSeries)m2;

                        Assert.AreEqual(l1.Points.Count(), l2.Points.Count());
                    }
                    else
                    {
                        Assert.IsTrue(m2 is BoxSummaryData);
                        BoxSummaryData b1 = (BoxSummaryData)m1;
                        BoxSummaryData b2 = (BoxSummaryData)m2;

                        Assert.AreEqual(b1.Points.Count(), b2.Points.Count());
                    }
                }
            }
        }
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     DatasetResults ds = new DatasetResults();
     global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
     any1.Namespace = "http://www.w3.org/2001/XMLSchema";
     any1.MinOccurs = new decimal(0);
     any1.MaxOccurs = decimal.MaxValue;
     any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any1);
     global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
     any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1";
     any2.MinOccurs = new decimal(1);
     any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any2);
     global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute1.Name = "namespace";
     attribute1.FixedValue = ds.Namespace;
     type.Attributes.Add(attribute1);
     global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute2.Name = "tableTypeName";
     attribute2.FixedValue = "ResultsDataTable";
     type.Attributes.Add(attribute2);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     DatasetResults ds = new DatasetResults();
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny();
     any.Namespace = ds.Namespace;
     sequence.Items.Add(any);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }