コード例 #1
0
        public void TestSamplingOnlyNonDominatedObjectsWithinSampleSkylineViaGetSkyline()
        {
            string skylineSampleSQL = TestContext.DataRow["skylineSampleSQL"].ToString();
            string entireSkylineSQL = TestContext.DataRow["entireSkylineSQL"].ToString();
            string testComment      = TestContext.DataRow["comment"].ToString();

            Debug.WriteLine(testComment);
            Debug.WriteLine(skylineSampleSQL);

            var common = new SQLCommon
            {
                SkylineType =
                    new SkylineBNL()
                {
                    Provider = Helper.ProviderName, ConnectionString = Helper.ConnectionString
                }
            };

            var prefSqlModelSkylineSample = common.GetPrefSqlModelFromPreferenceSql(skylineSampleSQL);
            var prefSqlModelEntireSkyline = common.GetPrefSqlModelFromPreferenceSql(entireSkylineSQL);

            var subjectUnderTest = new SQLParser.Helper
            {
                ConnectionString = Helper.ConnectionString,
                DriverString     = Helper.ProviderName
            };

            var sw = new Stopwatch();

            sw.Start();
            var entireSkyline = subjectUnderTest.GetResults(
                common.GetAnsiSqlFromPrefSqlModel(prefSqlModelEntireSkyline), common.SkylineType,
                prefSqlModelEntireSkyline, false);

            sw.Stop();
            Debug.WriteLine("ORIG ElapsedMilliseconds={0}", sw.ElapsedMilliseconds);
            Debug.WriteLine("ORIG Algorithm ElapsedMilliseconds={0}", subjectUnderTest.TimeInMilliseconds);
            sw.Restart();
            var sampleSkyline = subjectUnderTest.GetResults(
                common.GetAnsiSqlFromPrefSqlModel(prefSqlModelSkylineSample), common.SkylineType,
                prefSqlModelSkylineSample, false);

            sw.Stop();
            Debug.WriteLine("SMPL ElapsedMilliseconds={0}", sw.ElapsedMilliseconds);
            Debug.WriteLine("SMPL Algorithm ElapsedMilliseconds={0}", subjectUnderTest.TimeInMilliseconds);

            var entireSkylineObjectsIds = GetHashSetOfIdsFromDataTable(entireSkyline);
            var sampleSkylineObjectsIds = GetHashSetOfIdsFromDataTable(sampleSkyline);

            Debug.WriteLine("ORIG Count={0}", entireSkylineObjectsIds.Count);
            Debug.WriteLine("SMPL Count={0}", sampleSkylineObjectsIds.Count);

            Assert.IsTrue(sampleSkylineObjectsIds.IsSubsetOf(entireSkylineObjectsIds),
                          "Dominated objects contained in Sample Skyline (i.e., objects which are not contained in the entire Skyline).");
        }
コード例 #2
0
        public void TestSamplingObjectsWithinEntireSkylineCount()
        {
            var entireSkylineSQL = TestContext.DataRow["entireSkylineSQL"].ToString();
            var testComment      = TestContext.DataRow["comment"].ToString();

            Debug.WriteLine(testComment);

            var common = new SQLCommon {
                SkylineType = new SkylineBNL()
            };

            var prefSqlModelEntireSkyline = common.GetPrefSqlModelFromPreferenceSql(entireSkylineSQL);
            var subjectUnderTest          = new SQLParser.Helper
            {
                ConnectionString = Helper.ConnectionString,
                DriverString     = Helper.ProviderName
            };

            var entireSkyline = subjectUnderTest.GetResults(
                common.GetAnsiSqlFromPrefSqlModel(prefSqlModelEntireSkyline), common.SkylineType,
                prefSqlModelEntireSkyline, false);

            var expected = TestContext.DataRow["entireCount"].ToString();
            var actual   = entireSkyline.Rows.Count.ToString(CultureInfo.InvariantCulture);

            Assert.AreEqual(expected, actual, "Entire Skyline contains unexpected number of objects.");
        }
コード例 #3
0
        public void TestSamplingOnlyNonDominatedObjectsWithinSampleSkyline()
        {
            string skylineSampleSql = TestContext.DataRow["skylineSampleSQL"].ToString();
            string entireSkylineSql = TestContext.DataRow["entireSkylineSQL"].ToString();
            string testComment      = TestContext.DataRow["comment"].ToString();

            Debug.WriteLine(testComment);
            Debug.WriteLine(skylineSampleSql);

            string baseQuery;
            string operators;
            int    numberOfRecords;

            string[] parameter;

            var common = new SQLCommon
            {
                SkylineType =
                    new SkylineBNL()
                {
                    Provider = Helper.ProviderName, ConnectionString = Helper.ConnectionString
                }
            };

            PrefSQLModel prefSqlModelSkylineSample = common.GetPrefSqlModelFromPreferenceSql(skylineSampleSql);
            string       ansiSql = common.GetAnsiSqlFromPrefSqlModel(prefSqlModelSkylineSample);

            prefSQL.SQLParser.Helper.DetermineParameters(ansiSql, out parameter, out baseQuery, out operators,
                                                         out numberOfRecords);

            IEnumerable <CLRSafeHashSet <int> > useSubsets = UseSubsets(prefSqlModelSkylineSample);
            var subsetsProducer = new FixedSkylineSamplingSubsetsProducer(useSubsets);
            var utility         = new SkylineSamplingUtility(subsetsProducer);
            var skylineSample   = new SkylineSampling(utility)
            {
                SubsetCount      = prefSqlModelSkylineSample.SkylineSampleCount,
                SubsetDimension  = prefSqlModelSkylineSample.SkylineSampleDimension,
                SelectedStrategy = common.SkylineType
            };

            DataTable entireSkyline = common.ParseAndExecutePrefSQL(Helper.ConnectionString, Helper.ProviderName,
                                                                    entireSkylineSql);
            DataTable sampleSkyline = skylineSample.GetSkylineTable(baseQuery, operators);

            HashSet <int> entireSkylineObjectsIds = GetHashSetOfIdsFromDataTable(entireSkyline);
            HashSet <int> sampleSkylineObjectsIds = GetHashSetOfIdsFromDataTable(sampleSkyline);

            sampleSkylineObjectsIds.ExceptWith(entireSkylineObjectsIds);

            Debug.WriteLine("wrong objects:");
            foreach (int i in sampleSkylineObjectsIds)
            {
                Debug.WriteLine(i);
            }

            Assert.IsTrue(sampleSkylineObjectsIds.IsSubsetOf(entireSkylineObjectsIds),
                          "Dominated objects contained in Sample Skyline (i.e., objects which are not contained in the entire Skyline).");
        }
コード例 #4
0
        private static void ExecuteSampleSkylines(IReadOnlyCollection <IEnumerable <CLRSafeHashSet <int> > > producedSubsets,
                                                  PrefSQLModel prefSqlModel, SQLCommon common)
        {
            var objectsCount = 0;
            var timeSpent    = 0L;

            string strQuery;
            string operators;
            int    numberOfRecords;

            string[] parameter;

            string ansiSql = common.GetAnsiSqlFromPrefSqlModel(prefSqlModel);

            Debug.Write(ansiSql);
            prefSQL.SQLParser.Helper.DetermineParameters(ansiSql, out parameter, out strQuery, out operators,
                                                         out numberOfRecords);

            var sw = new Stopwatch();

            foreach (IEnumerable <CLRSafeHashSet <int> > subset in producedSubsets)
            {
                var subsetsProducer = new FixedSkylineSamplingSubsetsProducer(subset);
                var utility         = new SkylineSamplingUtility(subsetsProducer);
                var skylineSample   = new SkylineSampling(utility)
                {
                    SubsetCount      = prefSqlModel.SkylineSampleCount,
                    SubsetDimension  = prefSqlModel.SkylineSampleDimension,
                    SelectedStrategy = common.SkylineType
                };

                sw.Restart();
                DataTable dataTable = skylineSample.GetSkylineTable(strQuery, operators);
                sw.Stop();

                objectsCount += dataTable.Rows.Count;
                timeSpent    += skylineSample.TimeMilliseconds;
                foreach (CLRSafeHashSet <int> attribute in subset)
                {
                    Console.Write("[");
                    foreach (int attribute1 in attribute)
                    {
                        Console.Write(attribute1 + ",");
                    }
                    Console.Write("],");
                }
                Console.WriteLine();
                Console.WriteLine("alg time : " + skylineSample.TimeMilliseconds);
                Console.WriteLine("full time : " + sw.ElapsedMilliseconds);
                Console.WriteLine("objects : " + dataTable.Rows.Count);
            }

            Console.WriteLine("time average: " + (double)timeSpent / producedSubsets.Count);
            Console.WriteLine("objects average: " + (double)objectsCount / producedSubsets.Count);
        }
コード例 #5
0
        public void TestSamplingNumberOfObjectsWithinSampleSkyline()
        {
            string skylineSampleSQL = TestContext.DataRow["skylineSampleSQL"].ToString();
            string testComment      = TestContext.DataRow["comment"].ToString();
            int    expectedNumberOfSkylineSampleObjects =
                int.Parse(TestContext.DataRow["expectedNumberOfSkylineSampleObjects"].ToString());

            Debug.WriteLine(testComment);
            Debug.WriteLine(skylineSampleSQL);

            string baseQuery;
            string operators;
            int    numberOfRecords;

            string[] parameter;

            var common = new SQLCommon
            {
                SkylineType =
                    new SkylineBNL()
                {
                    Provider = Helper.ProviderName, ConnectionString = Helper.ConnectionString
                }
            };
            PrefSQLModel prefSqlModelSkylineSample = common.GetPrefSqlModelFromPreferenceSql(skylineSampleSQL);
            string       ansiSql = common.GetAnsiSqlFromPrefSqlModel(prefSqlModelSkylineSample);

            prefSQL.SQLParser.Helper.DetermineParameters(ansiSql, out parameter, out baseQuery, out operators,
                                                         out numberOfRecords);

            IEnumerable <CLRSafeHashSet <int> > useSubsets = UseSubsets(prefSqlModelSkylineSample);
            var subsetsProducer = new FixedSkylineSamplingSubsetsProducer(useSubsets);
            var utility         = new SkylineSamplingUtility(subsetsProducer);
            var skylineSample   = new SkylineSampling(utility)
            {
                SubsetCount      = prefSqlModelSkylineSample.SkylineSampleCount,
                SubsetDimension  = prefSqlModelSkylineSample.SkylineSampleDimension,
                SelectedStrategy = common.SkylineType
            };

            DataTable skyline = skylineSample.GetSkylineTable(baseQuery, operators);

            Assert.AreEqual(expectedNumberOfSkylineSampleObjects, skyline.Rows.Count,
                            "Unexpected number of Sample Skyline objects.");
        }
コード例 #6
0
        public void TestSamplingNumberOfObjectsWithinSampleSkyline()
        {
            string skylineSampleSQL = TestContext.DataRow["skylineSampleSQL"].ToString();
            string testComment = TestContext.DataRow["comment"].ToString();
            int expectedNumberOfSkylineSampleObjects =
                int.Parse(TestContext.DataRow["expectedNumberOfSkylineSampleObjects"].ToString());
            Debug.WriteLine(testComment);
            Debug.WriteLine(skylineSampleSQL);

            string baseQuery;
            string operators;
            int numberOfRecords;
            string[] parameter;

            var common = new SQLCommon
            {
                SkylineType =
                    new SkylineBNL() {Provider = Helper.ProviderName, ConnectionString = Helper.ConnectionString}
            };
            PrefSQLModel prefSqlModelSkylineSample = common.GetPrefSqlModelFromPreferenceSql(skylineSampleSQL);
            string ansiSql = common.GetAnsiSqlFromPrefSqlModel(prefSqlModelSkylineSample);

            prefSQL.SQLParser.Helper.DetermineParameters(ansiSql, out parameter, out baseQuery, out operators,
                out numberOfRecords);

            IEnumerable<CLRSafeHashSet<int>> useSubsets = UseSubsets(prefSqlModelSkylineSample);
            var subsetsProducer = new FixedSkylineSamplingSubsetsProducer(useSubsets);
            var utility = new SkylineSamplingUtility(subsetsProducer);
            var skylineSample = new SkylineSampling(utility)
            {
                SubsetCount = prefSqlModelSkylineSample.SkylineSampleCount,
                SubsetDimension = prefSqlModelSkylineSample.SkylineSampleDimension,
                SelectedStrategy = common.SkylineType
            };

            DataTable skyline = skylineSample.GetSkylineTable(baseQuery, operators);

            Assert.AreEqual(expectedNumberOfSkylineSampleObjects, skyline.Rows.Count,
                "Unexpected number of Sample Skyline objects.");
        }
コード例 #7
0
        public void TestSkylineAmountOfTupelsMSSQLCLR()
        {
            string skylineSampleSql = TestContext.DataRow["skylineSQL"].ToString();

            SQLCommon common = new SQLCommon();

            common.SkylineType = new SkylineSQL();
            PrefSQLModel model     = common.GetPrefSqlModelFromPreferenceSql(skylineSampleSql);
            string       sqlNative = common.GetAnsiSqlFromPrefSqlModel(model);

            common.SkylineType = new SkylineBNL();
            string sqlBNL = common.ParsePreferenceSQL(skylineSampleSql);

            common.SkylineType = new SkylineBNLSort();
            string sqlBNLSort = common.ParsePreferenceSQL(skylineSampleSql);

            common.SkylineType = new SkylineHexagon();
            string sqlHexagon = common.ParsePreferenceSQL(skylineSampleSql);

            //D&Q does not run with CLR
            common.SkylineType = new SkylineDQ();
            string sqlDQ = common.ParsePreferenceSQL(skylineSampleSql);

            int amountOfTupelsBNL     = 0;
            int amountOfTupelsBNLSort = 0;
            int amountOfTupelsSQL     = 0;
            int amountOfTupelsHexagon = 0;
            int amountOfTupelsDQ      = 0;

            SqlConnection cnnSQL = new SqlConnection(Helper.ConnectionString);

            cnnSQL.InfoMessage += cnnSQL_InfoMessage;
            try
            {
                cnnSQL.Open();

                //Native
                DbCommand command = cnnSQL.CreateCommand();
                command.CommandTimeout = 0; //infinite timeout
                command.CommandText    = sqlNative;
                DbDataReader sqlReader = command.ExecuteReader();

                if (sqlReader.HasRows)
                {
                    while (sqlReader.Read())
                    {
                        amountOfTupelsSQL++;
                    }
                }
                sqlReader.Close();

                //BNL
                command.CommandText = sqlBNL;
                sqlReader           = command.ExecuteReader();

                if (sqlReader.HasRows)
                {
                    while (sqlReader.Read())
                    {
                        amountOfTupelsBNL++;
                    }
                }
                sqlReader.Close();

                //BNLSort
                command.CommandText = sqlBNLSort;
                sqlReader           = command.ExecuteReader();

                if (sqlReader.HasRows)
                {
                    while (sqlReader.Read())
                    {
                        amountOfTupelsBNLSort++;
                    }
                }
                sqlReader.Close();


                //Hexagon
                command.CommandText = sqlHexagon;
                sqlReader           = command.ExecuteReader();

                if (sqlReader.HasRows)
                {
                    while (sqlReader.Read())
                    {
                        amountOfTupelsHexagon++;
                    }
                }
                sqlReader.Close();

                //D&Q (does not work with incomparable tuples)
                if (model.WithIncomparable == false)
                {
                    command.CommandText = sqlDQ;
                    sqlReader           = command.ExecuteReader();

                    if (sqlReader.HasRows)
                    {
                        while (sqlReader.Read())
                        {
                            amountOfTupelsDQ++;
                        }
                    }
                    sqlReader.Close();
                }

                cnnSQL.Close();
            }
            catch (Exception ex)
            {
                Assert.Fail("Connection failed:" + ex.Message);
            }

            int currentDataRowIndex = TestContext.DataRow.Table.Rows.IndexOf(TestContext.DataRow);

            //Check tuples (every algorithm should deliver the same amount of tuples)
            Assert.AreEqual(amountOfTupelsSQL, amountOfTupelsBNLSort, 0,
                            "BNLSort Amount of tupels in query " + currentDataRowIndex + " do not match");
            Assert.AreEqual(amountOfTupelsSQL, amountOfTupelsBNL, 0,
                            "BNL Amount of tupels in query " + currentDataRowIndex + " do not match");

            //Hexagon cannot handle Categorical preference that have no explicit OTHERS
            if (model.ContainsOpenPreference == false)
            {
                Assert.AreEqual(amountOfTupelsSQL, amountOfTupelsHexagon, 0,
                                "Hexagon Amount of tupels in query " + currentDataRowIndex + " do not match");
            }

            //D&Q does not work with incomparable tuples
            if (model.WithIncomparable == false)
            {
                Assert.AreEqual(amountOfTupelsSQL, amountOfTupelsDQ, 0,
                                "Amount of tupels in query " + currentDataRowIndex + " do not match");
            }
        }
コード例 #8
0
        private void TestForClusterAnalysis()
        {
            var common = new SQLCommon
            {
                SkylineType =
                    new SkylineBNL()
                {
                    Provider = Helper.ProviderName, ConnectionString = Helper.ConnectionString
                },
                ShowInternalAttributes = true
            };

            DbProviderFactory factory = DbProviderFactories.GetFactory(Helper.ProviderName);

            // use the factory object to create Data access objects.
            DbConnection connection = factory.CreateConnection();

            // will return the connection object (i.e. SqlConnection ...)
            connection.ConnectionString = Helper.ConnectionString;

            var dt = new DataTable();

            connection.Open();

            DbDataAdapter dap           = factory.CreateDataAdapter();
            DbCommand     selectCommand = connection.CreateCommand();

            selectCommand.CommandTimeout = 0; //infinite timeout

            string strQuery;
            string operators;
            int    numberOfRecords;

            string[] parameter;

            string ansiSql =
                common.GetAnsiSqlFromPrefSqlModel(common.GetPrefSqlModelFromPreferenceSql(_entireSkylineSql));

            prefSQL.SQLParser.Helper.DetermineParameters(ansiSql, out parameter, out strQuery, out operators,
                                                         out numberOfRecords);

            selectCommand.CommandText = strQuery;
            dap.SelectCommand         = selectCommand;
            dt = new DataTable();

            dap.Fill(dt);

            DataTable entireSkylineDataTable = common.ParseAndExecutePrefSQL(Helper.ConnectionString,
                                                                             Helper.ProviderName,
                                                                             _entireSkylineSql);

            int[] skylineAttributeColumns = SkylineSamplingHelper.GetSkylineAttributeColumns(entireSkylineDataTable);
            IReadOnlyDictionary <long, object[]> entireSkylineNormalized =
                prefSQL.SQLSkyline.Helper.GetDatabaseAccessibleByUniqueId(entireSkylineDataTable, 0);

            SkylineSamplingHelper.NormalizeColumns(entireSkylineNormalized, skylineAttributeColumns);

            DataTable sampleSkylineDataTable = common.ParseAndExecutePrefSQL(Helper.ConnectionString,
                                                                             Helper.ProviderName,
                                                                             _skylineSampleSql);
            IReadOnlyDictionary <long, object[]> sampleSkylineNormalized =
                prefSQL.SQLSkyline.Helper.GetDatabaseAccessibleByUniqueId(sampleSkylineDataTable, 0);

            SkylineSamplingHelper.NormalizeColumns(sampleSkylineNormalized, skylineAttributeColumns);

            for (var i = 0; i < skylineAttributeColumns.Length; i++)
            {
                dt.Columns.RemoveAt(0);
            }

            IReadOnlyDictionary <long, object[]> full = prefSQL.SQLSkyline.Helper.GetDatabaseAccessibleByUniqueId(dt, 0);

            SkylineSamplingHelper.NormalizeColumns(full, skylineAttributeColumns);

            ClusterAnalysis.CalcMedians(full, skylineAttributeColumns);

            IReadOnlyDictionary <BigInteger, List <IReadOnlyDictionary <long, object[]> > > entireBuckets =
                ClusterAnalysis.GetBuckets(entireSkylineNormalized, skylineAttributeColumns);
            IReadOnlyDictionary <BigInteger, List <IReadOnlyDictionary <long, object[]> > > sampleBuckets =
                ClusterAnalysis.GetBuckets(sampleSkylineNormalized, skylineAttributeColumns);

            //IReadOnlyDictionary<int, List<IReadOnlyDictionary<long, object[]>>> aggregatedEntireBuckets =
            //    ClusterAnalysis.GetAggregatedBuckets(entireBuckets);
            //IReadOnlyDictionary<int, List<IReadOnlyDictionary<long, object[]>>> aggregatedSampleBuckets =
            //    ClusterAnalysis.GetAggregatedBuckets(sampleBuckets);

            IReadOnlyDictionary <BigInteger, List <IReadOnlyDictionary <long, object[]> > > fullB =
                ClusterAnalysis.GetBuckets(full, skylineAttributeColumns);
            // IReadOnlyDictionary<int, List<IReadOnlyDictionary<long, object[]>>> aFullB =
            //     ClusterAnalysis.GetAggregatedBuckets(fullB);

            IOrderedEnumerable <KeyValuePair <BigInteger, List <IReadOnlyDictionary <long, object[]> > > > sorted = fullB.OrderBy(l => l.Value.Count)
                                                                                                                    .ThenBy(l => l.Key);

            int len = Convert.ToInt32(Math.Pow(2, skylineAttributeColumns.Length));

            //for (var i = 0; i < len; i++)
            foreach (KeyValuePair <BigInteger, List <IReadOnlyDictionary <long, object[]> > > s in sorted)
            {
                BigInteger i             = s.Key;
                int        entire        = entireBuckets.ContainsKey(i) ? entireBuckets[i].Count : 0;
                int        sample        = sampleBuckets.ContainsKey(i) ? sampleBuckets[i].Count : 0;
                double     entirePercent = (double)entire / entireSkylineNormalized.Count;
                double     samplePercent = (double)sample / sampleSkylineNormalized.Count;
                int        fullX         = fullB.ContainsKey(i) ? fullB[i].Count : 0;
                double     fullP         = (double)fullX / full.Count;
                Console.WriteLine("-- {0,5} -- {5,6} ({6,7:P2} %) -- {1,6} ({3,7:P2} %) -- {2,6} ({4,7:P2} %)", i,
                                  entire, sample, entirePercent,
                                  samplePercent, fullX, fullP);
            }

            Console.WriteLine();
            Console.WriteLine("{0} - {1} - {2}", entireSkylineNormalized.Count, sampleSkylineNormalized.Count,
                              full.Count);
        }
コード例 #9
0
        private void TestForDominatedObjects()
        {
            var common = new SQLCommon
            {
                SkylineType =
                    new SkylineBNL()
                {
                    Provider = Helper.ProviderName, ConnectionString = Helper.ConnectionString
                },
                ShowInternalAttributes = true
            };

            DataTable entireSkylineDataTable =
                common.ParseAndExecutePrefSQL(Helper.ConnectionString, Helper.ProviderName,
                                              _entireSkylineSql);

            int[] skylineAttributeColumns =
                SkylineSamplingHelper.GetSkylineAttributeColumns(entireSkylineDataTable);

            DbProviderFactory factory = DbProviderFactories.GetFactory(Helper.ProviderName);

            // use the factory object to create Data access objects.
            DbConnection connection = factory.CreateConnection();

            // will return the connection object (i.e. SqlConnection ...)
            connection.ConnectionString = Helper.ConnectionString;

            var dtEntire = new DataTable();

            connection.Open();

            DbDataAdapter dap           = factory.CreateDataAdapter();
            DbCommand     selectCommand = connection.CreateCommand();

            selectCommand.CommandTimeout = 0; //infinite timeout

            string strQueryEntire;
            string operatorsEntire;
            int    numberOfRecordsEntire;

            string[] parameterEntire;

            string ansiSqlEntire =
                common.GetAnsiSqlFromPrefSqlModel(
                    common.GetPrefSqlModelFromPreferenceSql(_entireSkylineSql));

            prefSQL.SQLParser.Helper.DetermineParameters(ansiSqlEntire, out parameterEntire,
                                                         out strQueryEntire, out operatorsEntire,
                                                         out numberOfRecordsEntire);

            selectCommand.CommandText = strQueryEntire;
            dap.SelectCommand         = selectCommand;
            dtEntire = new DataTable();

            dap.Fill(dtEntire);

            for (var ii = 0; ii < skylineAttributeColumns.Length; ii++)
            {
                dtEntire.Columns.RemoveAt(0);
            }

            DataTable sampleSkylineDataTable = common.ParseAndExecutePrefSQL(Helper.ConnectionString,
                                                                             Helper.ProviderName,
                                                                             _skylineSampleSql);

            DataTable entireSkylineDataTableBestRank = common.ParseAndExecutePrefSQL(Helper.ConnectionString,
                                                                                     Helper.ProviderName,
                                                                                     _entireSkylineSqlBestRank.Replace("XXX", sampleSkylineDataTable.Rows.Count.ToString()));
            DataTable entireSkylineDataTableSumRank = common.ParseAndExecutePrefSQL(Helper.ConnectionString,
                                                                                    Helper.ProviderName,
                                                                                    _entireSkylineSqlSumRank.Replace("XXX", sampleSkylineDataTable.Rows.Count.ToString()));

            IReadOnlyDictionary <long, object[]> sampleSkylineDatabase =
                prefSQL.SQLSkyline.Helper.GetDatabaseAccessibleByUniqueId(sampleSkylineDataTable, 0);
            IReadOnlyDictionary <long, object[]> entireDatabase =
                prefSQL.SQLSkyline.Helper.GetDatabaseAccessibleByUniqueId(dtEntire, 0);
            IReadOnlyDictionary <long, object[]> entireSkylineDatabase =
                prefSQL.SQLSkyline.Helper.GetDatabaseAccessibleByUniqueId(entireSkylineDataTable, 0);
            IReadOnlyDictionary <long, object[]> entireSkylineDatabaseBestRank =
                prefSQL.SQLSkyline.Helper.GetDatabaseAccessibleByUniqueId(entireSkylineDataTableBestRank, 0);
            IReadOnlyDictionary <long, object[]> entireSkylineDatabaseSumRank =
                prefSQL.SQLSkyline.Helper.GetDatabaseAccessibleByUniqueId(entireSkylineDataTableSumRank, 0);
            IReadOnlyDictionary <long, object[]> randomSample =
                SkylineSamplingHelper.GetRandomSample(entireSkylineDatabase, sampleSkylineDataTable.Rows.Count);

            var dominatedObjectsEntireSkyline = new DominatedObjects(entireDatabase, entireSkylineDatabase,
                                                                     skylineAttributeColumns);
            var dominatedObjectsSampleSkyline = new DominatedObjects(entireDatabase, sampleSkylineDatabase,
                                                                     skylineAttributeColumns);
            var dominatedObjectsEntireSkylineBestRank = new DominatedObjects(entireDatabase,
                                                                             entireSkylineDatabaseBestRank, skylineAttributeColumns);
            var dominatedObjectsEntireSkylineSumRank = new DominatedObjects(entireDatabase, entireSkylineDatabaseSumRank,
                                                                            skylineAttributeColumns);
            var dominatedObjectsRandomSample = new DominatedObjects(entireDatabase, randomSample,
                                                                    skylineAttributeColumns);

            Debug.WriteLine("entire database size: {0}", entireDatabase.Keys.ToList().Count);
            Debug.WriteLine("entire skyline size: {0}", entireSkylineDataTable.Rows.Count);
            Debug.WriteLine("sample skyline size: {0}", sampleSkylineDatabase.Keys.ToList().Count);
            Debug.WriteLine("random skyline size: {0}", randomSample.Keys.ToList().Count);
            Debug.WriteLine("best skyline size: {0}", entireSkylineDatabaseBestRank.Keys.ToList().Count);
            Debug.WriteLine("sum skyline size: {0}", entireSkylineDatabaseSumRank.Keys.ToList().Count);
            Debug.WriteLine("");
            Debug.WriteLine("");

            WriteSummary("entire", dominatedObjectsEntireSkyline);
            WriteSummary("sample", dominatedObjectsSampleSkyline);
            WriteSummary("random", dominatedObjectsRandomSample);
            WriteSummary("best", dominatedObjectsEntireSkylineBestRank);
            WriteSummary("sum", dominatedObjectsEntireSkylineSumRank);

            WriteDominatingObjects("entire", dominatedObjectsEntireSkyline);
            WriteDominatingObjects("sample", dominatedObjectsSampleSkyline);
            WriteDominatingObjects("random", dominatedObjectsRandomSample);
            WriteDominatingObjects("best", dominatedObjectsEntireSkylineBestRank);
            WriteDominatingObjects("sum", dominatedObjectsEntireSkylineSumRank);
        }
コード例 #10
0
        public void TestSamplingOnlyNonDominatedObjectsWithinSampleSkyline()
        {
            string skylineSampleSql = TestContext.DataRow["skylineSampleSQL"].ToString();
            string entireSkylineSql = TestContext.DataRow["entireSkylineSQL"].ToString();
            string testComment = TestContext.DataRow["comment"].ToString();
            Debug.WriteLine(testComment);
            Debug.WriteLine(skylineSampleSql);

            string baseQuery;
            string operators;
            int numberOfRecords;
            string[] parameter;

            var common = new SQLCommon
            {
                SkylineType =
                    new SkylineBNL() { Provider = Helper.ProviderName, ConnectionString = Helper.ConnectionString }
            };

            PrefSQLModel prefSqlModelSkylineSample = common.GetPrefSqlModelFromPreferenceSql(skylineSampleSql);
            string ansiSql = common.GetAnsiSqlFromPrefSqlModel(prefSqlModelSkylineSample);

            prefSQL.SQLParser.Helper.DetermineParameters(ansiSql, out parameter, out baseQuery, out operators,
                out numberOfRecords);

            IEnumerable<CLRSafeHashSet<int>> useSubsets = UseSubsets(prefSqlModelSkylineSample);
            var subsetsProducer = new FixedSkylineSamplingSubsetsProducer(useSubsets);
            var utility = new SkylineSamplingUtility(subsetsProducer);
            var skylineSample = new SkylineSampling(utility)
            {
                SubsetCount = prefSqlModelSkylineSample.SkylineSampleCount,
                SubsetDimension = prefSqlModelSkylineSample.SkylineSampleDimension,
                SelectedStrategy = common.SkylineType
            };

            DataTable entireSkyline = common.ParseAndExecutePrefSQL(Helper.ConnectionString, Helper.ProviderName,
                entireSkylineSql);
            DataTable sampleSkyline = skylineSample.GetSkylineTable(baseQuery, operators);

            HashSet<int> entireSkylineObjectsIds = GetHashSetOfIdsFromDataTable(entireSkyline);
            HashSet<int> sampleSkylineObjectsIds = GetHashSetOfIdsFromDataTable(sampleSkyline);

            sampleSkylineObjectsIds.ExceptWith(entireSkylineObjectsIds);

            Debug.WriteLine("wrong objects:");
            foreach (int i in sampleSkylineObjectsIds)
            {
                Debug.WriteLine(i);
            }

            Assert.IsTrue(sampleSkylineObjectsIds.IsSubsetOf(entireSkylineObjectsIds),
                "Dominated objects contained in Sample Skyline (i.e., objects which are not contained in the entire Skyline).");
        }