Example #1
0
        /// <summary>
        /// Returns XML string with all occurences of Active element "SD-KL hypothesis".
        /// </summary>
        /// <param name="index">index of data source in FEplugin data sources table</param>
        /// <returns>XML string</returns>
        public static string getList(int index)
        {
            string resultString = ""; // result XML string

            // loading DTD to resultString
            try { resultString = XMLHelper.loadDTD(); }
            catch (Exception e)
            {
#if (LADENI)
                MessageBox.Show("error while loading DTD: " + e.Message);
#endif
                return(resultString);
            }

            // root element
            resultString += "<active_list>";

            string PropName = "Hypotheses";  // name of property which contain a list of hypotheses
            // searching all boxes SD-KL-tasks
            IBoxModule[] TaskBoxes = BoxesHelper.ListBoxesWithID(CFEsourcesTab.Sources[index] as CFEsource, "LISpMinerTasks.SDKLTask");

            // processing of each box -  searching all KL-hypotheses
            string ErrStr = "";             // error report

            string matrix_name = "unknown"; // analyzed data matrix name
            string db_name     = "unknown"; // analyzed database name
            string task_name   = "unknown"; // task name - given with user name of box FFTTast

            // creatind delegates for functions of quantifiers
            // "sum of values"
            ContingencyTable.QuantifierValue <TwoDimensionalContingencyTable> sum_delegat = new ContingencyTable.QuantifierValue <TwoDimensionalContingencyTable>(TwoDimensionalContingencyTable.GetSumOfValues);
            // "min value"
            ContingencyTable.QuantifierValue <TwoDimensionalContingencyTable> min_delegat = new ContingencyTable.QuantifierValue <TwoDimensionalContingencyTable>(TwoDimensionalContingencyTable.GetMinValue);
            // "max value"
            ContingencyTable.QuantifierValue <TwoDimensionalContingencyTable> max_delegat = new ContingencyTable.QuantifierValue <TwoDimensionalContingencyTable>(TwoDimensionalContingencyTable.GetMaxValue);



            #region Loop - processing of each KL-Task from array TaskBoxes

            foreach (IBoxModule box in TaskBoxes)
            {
                try
                {
                    // searching data source name (database)
                    IBoxModule[] db_names = BoxesHelper.ListAncestBoxesWithID(box, "DataMiningCommon.Database");
                    if (db_names.GetLength(0) != 1)  // searched more than one data source or neither one
                    {
                        throw new System.Exception("found " + db_names.GetLength(0).ToString() + " databases");
                    }
                    db_name = (db_names[0].GetPropertyOther("DatabaseName") as StringT).stringValue;

                    // searching data matrix name
                    IBoxModule[] matrix_names = BoxesHelper.ListAncestBoxesWithID(box, "DataMiningCommon.DataMatrix");
                    if (matrix_names.GetLength(0) != 1)  // searched more than one data source or neither one
                    {
                        throw new System.Exception("found " + matrix_names.GetLength(0).ToString() + " data matrixes");
                    }
                    matrix_name = (matrix_names[0].GetPropertyOther("Name") as StringT).stringValue;

                    // searching task name
                    task_name = box.UserName;

                    // searching the list of all hypotheses in this task
                    HypothesesT        HypT    = box.GetPropertyOther(PropName) as HypothesesT;
                    HypothesisStruct[] HypList = HypT.hypothesesValue.Clone() as HypothesisStruct[];

                    // records for storing the results
                    Rec_hyp_SDKL     rHyp  = new Rec_hyp_SDKL();     // SD-KL hypothesis
                    Rec_ti_attribute rAnt  = new Rec_ti_attribute(); // Antecedent (Row attributes)
                    Rec_ti_attribute rSuc  = new Rec_ti_attribute(); // Succedent (Column attributes)
                    Rec_ti_cedent    rCon  = new Rec_ti_cedent();    // condition
                    Rec_ti_cedent    rSet1 = new Rec_ti_cedent();    // set 1
                    Rec_ti_cedent    rSet2 = new Rec_ti_cedent();    // set 2


                    #region Loop - processing of each hypotheses jedne krabicky SDKLTask
                    // Loop over all hypotheses
                    for (int i = 0; i < HypList.GetLength(0); i++)
                    {
                        #region element hyp_SDKL

                        rHyp.id                = "hypSDKL" + box.ProjectIdentifier.ToString() + "_" + i.ToString();
                        rHyp.db_name           = db_name;
                        rHyp.matrix_name       = matrix_name;
                        rHyp.task_name         = task_name;
                        rHyp.row_attributes    = "r_attr" + rHyp.id;
                        rHyp.column_attributes = "c_attr" + rHyp.id;
                        rHyp.condition         = "con" + rHyp.id;
                        rHyp.set1              = "set1" + rHyp.id;
                        rHyp.set2              = "set2" + rHyp.id;
                        TwoDimensionalContingencyTable CT1 = new TwoDimensionalContingencyTable(HypList[i].quantifierSetting.firstContingencyTableRows);  // Contingency Table 1
                        TwoDimensionalContingencyTable CT2 = new TwoDimensionalContingencyTable(HypList[i].quantifierSetting.secondContingencyTableRows); // Contingency Table 2
                        rHyp.Tab1 = HypList[i].quantifierSetting.firstContingencyTableRows;
                        rHyp.Tab2 = HypList[i].quantifierSetting.secondContingencyTableRows;


                        // values of quantifiers - set1
                        try
                        {
                            rHyp.sum1    = CT1.SumOfValues.ToString();
                            rHyp.min1    = CT1.MinValue.ToString();
                            rHyp.max1    = CT1.MaxValue.ToString();
                            rHyp.chi_sq1 = TwoDimensionalContingencyTable.ChiSquare(CT1).ToString();
                            rHyp.fnc_s1  = TwoDimensionalContingencyTable.SumOfRowMaximumsValue(CT1).ToString();
                            rHyp.fnc_r1  = TwoDimensionalContingencyTable.MinOfRowMaximumsValue(CT1).ToString();
                            rHyp.h_c1    = CT1.MarginalColumnEntropy.ToString();
                            rHyp.h_r1    = CT1.MarginalRowEntropy.ToString();
                            rHyp.h_c_r1  = TwoDimensionalContingencyTable.ConditionalCREntropyValue(CT1).ToString();
                            rHyp.mi1     = CT1.MutualInformation.ToString();
                            //rHyp.aic = CT.???;  TODO
                            rHyp.kend1 = TwoDimensionalContingencyTable.KendalValue(CT1).ToString();
                        }
                        catch (System.Exception e) // TODO: Ferda ma chyby ve vypoctech -> opravit!
                        {
                            ErrStr += "Box ProjectIdentifier=" + box.ProjectIdentifier.ToString() + ": chyba pri vypoctu quantifier: " + e.Message + "\n";
                        }
                        // values of quantifiers - set2
                        try
                        {
                            rHyp.sum2    = CT2.SumOfValues.ToString();
                            rHyp.min2    = CT2.MinValue.ToString();
                            rHyp.max2    = CT2.MaxValue.ToString();
                            rHyp.chi_sq2 = TwoDimensionalContingencyTable.ChiSquare(CT2).ToString();
                            rHyp.fnc_s2  = TwoDimensionalContingencyTable.SumOfRowMaximumsValue(CT2).ToString();
                            rHyp.fnc_r2  = TwoDimensionalContingencyTable.MinOfRowMaximumsValue(CT2).ToString();
                            rHyp.h_c2    = CT2.MarginalColumnEntropy.ToString();
                            rHyp.h_r2    = CT2.MarginalRowEntropy.ToString();
                            rHyp.h_c_r2  = TwoDimensionalContingencyTable.ConditionalCREntropyValue(CT2).ToString();
                            rHyp.mi2     = CT2.MutualInformation.ToString();
                            //rHyp.aic = CT.???;  TODO
                            rHyp.kend2 = TwoDimensionalContingencyTable.KendalValue(CT2).ToString();
                        }
                        catch (System.Exception e) // Ferda ma chyby ve vypoctech!
                        {
                            ErrStr += "Box ProjectIdentifier=" + box.ProjectIdentifier.ToString() + ": chyba pri vypoctu quantifier: " + e.Message + "\n";
                        }
                        // values of quantifiers - diffrent of set1 a set2
                        try
                        {
                            rHyp.da_sum = TwoDimensionalContingencyTable.Value <TwoDimensionalContingencyTable>(sum_delegat, CT1, CT2, OperationModeEnum.DifferencesOfAbsoluteFrequencies).ToString();
                            rHyp.da_min = TwoDimensionalContingencyTable.Value <TwoDimensionalContingencyTable>(min_delegat, CT1, CT2, OperationModeEnum.DifferencesOfAbsoluteFrequencies).ToString();
                            rHyp.da_max = TwoDimensionalContingencyTable.Value <TwoDimensionalContingencyTable>(max_delegat, CT1, CT2, OperationModeEnum.DifferencesOfAbsoluteFrequencies).ToString();
                            rHyp.dr_sum = TwoDimensionalContingencyTable.Value <TwoDimensionalContingencyTable>(sum_delegat, CT1, CT2, OperationModeEnum.DifferencesOfRelativeFrequencies).ToString();
                            rHyp.dr_min = TwoDimensionalContingencyTable.Value <TwoDimensionalContingencyTable>(min_delegat, CT1, CT2, OperationModeEnum.DifferencesOfRelativeFrequencies).ToString();
                            rHyp.dr_max = TwoDimensionalContingencyTable.Value <TwoDimensionalContingencyTable>(max_delegat, CT1, CT2, OperationModeEnum.DifferencesOfRelativeFrequencies).ToString();
                        }
                        catch (System.Exception e) // Ferda ma chyby ve vypoctech!
                        {
                            ErrStr += "Box ProjectIdentifier=" + box.ProjectIdentifier.ToString() + ": chyba pri vypoctu quantifier: " + e.Message + "\n";
                        }



                        #endregion

                        #region element ti_attribute Row attributes (Antecedent)

                        rAnt.id    = rHyp.row_attributes;
                        rAnt.type  = "Row attributes";
                        rAnt.quant = "";   // deleting previous value
                        // category
                        List <Rec_ti_category> Cat_a = new List <Rec_ti_category>();
                        foreach (LiteralStruct lit in HypList[i].literals)
                        {
                            if (lit.cedentType == CedentEnum.Antecedent)
                            {
                                rAnt.quant += lit.literalName;
                                foreach (string s in lit.categoriesNames)
                                {
                                    Rec_ti_category C = new Rec_ti_category();
                                    C.value = s;
                                    Cat_a.Add(C);
                                }
                            }
                        }

                        #endregion

                        #region element ti_attribute Column attributes (Succedent)

                        rSuc.id    = rHyp.column_attributes;
                        rSuc.type  = "Column attributes";
                        rSuc.quant = "";   // deleting previous value
                        // category
                        List <Rec_ti_category> Cat_s = new List <Rec_ti_category>();
                        foreach (LiteralStruct lit in HypList[i].literals)
                        {
                            if (lit.cedentType == CedentEnum.Succedent)
                            {
                                rSuc.quant += lit.literalName;
                                foreach (string s in lit.categoriesNames)
                                {
                                    Rec_ti_category C = new Rec_ti_category();
                                    C.value = s;
                                    Cat_s.Add(C);
                                }
                            }
                        }

                        #endregion

                        #region element ti_cedent (Condition)

                        rCon.id   = "con" + rHyp.id;
                        rCon.type = "Condition";
                        // literals
                        int litCounter = 0;  // counter of literals of this hypothesis
                        List <Rec_ti_literal> Lit_c = new List <Rec_ti_literal>();
                        foreach (BooleanLiteralStruct lit in HypList[i].booleanLiterals)
                        {
                            if (lit.cedentType == CedentEnum.Condition)
                            {
                                Rec_ti_literal l = new Rec_ti_literal();
                                l.id = "tiLit" + rHyp.id + "_" + litCounter.ToString();
                                litCounter++;
                                if (lit.negation)
                                {
                                    l.quant = "¬";
                                }
                                l.quant += lit.literalName;
                                int counter = 0;
                                foreach (string s in lit.categoriesNames)
                                {
                                    if (counter > 0)
                                    {
                                        l.value += ",";
                                    }
                                    l.value += s;
                                    counter++;
                                }
                                Lit_c.Add(l);
                            }
                        }

                        #endregion

                        #region element ti_cedent (Set1)

                        rSet1.id   = rHyp.set1;
                        rSet1.type = "First Set";
                        // literals
                        List <Rec_ti_literal> Lit_s1 = new List <Rec_ti_literal>();
                        foreach (BooleanLiteralStruct lit in HypList[i].booleanLiterals)
                        {
                            if (lit.cedentType == CedentEnum.FirstSet)
                            {
                                Rec_ti_literal l = new Rec_ti_literal();
                                l.id = "tiLit" + rHyp.id + "_" + litCounter.ToString();
                                litCounter++;
                                if (lit.negation)
                                {
                                    l.quant = "¬";
                                }
                                l.quant += lit.literalName;
                                int counter = 0;
                                foreach (string s in lit.categoriesNames)
                                {
                                    if (counter > 0)
                                    {
                                        l.value += ",";
                                    }
                                    l.value += s;
                                    counter++;
                                }
                                Lit_s1.Add(l);
                            }
                        }

                        #endregion

                        #region element ti_cedent (Set2)

                        rSet2.id   = rHyp.set2;
                        rSet2.type = "Second Set";
                        // literals
                        List <Rec_ti_literal> Lit_s2 = new List <Rec_ti_literal>();
                        foreach (BooleanLiteralStruct lit in HypList[i].booleanLiterals)
                        {
                            if (lit.cedentType == CedentEnum.SecondSet)
                            {
                                Rec_ti_literal l = new Rec_ti_literal();
                                l.id = "tiLit" + rHyp.id + "_" + litCounter.ToString();
                                litCounter++;
                                if (lit.negation)
                                {
                                    l.quant = "¬";
                                }
                                l.quant += lit.literalName;
                                int counter = 0;
                                foreach (string s in lit.categoriesNames)
                                {
                                    if (counter > 0)
                                    {
                                        l.value += ",";
                                    }
                                    l.value += s;
                                    counter++;
                                }
                                Lit_s2.Add(l);
                            }
                        }

                        #endregion


                        #region Generating of one hypothesis to XML string

                        string oneHypString = "";
                        // generating hypotheses to XML
                        oneHypString += rHyp.ToXML();
                        // generating Row attributes (Antecedent) to XML
                        oneHypString += rAnt.ToXML(Cat_a);
                        // generating Column attributes (Succedent) to XML
                        oneHypString += rSuc.ToXML(Cat_s);
                        // generating Condition to XML
                        oneHypString += rCon.ToXML(Lit_c);
                        // generating Set1 to XML
                        oneHypString += rSet1.ToXML(Lit_s1);
                        // generating Set2 to XML
                        oneHypString += rSet2.ToXML(Lit_s2);



                        resultString += oneHypString;

                        #endregion
                    }
                    #endregion
                }
                catch (System.Exception e)
                {
                    ErrStr += "Box ProjectIdentifier=" + box.ProjectIdentifier.ToString() + ": " + e.Message + "\n";
                }
            }
            #endregion


            // root element
            resultString += "</active_list>";

#if (LADENI)
            // generating of error message:
            if (!String.IsNullOrEmpty(ErrStr))  // LADICI
            {
                MessageBox.Show("Pri nacitani SD-KL hypotheses doslo k chybam:\n" + ErrStr, "Chyba", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            // LADICI - Kody - storing output to file "XMLsd4fthypExample.xml" in directory
            XMLHelper.saveXMLexample(resultString, "../XML/XMLsdKLhypExample.xml");
#endif

            return(resultString);
        }
Example #2
0
        /// <summary>
        /// Returns XML string with all occurences of Active element "SD-CF hypothesis".
        /// </summary>
        /// <param name="index">index of data source in FEplugin data sources table</param>
        /// <returns>XML string</returns>
        public static string getList(int index)
        {
            string resultString = ""; // result XML string

            // loading DTD to resultString
            try { resultString = XMLHelper.loadDTD(); }
            catch (Exception e)
            {
#if (LADENI)
                MessageBox.Show("error while loading DTD: " + e.Message);
#endif
                return(resultString);
            }

            // root element
            resultString += "<active_list>";

            string PropName = "Hypotheses";  // name of property which contain a list of hypotheses
            // searching all boxes CF-task
            IBoxModule[] TaskBoxes = BoxesHelper.ListBoxesWithID(CFEsourcesTab.Sources[index] as CFEsource, "LISpMinerTasks.SDCFTask");

            // processing of each box - searching all CF-hypotheses
            string ErrStr = "";             // error report

            string matrix_name = "unknown"; // analyzed data matrix name
            string db_name     = "unknown"; // analyzed database name
            string task_name   = "unknown"; // task name - given with user name of box FFTTast

            // creating delegates of quantifier functions
            // "sum of values"
            ContingencyTable.QuantifierValue <OneDimensionalContingencyTable> sum_delegat = new ContingencyTable.QuantifierValue <OneDimensionalContingencyTable>(OneDimensionalContingencyTable.GetSumOfValues);
            // "min value"
            ContingencyTable.QuantifierValue <OneDimensionalContingencyTable> min_delegat = new ContingencyTable.QuantifierValue <OneDimensionalContingencyTable>(OneDimensionalContingencyTable.GetMinValue);
            // "max value"
            ContingencyTable.QuantifierValue <OneDimensionalContingencyTable> max_delegat = new ContingencyTable.QuantifierValue <OneDimensionalContingencyTable>(OneDimensionalContingencyTable.GetMaxValue);



            #region Loop - processing of each CF-Task from array TaskBoxes

            foreach (IBoxModule box in TaskBoxes)
            {
                try
                {
                    // searching data source name (database)
                    IBoxModule[] db_names = BoxesHelper.ListAncestBoxesWithID(box, "DataMiningCommon.Database");
                    if (db_names.GetLength(0) != 1)  // searched more than one data source or neither one
                    {
                        throw new System.Exception("found " + db_names.GetLength(0).ToString() + " databases");
                    }
                    db_name = (db_names[0].GetPropertyOther("DatabaseName") as StringT).stringValue;

                    // searching data matrix name
                    IBoxModule[] matrix_names = BoxesHelper.ListAncestBoxesWithID(box, "DataMiningCommon.DataMatrix");
                    if (matrix_names.GetLength(0) != 1)  // searched more than one data source or neither one
                    {
                        throw new System.Exception("found " + matrix_names.GetLength(0).ToString() + " data matrixes");
                    }
                    matrix_name = (matrix_names[0].GetPropertyOther("Name") as StringT).stringValue;

                    // searching task name
                    task_name = box.UserName;

                    // searching the list of all hypotheses in this task
                    HypothesesT        HypT    = box.GetPropertyOther(PropName) as HypothesesT;
                    HypothesisStruct[] HypList = HypT.hypothesesValue.Clone() as HypothesisStruct[];

                    // records for storing the results
                    Rec_hyp_sdcf     rHyp  = new Rec_hyp_sdcf();     // CF hypothesis
                    Rec_ti_attribute rAnt  = new Rec_ti_attribute(); // Antecedent (Attributes)
                    Rec_ti_cedent    rCon  = new Rec_ti_cedent();    // Condition
                    Rec_ti_cedent    rSet1 = new Rec_ti_cedent();    // set 1
                    Rec_ti_cedent    rSet2 = new Rec_ti_cedent();    // set 2


                    #region Loop - processing of each hypotheses jedne krabicky CFTask
                    // Loop over all hypotheses
                    for (int i = 0; i < HypList.GetLength(0); i++)
                    {
                        #region element hyp_sdcf

                        rHyp.id          = "hypsdcf" + box.ProjectIdentifier.ToString() + "_" + i.ToString();
                        rHyp.db_name     = db_name;
                        rHyp.matrix_name = matrix_name;
                        rHyp.task_name   = task_name;
                        rHyp.attributes  = "attr" + rHyp.id;
                        rHyp.condition   = "con" + rHyp.id;
                        rHyp.set1        = "set1" + rHyp.id;
                        rHyp.set2        = "set2" + rHyp.id;

                        OneDimensionalContingencyTable CT1 = new OneDimensionalContingencyTable(HypList[i].quantifierSetting.firstContingencyTableRows);  // Contingency Table 1
                        OneDimensionalContingencyTable CT2 = new OneDimensionalContingencyTable(HypList[i].quantifierSetting.secondContingencyTableRows); // Contingency Table 2
                        rHyp.Tab1 = HypList[i].quantifierSetting.firstContingencyTableRows[0];
                        rHyp.Tab2 = HypList[i].quantifierSetting.secondContingencyTableRows[0];


                        // values of quantifiers - set1
                        try
                        {
                            rHyp.sum1     = CT1.SumOfValues.ToString();
                            rHyp.min1     = CT1.MinValue.ToString();
                            rHyp.max1     = CT1.MaxValue.ToString();
                            rHyp.v1       = CT1.VariationRatio.ToString();
                            rHyp.nom_var1 = CT1.NominalVariation.ToString();
                            rHyp.dor_var1 = CT1.DiscreteOrdinaryVariation.ToString();
                            rHyp.avg_a1   = CT1.ArithmeticAverage.ToString();
                            rHyp.avg_g1   = CT1.GeometricAverage.ToString();
                            rHyp.var1     = CT1.Variance.ToString();
                            rHyp.st_dev1  = CT1.StandardDeviation.ToString();
                            rHyp.skew1    = CT1.Skewness.ToString();
                            rHyp.asym1    = CT1.Asymentry.ToString();
                        }
                        catch (System.Exception e) // !Ferda has errors in quantifier values!!
                        {
                            ErrStr += "Box ProjectIdentifier=" + box.ProjectIdentifier.ToString() + ": chyba pri vypoctu kvantifikatoru: " + e.Message + "\n";
                        }

                        // values of quantifiers - set2
                        try
                        {
                            rHyp.sum2     = CT2.SumOfValues.ToString();
                            rHyp.min2     = CT2.MinValue.ToString();
                            rHyp.max2     = CT2.MaxValue.ToString();
                            rHyp.v2       = CT2.VariationRatio.ToString();
                            rHyp.nom_var2 = CT2.NominalVariation.ToString();
                            rHyp.dor_var2 = CT2.DiscreteOrdinaryVariation.ToString();
                            rHyp.avg_a2   = CT2.ArithmeticAverage.ToString();
                            rHyp.avg_g2   = CT2.GeometricAverage.ToString();
                            rHyp.var2     = CT2.Variance.ToString();
                            rHyp.st_dev2  = CT2.StandardDeviation.ToString();
                            rHyp.skew2    = CT2.Skewness.ToString();
                            rHyp.asym2    = CT2.Asymentry.ToString();
                        }
                        catch (System.Exception e) // !Ferda has errors in quantifier values!!
                        {
                            ErrStr += "Box ProjectIdentifier=" + box.ProjectIdentifier.ToString() + ": chyba pri vypoctu kvantifikatoru: " + e.Message + "\n";
                        }

                        // values of quantifiers - diffrent of set1 a set2
                        try
                        {
                            rHyp.da_sum = OneDimensionalContingencyTable.Value <OneDimensionalContingencyTable>(sum_delegat, CT1, CT2, OperationModeEnum.DifferencesOfAbsoluteFrequencies).ToString();
                            rHyp.da_min = OneDimensionalContingencyTable.Value <OneDimensionalContingencyTable>(min_delegat, CT1, CT2, OperationModeEnum.DifferencesOfAbsoluteFrequencies).ToString();
                            rHyp.da_max = OneDimensionalContingencyTable.Value <OneDimensionalContingencyTable>(max_delegat, CT1, CT2, OperationModeEnum.DifferencesOfAbsoluteFrequencies).ToString();
                            rHyp.dr_sum = OneDimensionalContingencyTable.Value <OneDimensionalContingencyTable>(sum_delegat, CT1, CT2, OperationModeEnum.DifferencesOfRelativeFrequencies).ToString();
                            rHyp.dr_min = OneDimensionalContingencyTable.Value <OneDimensionalContingencyTable>(min_delegat, CT1, CT2, OperationModeEnum.DifferencesOfRelativeFrequencies).ToString();
                            rHyp.dr_max = OneDimensionalContingencyTable.Value <OneDimensionalContingencyTable>(max_delegat, CT1, CT2, OperationModeEnum.DifferencesOfRelativeFrequencies).ToString();
                        }
                        catch (System.Exception e) // !Ferda has errors in quantifier values!!
                        {
                            ErrStr += "Box ProjectIdentifier=" + box.ProjectIdentifier.ToString() + ": chyba pri vypoctu kvantifikatoru: " + e.Message + "\n";
                        }



                        #endregion

                        #region element ti_attribute  Attributes (Antecedent)

                        rAnt.id    = rHyp.attributes;
                        rAnt.type  = "Attributes";
                        rAnt.quant = "";   // deleting previous value
                        // category
                        List <Rec_ti_category> Cat_a = new List <Rec_ti_category>();
                        foreach (LiteralStruct lit in HypList[i].literals)
                        {
                            if (lit.cedentType == CedentEnum.Antecedent)
                            {
                                rAnt.quant += lit.literalName;
                                foreach (string s in lit.categoriesNames)
                                {
                                    Rec_ti_category C = new Rec_ti_category();
                                    C.value = s;
                                    Cat_a.Add(C);
                                }
                            }
                        }

                        #endregion

                        #region element ti_cedent (Condition)

                        int litCounter = 0;  // counter of literals of this cedent
                        rCon.id   = "con" + rHyp.id;
                        rCon.type = "Condition";
                        // literals
                        List <Rec_ti_literal> Lit_c = new List <Rec_ti_literal>();
                        foreach (BooleanLiteralStruct lit in HypList[i].booleanLiterals)
                        {
                            if (lit.cedentType == CedentEnum.Condition)
                            {
                                Rec_ti_literal l = new Rec_ti_literal();
                                l.id = "tiLit" + rHyp.id + "_" + litCounter.ToString();
                                litCounter++;
                                if (lit.negation)
                                {
                                    l.quant = "¬";
                                }
                                l.quant += lit.literalName;
                                int counter = 0;
                                foreach (string s in lit.categoriesNames)
                                {
                                    if (counter > 0)
                                    {
                                        l.value += ",";
                                    }
                                    l.value += s;
                                    counter++;
                                }
                                Lit_c.Add(l);
                            }
                        }

                        #endregion

                        #region element ti_cedent (Set1)

                        rSet1.id   = rHyp.set1;
                        rSet1.type = "First Set";
                        // literals
                        List <Rec_ti_literal> Lit_s1 = new List <Rec_ti_literal>();
                        foreach (BooleanLiteralStruct lit in HypList[i].booleanLiterals)
                        {
                            if (lit.cedentType == CedentEnum.FirstSet)
                            {
                                Rec_ti_literal l = new Rec_ti_literal();
                                l.id = "tiLit" + rHyp.id + "_" + litCounter.ToString();
                                litCounter++;
                                if (lit.negation)
                                {
                                    l.quant = "¬";
                                }
                                l.quant += lit.literalName;
                                int counter = 0;
                                foreach (string s in lit.categoriesNames)
                                {
                                    if (counter > 0)
                                    {
                                        l.value += ",";
                                    }
                                    l.value += s;
                                    counter++;
                                }
                                Lit_s1.Add(l);
                            }
                        }

                        #endregion

                        #region element ti_cedent (Set2)

                        rSet2.id   = rHyp.set2;
                        rSet2.type = "Second Set";
                        // literals
                        List <Rec_ti_literal> Lit_s2 = new List <Rec_ti_literal>();
                        foreach (BooleanLiteralStruct lit in HypList[i].booleanLiterals)
                        {
                            if (lit.cedentType == CedentEnum.SecondSet)
                            {
                                Rec_ti_literal l = new Rec_ti_literal();
                                l.id = "tiLit" + rHyp.id + "_" + litCounter.ToString();
                                litCounter++;
                                if (lit.negation)
                                {
                                    l.quant = "¬";
                                }
                                l.quant += lit.literalName;
                                int counter = 0;
                                foreach (string s in lit.categoriesNames)
                                {
                                    if (counter > 0)
                                    {
                                        l.value += ",";
                                    }
                                    l.value += s;
                                    counter++;
                                }
                                Lit_s2.Add(l);
                            }
                        }

                        #endregion


                        #region Generating of one hypotheses to XML string

                        string oneHypString = "";
                        // generating hypotheses to XML
                        oneHypString += rHyp.ToXML();
                        // generating Attributes (Antecedent) to XML
                        oneHypString += rAnt.ToXML(Cat_a);
                        // generating Condition to XML
                        oneHypString += rCon.ToXML(Lit_c);
                        // generating Set1 to XML
                        oneHypString += rSet1.ToXML(Lit_s1);
                        // generating Set2 to XML
                        oneHypString += rSet2.ToXML(Lit_s2);



                        resultString += oneHypString;

                        #endregion
                    }
                    #endregion
                }
                catch (System.Exception e)
                {
                    ErrStr += "Box ProjectIdentifier=" + box.ProjectIdentifier.ToString() + ": " + e.Message + "\n";
                }
            }
            #endregion


            // root element
            resultString += "</active_list>";

#if (LADENI)
            // generating of error message:
            if (!String.IsNullOrEmpty(ErrStr))  // LADICI
            {
                MessageBox.Show("Pri nacitani SD-CF hypotheses doslo k chybam:\n" + ErrStr, "Chyba", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }


            // LADICI - Kody - storing output to file "XMLsd4fthypExample.xml" in directory
            XMLHelper.saveXMLexample(resultString, "../XML/XMLsdcfhypExample.xml");
#endif

            return(resultString);
        }
        /// <summary>
        /// Returns XML string with all occurences of Active element "SD-KL hypothesis".
        /// </summary>
        /// <param name="index">index of data source in FEplugin data sources table</param>
        /// <returns>XML string</returns>
        public static string getList(int index)
        {
            string resultString = ""; // result XML string

            // loading DTD to resultString
            try { resultString = XMLHelper.loadDTD(); }
            catch (Exception e)
            {
            #if (LADENI)
                MessageBox.Show("error while loading DTD: " + e.Message);
            #endif
                return resultString;
            }

            // root element
            resultString += "<active_list>";

            string PropName = "Hypotheses";  // name of property which contain a list of hypotheses
            // searching all boxes SD-KL-tasks
            IBoxModule[] TaskBoxes = BoxesHelper.ListBoxesWithID(CFEsourcesTab.Sources[index] as CFEsource, "LISpMinerTasks.SDKLTask");

            // processing of each box -  searching all KL-hypotheses
            string ErrStr = ""; // error report

            string matrix_name = "unknown";   // analyzed data matrix name
            string db_name="unknown";    // analyzed database name
            string task_name = "unknown";  // task name - given with user name of box FFTTast

            // creatind delegates for functions of quantifiers
            // "sum of values"
            ContingencyTable.QuantifierValue<TwoDimensionalContingencyTable> sum_delegat = new ContingencyTable.QuantifierValue<TwoDimensionalContingencyTable>(TwoDimensionalContingencyTable.GetSumOfValues);
            // "min value"
            ContingencyTable.QuantifierValue<TwoDimensionalContingencyTable> min_delegat = new ContingencyTable.QuantifierValue<TwoDimensionalContingencyTable>(TwoDimensionalContingencyTable.GetMinValue);
            // "max value"
            ContingencyTable.QuantifierValue<TwoDimensionalContingencyTable> max_delegat = new ContingencyTable.QuantifierValue<TwoDimensionalContingencyTable>(TwoDimensionalContingencyTable.GetMaxValue);

            #region Loop - processing of each KL-Task from array TaskBoxes

            foreach (IBoxModule box in TaskBoxes)
            {
                try
                {
                    // searching data source name (database)
                    IBoxModule[] db_names = BoxesHelper.ListAncestBoxesWithID(box, "DataMiningCommon.Database");
                    if (db_names.GetLength(0) != 1)  // searched more than one data source or neither one
                        throw new System.Exception("found " + db_names.GetLength(0).ToString() + " databases");
                    db_name = (db_names[0].GetPropertyOther("DatabaseName") as StringT).stringValue;

                    // searching data matrix name
                    IBoxModule[] matrix_names = BoxesHelper.ListAncestBoxesWithID(box, "DataMiningCommon.DataMatrix");
                    if (matrix_names.GetLength(0) != 1)  // searched more than one data source or neither one
                        throw new System.Exception("found " + matrix_names.GetLength(0).ToString() + " data matrixes");
                    matrix_name = (matrix_names[0].GetPropertyOther("Name") as StringT).stringValue;

                    // searching task name
                    task_name = box.UserName;

                    // searching the list of all hypotheses in this task
                    HypothesesT HypT = box.GetPropertyOther(PropName) as HypothesesT;
                    HypothesisStruct[] HypList = HypT.hypothesesValue.Clone() as HypothesisStruct[];

                    // records for storing the results
                    Rec_hyp_SDKL rHyp = new Rec_hyp_SDKL();   // SD-KL hypothesis
                    Rec_ti_attribute rAnt = new Rec_ti_attribute();  // Antecedent (Row attributes)
                    Rec_ti_attribute rSuc = new Rec_ti_attribute();  // Succedent (Column attributes)
                    Rec_ti_cedent rCon = new Rec_ti_cedent();  // condition
                    Rec_ti_cedent rSet1 = new Rec_ti_cedent();  // set 1
                    Rec_ti_cedent rSet2 = new Rec_ti_cedent();  // set 2

                    #region Loop - processing of each hypotheses jedne krabicky SDKLTask
                    // Loop over all hypotheses
                    for (int i = 0; i < HypList.GetLength(0); i++)
                    {
                        #region element hyp_SDKL

                        rHyp.id = "hypSDKL" + box.ProjectIdentifier.ToString() + "_" + i.ToString();
                        rHyp.db_name = db_name;
                        rHyp.matrix_name = matrix_name;
                        rHyp.task_name = task_name;
                        rHyp.row_attributes = "r_attr" + rHyp.id;
                        rHyp.column_attributes = "c_attr" + rHyp.id;
                        rHyp.condition = "con" + rHyp.id;
                        rHyp.set1 = "set1" + rHyp.id;
                        rHyp.set2 = "set2" + rHyp.id;
                        TwoDimensionalContingencyTable CT1 = new TwoDimensionalContingencyTable(HypList[i].quantifierSetting.firstContingencyTableRows); // Contingency Table 1
                        TwoDimensionalContingencyTable CT2 = new TwoDimensionalContingencyTable(HypList[i].quantifierSetting.secondContingencyTableRows); // Contingency Table 2
                        rHyp.Tab1 = HypList[i].quantifierSetting.firstContingencyTableRows;
                        rHyp.Tab2 = HypList[i].quantifierSetting.secondContingencyTableRows;

                        // values of quantifiers - set1
                        try
                        {
                            rHyp.sum1 = CT1.SumOfValues.ToString();
                            rHyp.min1 = CT1.MinValue.ToString();
                            rHyp.max1 = CT1.MaxValue.ToString();
                            rHyp.chi_sq1 = TwoDimensionalContingencyTable.ChiSquare(CT1).ToString();
                            rHyp.fnc_s1 = TwoDimensionalContingencyTable.SumOfRowMaximumsValue(CT1).ToString();
                            rHyp.fnc_r1 = TwoDimensionalContingencyTable.MinOfRowMaximumsValue(CT1).ToString();
                            rHyp.h_c1 = CT1.MarginalColumnEntropy.ToString();
                            rHyp.h_r1 = CT1.MarginalRowEntropy.ToString();
                            rHyp.h_c_r1 = TwoDimensionalContingencyTable.ConditionalCREntropyValue(CT1).ToString();
                            rHyp.mi1 = CT1.MutualInformation.ToString();
                            //rHyp.aic = CT.???;  TODO
                            rHyp.kend1 = TwoDimensionalContingencyTable.KendalValue(CT1).ToString();
                        }
                        catch (System.Exception e) // TODO: Ferda ma chyby ve vypoctech -> opravit!
                        {
                            ErrStr += "Box ProjectIdentifier=" + box.ProjectIdentifier.ToString() + ": chyba pri vypoctu quantifier: " + e.Message + "\n";
                        }
                        // values of quantifiers - set2
                        try
                        {
                            rHyp.sum2 = CT2.SumOfValues.ToString();
                            rHyp.min2 = CT2.MinValue.ToString();
                            rHyp.max2 = CT2.MaxValue.ToString();
                            rHyp.chi_sq2 = TwoDimensionalContingencyTable.ChiSquare(CT2).ToString();
                            rHyp.fnc_s2 = TwoDimensionalContingencyTable.SumOfRowMaximumsValue(CT2).ToString();
                            rHyp.fnc_r2 = TwoDimensionalContingencyTable.MinOfRowMaximumsValue(CT2).ToString();
                            rHyp.h_c2 = CT2.MarginalColumnEntropy.ToString();
                            rHyp.h_r2 = CT2.MarginalRowEntropy.ToString();
                            rHyp.h_c_r2 = TwoDimensionalContingencyTable.ConditionalCREntropyValue(CT2).ToString();
                            rHyp.mi2 = CT2.MutualInformation.ToString();
                            //rHyp.aic = CT.???;  TODO
                            rHyp.kend2 = TwoDimensionalContingencyTable.KendalValue(CT2).ToString();
                        }
                        catch (System.Exception e) // Ferda ma chyby ve vypoctech!
                        {
                            ErrStr += "Box ProjectIdentifier=" + box.ProjectIdentifier.ToString() + ": chyba pri vypoctu quantifier: " + e.Message + "\n";
                        }
                        // values of quantifiers - diffrent of set1 a set2
                        try
                        {
                            rHyp.da_sum = TwoDimensionalContingencyTable.Value<TwoDimensionalContingencyTable>(sum_delegat, CT1, CT2, OperationModeEnum.DifferencesOfAbsoluteFrequencies).ToString();
                            rHyp.da_min = TwoDimensionalContingencyTable.Value<TwoDimensionalContingencyTable>(min_delegat, CT1, CT2, OperationModeEnum.DifferencesOfAbsoluteFrequencies).ToString();
                            rHyp.da_max = TwoDimensionalContingencyTable.Value<TwoDimensionalContingencyTable>(max_delegat, CT1, CT2, OperationModeEnum.DifferencesOfAbsoluteFrequencies).ToString();
                            rHyp.dr_sum = TwoDimensionalContingencyTable.Value<TwoDimensionalContingencyTable>(sum_delegat, CT1, CT2, OperationModeEnum.DifferencesOfRelativeFrequencies).ToString();
                            rHyp.dr_min = TwoDimensionalContingencyTable.Value<TwoDimensionalContingencyTable>(min_delegat, CT1, CT2, OperationModeEnum.DifferencesOfRelativeFrequencies).ToString();
                            rHyp.dr_max = TwoDimensionalContingencyTable.Value<TwoDimensionalContingencyTable>(max_delegat, CT1, CT2, OperationModeEnum.DifferencesOfRelativeFrequencies).ToString();
                        }
                        catch (System.Exception e) // Ferda ma chyby ve vypoctech!
                        {
                            ErrStr += "Box ProjectIdentifier=" + box.ProjectIdentifier.ToString() + ": chyba pri vypoctu quantifier: " + e.Message + "\n";
                        }

                        #endregion

                        #region element ti_attribute Row attributes (Antecedent)

                        rAnt.id = rHyp.row_attributes;
                        rAnt.type = "Row attributes";
                        rAnt.quant = "";   // deleting previous value
                        // category
                        List<Rec_ti_category> Cat_a = new List<Rec_ti_category>();
                        foreach (LiteralStruct lit in HypList[i].literals)
                        {
                            if (lit.cedentType == CedentEnum.Antecedent)
                            {
                                rAnt.quant += lit.literalName;
                                foreach (string s in lit.categoriesNames)
                                {
                                    Rec_ti_category C = new Rec_ti_category();
                                    C.value = s;
                                    Cat_a.Add(C);
                                }
                            }
                        }

                        #endregion

                        #region element ti_attribute Column attributes (Succedent)

                        rSuc.id = rHyp.column_attributes;
                        rSuc.type = "Column attributes";
                        rSuc.quant = "";   // deleting previous value
                        // category
                        List<Rec_ti_category> Cat_s = new List<Rec_ti_category>();
                        foreach (LiteralStruct lit in HypList[i].literals)
                        {
                            if (lit.cedentType == CedentEnum.Succedent)
                            {
                                rSuc.quant += lit.literalName;
                                foreach (string s in lit.categoriesNames)
                                {
                                    Rec_ti_category C = new Rec_ti_category();
                                    C.value = s;
                                    Cat_s.Add(C);
                                }
                            }
                        }

                        #endregion

                        #region element ti_cedent (Condition)

                        rCon.id = "con" + rHyp.id;
                        rCon.type = "Condition";
                        // literals
                        int litCounter = 0;  // counter of literals of this hypothesis
                        List<Rec_ti_literal> Lit_c = new List<Rec_ti_literal>();
                        foreach (BooleanLiteralStruct lit in HypList[i].booleanLiterals)
                        {
                            if (lit.cedentType == CedentEnum.Condition)
                            {
                                Rec_ti_literal l = new Rec_ti_literal();
                                l.id = "tiLit" + rHyp.id + "_" + litCounter.ToString();
                                litCounter++;
                                if (lit.negation)
                                    l.quant = "¬";
                                l.quant += lit.literalName;
                                int counter = 0;
                                foreach (string s in lit.categoriesNames)
                                {
                                    if (counter > 0)
                                        l.value += ",";
                                    l.value += s;
                                    counter++;
                                }
                                Lit_c.Add(l);
                            }
                        }

                        #endregion

                        #region element ti_cedent (Set1)

                        rSet1.id = rHyp.set1;
                        rSet1.type = "First Set";
                        // literals
                        List<Rec_ti_literal> Lit_s1 = new List<Rec_ti_literal>();
                        foreach (BooleanLiteralStruct lit in HypList[i].booleanLiterals)
                        {
                            if (lit.cedentType == CedentEnum.FirstSet)
                            {
                                Rec_ti_literal l = new Rec_ti_literal();
                                l.id = "tiLit" + rHyp.id + "_" + litCounter.ToString();
                                litCounter++;
                                if (lit.negation)
                                    l.quant = "¬";
                                l.quant += lit.literalName;
                                int counter = 0;
                                foreach (string s in lit.categoriesNames)
                                {
                                    if (counter > 0)
                                        l.value += ",";
                                    l.value += s;
                                    counter++;
                                }
                                Lit_s1.Add(l);
                            }
                        }

                        #endregion

                        #region element ti_cedent (Set2)

                        rSet2.id = rHyp.set2;
                        rSet2.type = "Second Set";
                        // literals
                        List<Rec_ti_literal> Lit_s2 = new List<Rec_ti_literal>();
                        foreach (BooleanLiteralStruct lit in HypList[i].booleanLiterals)
                        {
                            if (lit.cedentType == CedentEnum.SecondSet)
                            {
                                Rec_ti_literal l = new Rec_ti_literal();
                                l.id = "tiLit" + rHyp.id + "_" + litCounter.ToString();
                                litCounter++;
                                if (lit.negation)
                                    l.quant = "¬";
                                l.quant += lit.literalName;
                                int counter = 0;
                                foreach (string s in lit.categoriesNames)
                                {
                                    if (counter > 0)
                                        l.value += ",";
                                    l.value += s;
                                    counter++;
                                }
                                Lit_s2.Add(l);
                            }
                        }

                        #endregion

                        #region Generating of one hypothesis to XML string

                        string oneHypString = "";
                        // generating hypotheses to XML
                        oneHypString += rHyp.ToXML();
                        // generating Row attributes (Antecedent) to XML
                        oneHypString += rAnt.ToXML(Cat_a);
                        // generating Column attributes (Succedent) to XML
                        oneHypString += rSuc.ToXML(Cat_s);
                        // generating Condition to XML
                        oneHypString += rCon.ToXML(Lit_c);
                        // generating Set1 to XML
                        oneHypString += rSet1.ToXML(Lit_s1);
                        // generating Set2 to XML
                        oneHypString += rSet2.ToXML(Lit_s2);

                        resultString += oneHypString;

                        #endregion
                    }
                    #endregion
                }
                catch (System.Exception e)
                {
                    ErrStr += "Box ProjectIdentifier=" + box.ProjectIdentifier.ToString() + ": " + e.Message + "\n";
                }
            }
            #endregion

            // root element
            resultString += "</active_list>";

            #if (LADENI)
            // generating of error message:
            if (!String.IsNullOrEmpty(ErrStr))  // LADICI
                MessageBox.Show("Pri nacitani SD-KL hypotheses doslo k chybam:\n" + ErrStr, "Chyba", MessageBoxButtons.OK, MessageBoxIcon.Error);

            // LADICI - Kody - storing output to file "XMLsd4fthypExample.xml" in directory
            XMLHelper.saveXMLexample(resultString, "../XML/XMLsdKLhypExample.xml");
            #endif

            return resultString;
        }
        /// <summary>
        /// Returns XML string with all occurences of Active element "SD-4FFT hypothesis".
        /// </summary>
        /// <param name="index">index of data source in FEplugin data sources table</param>
        /// <returns>XML string</returns>
        public static string getList(int index)
        {
            string resultString = ""; // result XML string

            // loading DTD to resultString
            try { resultString = XMLHelper.loadDTD(); }
            catch (Exception e)
            {
            #if (LADENI)
                MessageBox.Show("error while loading DTD: " + e.Message);
            #endif
                return resultString;
            }

            // root element
            resultString += "<active_list>";

            string PropName = "Hypotheses";  // name of property which contain a list of hypotheses
            // searching all boxes SD-4FT-uloh
            IBoxModule[] TaskBoxes = BoxesHelper.ListBoxesWithID(CFEsourcesTab.Sources[index] as CFEsource, "LISpMinerTasks.SDFFTTask");

            // processing of each box - searching all 4ft-hypotheses
            string ErrStr = ""; // error report

            string matrix_name = "unknown";   // analyzed data matrix name
            string db_name="unknown";    // analyzed database name
            string task_name = "unknown";  // task name - given with user name of box FFTTast

            // creating delegate of quantifier function - "sum of value"
            ContingencyTable.QuantifierValue<FourFoldContingencyTable> sum_delegat = new ContingencyTable.QuantifierValue<FourFoldContingencyTable>(FourFoldContingencyTable.GetSumOfValues);

            #region Loop - processing of each SD-4ft-Task from array TaskBoxes

            foreach (IBoxModule box in TaskBoxes)
            {
                try
                {
                    // searching data source name (database)
                    IBoxModule[] db_names = BoxesHelper.ListAncestBoxesWithID(box, "DataMiningCommon.Database");
                    if (db_names.GetLength(0) != 1)  // searched more than one data source or neither one
                        throw new System.Exception("found " + db_names.GetLength(0).ToString() + " databases");
                    db_name = (db_names[0].GetPropertyOther("DatabaseName") as StringT).stringValue;

                    // searching data matrix name
                    IBoxModule[] matrix_names = BoxesHelper.ListAncestBoxesWithID(box, "DataMiningCommon.DataMatrix");
                    if (matrix_names.GetLength(0) != 1)  // searched more than one data source or neither one
                        throw new System.Exception("found " + matrix_names.GetLength(0).ToString() + " data matrixes");
                    matrix_name = (matrix_names[0].GetPropertyOther("Name") as StringT).stringValue;

                    // searching task name
                    task_name = box.UserName;

                    // searching the list of all hypotheses in this task
                    HypothesesT HypT = box.GetPropertyOther(PropName) as HypothesesT;
                    HypothesisStruct[] HypList = HypT.hypothesesValue.Clone() as HypothesisStruct[];

                    // records for storing the results
                    Rec_hyp_sd4ft rHyp = new Rec_hyp_sd4ft();      // hypothesis
                    Rec_ti_cedent rAnt = new Rec_ti_cedent();  // antecedent
                    Rec_ti_cedent rSuc = new Rec_ti_cedent();  // succedent
                    Rec_ti_cedent rCon = new Rec_ti_cedent();  // condition
                    Rec_ti_cedent rSet1 = new Rec_ti_cedent();  // set 1
                    Rec_ti_cedent rSet2 = new Rec_ti_cedent();  // set 2

                    #region Loop - processing of each hypotheses of one SDFFTTask box
                    // Loop over all hypotheses
                    for (int i = 0; i < HypList.GetLength(0); i++)
                    {
                        #region element hyp_sd4ft

                        rHyp.id = "hypsd4ft" + box.ProjectIdentifier.ToString() + "_" + i.ToString();
                        rHyp.db_name = db_name;
                        rHyp.matrix_name = matrix_name;
                        rHyp.task_name = task_name;
                        rHyp.antecedent = "ant" + rHyp.id;
                        rHyp.succedent = "suc" + rHyp.id;
                        rHyp.condition = "con" + rHyp.id;
                        rHyp.set1 = "set1" + rHyp.id;
                        rHyp.set2 = "set2" + rHyp.id;
                        FourFoldContingencyTable FFT1 = new FourFoldContingencyTable(HypList[i].quantifierSetting.firstContingencyTableRows);
                        FourFoldContingencyTable FFT2 = new FourFoldContingencyTable(HypList[i].quantifierSetting.secondContingencyTableRows);
                        rHyp.a = FFT1.A.ToString();
                        rHyp.b = FFT1.B.ToString();
                        rHyp.c = FFT1.C.ToString();
                        rHyp.d = FFT1.D.ToString();
                        rHyp.e = FFT2.A.ToString();
                        rHyp.f = FFT2.B.ToString();
                        rHyp.g = FFT2.C.ToString();
                        rHyp.h = FFT2.D.ToString();

                        // values of quantifiers - first set
                        double conf1 = FourFoldContingencyTable.FoundedImplicationValue(FFT1);  // Founded implication (a/a+b)
                        rHyp.conf1 = conf1.ToString();
                        double d_conf1 = FourFoldContingencyTable.DoubleFoundedImplicationValue(FFT1); // Double Founded implication (a/a+b+c)
                        rHyp.d_conf1 = d_conf1.ToString();
                        double e_conf1 = FourFoldContingencyTable.FoundedEquivalenceValue(FFT1);   // Founded Equivalence (a+d)/(a+b+c+d)  ??? BUG ve Ferdovi
                        rHyp.e_conf1 = e_conf1.ToString();
                        rHyp.support1 = FourFoldContingencyTable.BaseCeilValue(FFT1).ToString(); //???  Support (a/a+b+c+d)
                           // helping variable
                        double avg_diff1 = FourFoldContingencyTable.AboveAverageImplicationValue(FFT1) - 1; // Averafe difference ((a*(a+b+c+d))/((a+b)*(a+c)) -1)
                        rHyp.avg_diff1 = avg_diff1.ToString();
                        rHyp.fisher1 = FFT1.FisherValue().ToString();
                        rHyp.chi_sq1 = FFT1.ChiSquareValue().ToString();

                        // values of quantifiers - second set
                        double conf2 = FourFoldContingencyTable.FoundedImplicationValue(FFT2);  // Founded implication (a/a+b)
                        rHyp.conf2 = conf2.ToString();
                        double d_conf2 = FourFoldContingencyTable.DoubleFoundedImplicationValue(FFT2); // Double Founded implication (a/a+b+c)
                        rHyp.d_conf2 = d_conf2.ToString();
                        double e_conf2 = FourFoldContingencyTable.FoundedEquivalenceValue(FFT2);   // Founded Equivalence (a+d)/(a+b+c+d)  ??? BUG ve Ferdovi
                        rHyp.e_conf2 = e_conf2.ToString();
                        rHyp.support2 = FourFoldContingencyTable.BaseCeilValue(FFT2).ToString(); //???  Support (a/a+b+c+d)
                           // helping variable
                        double avg_diff2 = FourFoldContingencyTable.AboveAverageImplicationValue(FFT2) - 1; // Averafe difference ((a*(a+b+c+d))/((a+b)*(a+c)) -1)
                        rHyp.avg_diff2 = avg_diff2.ToString();
                        rHyp.fisher2 = FFT2.FisherValue().ToString();
                        rHyp.chi_sq2 = FFT2.ChiSquareValue().ToString();

                        // values of quantifiers - diffrent of first and second set
                        rHyp.dr_sum = FourFoldContingencyTable.Value<FourFoldContingencyTable>(sum_delegat, FFT1, FFT2, OperationModeEnum.DifferencesOfRelativeFrequencies).ToString();
                        double df_conf = FourFoldContingencyTable.Combine(conf1, conf2, OperationModeEnum.DifferenceOfQuantifierValues);
                        rHyp.df_conf = df_conf.ToString();
                        double df_dfui  = FourFoldContingencyTable.Combine(d_conf1, d_conf2, OperationModeEnum.DifferenceOfQuantifierValues);
                        rHyp.df_dfui = df_dfui.ToString();
                        double df_fue = FourFoldContingencyTable.Combine(e_conf1, e_conf2, OperationModeEnum.DifferenceOfQuantifierValues);
                        rHyp.df_fue = df_fue.ToString();
                        double df_avg = FourFoldContingencyTable.Combine(avg_diff1, avg_diff2, OperationModeEnum.DifferenceOfQuantifierValues);
                        rHyp.df_avg = df_avg.ToString();

                        #endregion

                        #region element ti_cedent (Antecedent)

                        rAnt.id = rHyp.antecedent;
                        rAnt.type = "Antecedent";
                        // literals
                        int litCounter = 0;  // counter of literals of this hypotheses
                        List<Rec_ti_literal> Lit_a = new List<Rec_ti_literal>();
                        foreach (BooleanLiteralStruct lit in HypList[i].booleanLiterals)
                        {
                            if (lit.cedentType == CedentEnum.Antecedent)
                            {
                                Rec_ti_literal l = new Rec_ti_literal();
                                l.id = "tiLit" + rHyp.id + "_" + litCounter.ToString();
                                litCounter++;
                                if (lit.negation)
                                    l.quant = "¬";
                                l.quant += lit.literalName;
                                int counter = 0;
                                foreach (string s in lit.categoriesNames)
                                {
                                    if (counter > 0)
                                        l.value += ",";
                                    l.value += s;
                                    counter++;
                                }
                                Lit_a.Add(l);
                            }
                        }

                        #endregion

                        #region element ti_cedent (Succedent)

                        rSuc.id = rHyp.succedent;
                        rSuc.type = "Succedent";
                        // literals
                        List<Rec_ti_literal> Lit_s = new List<Rec_ti_literal>();
                        foreach (BooleanLiteralStruct lit in HypList[i].booleanLiterals)
                        {
                            if (lit.cedentType == CedentEnum.Succedent)
                            {
                                Rec_ti_literal l = new Rec_ti_literal();
                                l.id = "tiLit" + rHyp.id + "_" + litCounter.ToString();
                                litCounter++;
                                if (lit.negation)
                                    l.quant = "¬";
                                l.quant += lit.literalName;
                                int counter = 0;
                                foreach (string s in lit.categoriesNames)
                                {
                                    if (counter > 0)
                                        l.value += ",";
                                    l.value += s;
                                    counter++;
                                }
                                Lit_s.Add(l);
                            }
                        }

                        #endregion

                        #region element ti_cedent (Condition)

                        rCon.id = rHyp.condition;
                        rCon.type = "Condition";
                        // literals
                        List<Rec_ti_literal> Lit_c = new List<Rec_ti_literal>();
                        foreach (BooleanLiteralStruct lit in HypList[i].booleanLiterals)
                        {
                            if (lit.cedentType == CedentEnum.Condition)
                            {
                                Rec_ti_literal l = new Rec_ti_literal();
                                l.id = "tiLit" + rHyp.id + "_" + litCounter.ToString();
                                litCounter++;
                                if (lit.negation)
                                    l.quant = "¬";
                                l.quant += lit.literalName;
                                int counter = 0;
                                foreach (string s in lit.categoriesNames)
                                {
                                    if (counter > 0)
                                        l.value += ",";
                                    l.value += s;
                                    counter++;
                                }
                                Lit_c.Add(l);
                            }
                        }

                        #endregion

                        #region element ti_cedent (First Set)

                        rSet1.id = rHyp.set1;
                        rSet1.type = "First Set";
                        // literals
                        List<Rec_ti_literal> Lit_s1 = new List<Rec_ti_literal>();
                        foreach (BooleanLiteralStruct lit in HypList[i].booleanLiterals)
                        {
                            if (lit.cedentType == CedentEnum.FirstSet)
                            {
                                Rec_ti_literal l = new Rec_ti_literal();
                                l.id = "tiLit" + rHyp.id + "_" + litCounter.ToString();
                                litCounter++;
                                if (lit.negation)
                                    l.quant = "¬";
                                l.quant += lit.literalName;
                                int counter = 0;
                                foreach (string s in lit.categoriesNames)
                                {
                                    if (counter > 0)
                                        l.value += ",";
                                    l.value += s;
                                    counter++;
                                }
                                Lit_s1.Add(l);
                            }
                        }

                        #endregion

                        #region element ti_cedent (Second Set)

                        rSet2.id = rHyp.set2;
                        rSet2.type = "Second Set";
                        // literals
                        List<Rec_ti_literal> Lit_s2 = new List<Rec_ti_literal>();
                        foreach (BooleanLiteralStruct lit in HypList[i].booleanLiterals)
                        {
                            if (lit.cedentType == CedentEnum.SecondSet)
                            {
                                Rec_ti_literal l = new Rec_ti_literal();
                                l.id = "tiLit" + rHyp.id + "_" + litCounter.ToString();
                                litCounter++;
                                if (lit.negation)
                                    l.quant = "¬";
                                l.quant += lit.literalName;
                                int counter = 0;
                                foreach (string s in lit.categoriesNames)
                                {
                                    if (counter > 0)
                                        l.value += ",";
                                    l.value += s;
                                    counter++;
                                }
                                Lit_s2.Add(l);
                            }
                        }

                        #endregion

                        #region Generating of one hypotheses to XML string

                        string oneHypString = "";
                        // generating hypotheses to XML
                        oneHypString += rHyp.ToXML();
                        // generating Antecedent to XML
                        oneHypString += rAnt.ToXML(Lit_a);
                        // generating Succedent to XML
                        oneHypString += rSuc.ToXML(Lit_s);
                        // generating Condition to XML
                        oneHypString += rCon.ToXML(Lit_c);
                        // generating First Set to XML
                        oneHypString += rSet1.ToXML(Lit_s1);
                        // generating Second Set to XML
                        oneHypString += rSet2.ToXML(Lit_s2);

                        resultString += oneHypString;

                        #endregion
                    }
                    #endregion
                }
                catch (System.Exception e)
                {
                    ErrStr += "Box ProjectIdentifier=" + box.ProjectIdentifier.ToString() + ": " + e.Message + "\n";
                }
            }
            #endregion

            // root element
            resultString += "</active_list>";

            #if (LADENI)
            // generating of error message:
            if (!String.IsNullOrEmpty(ErrStr))  // LADICI
                MessageBox.Show("Pri nacitani SD4FT hypotheses doslo k chybam:\n" + ErrStr, "Chyba", MessageBoxButtons.OK, MessageBoxIcon.Error);

            // LADICI - Kody - storing output to file "XMLsd4fthypExample.xml" in directory
            XMLHelper.saveXMLexample(resultString, "../XML/XMLsd4fthypExample.xml");
            #endif

            return resultString;
        }
        /// <summary>
        /// Returns XML string with all occurences of Active element "SD-CF hypothesis".
        /// </summary>
        /// <param name="index">index of data source in FEplugin data sources table</param>
        /// <returns>XML string</returns>
        public static string getList(int index)
        {
            string resultString = ""; // result XML string

            // loading DTD to resultString
            try { resultString = XMLHelper.loadDTD(); }
            catch (Exception e)
            {
            #if (LADENI)
                MessageBox.Show("error while loading DTD: " + e.Message);
            #endif
                return resultString;
            }

            // root element
            resultString += "<active_list>";

            string PropName = "Hypotheses";  // name of property which contain a list of hypotheses
            // searching all boxes CF-task
            IBoxModule[] TaskBoxes = BoxesHelper.ListBoxesWithID(CFEsourcesTab.Sources[index] as CFEsource, "LISpMinerTasks.SDCFTask");

            // processing of each box - searching all CF-hypotheses
            string ErrStr = ""; // error report

            string matrix_name = "unknown";   // analyzed data matrix name
            string db_name="unknown";    // analyzed database name
            string task_name = "unknown";  // task name - given with user name of box FFTTast

            // creating delegates of quantifier functions
                // "sum of values"
            ContingencyTable.QuantifierValue<OneDimensionalContingencyTable> sum_delegat = new ContingencyTable.QuantifierValue<OneDimensionalContingencyTable>(OneDimensionalContingencyTable.GetSumOfValues);
                // "min value"
            ContingencyTable.QuantifierValue<OneDimensionalContingencyTable> min_delegat = new ContingencyTable.QuantifierValue<OneDimensionalContingencyTable>(OneDimensionalContingencyTable.GetMinValue);
                // "max value"
            ContingencyTable.QuantifierValue<OneDimensionalContingencyTable> max_delegat = new ContingencyTable.QuantifierValue<OneDimensionalContingencyTable>(OneDimensionalContingencyTable.GetMaxValue);

            #region Loop - processing of each CF-Task from array TaskBoxes

            foreach (IBoxModule box in TaskBoxes)
            {
                try
                {
                    // searching data source name (database)
                    IBoxModule[] db_names = BoxesHelper.ListAncestBoxesWithID(box, "DataMiningCommon.Database");
                    if (db_names.GetLength(0) != 1)  // searched more than one data source or neither one
                        throw new System.Exception("found " + db_names.GetLength(0).ToString() + " databases");
                    db_name = (db_names[0].GetPropertyOther("DatabaseName") as StringT).stringValue;

                    // searching data matrix name
                    IBoxModule[] matrix_names = BoxesHelper.ListAncestBoxesWithID(box, "DataMiningCommon.DataMatrix");
                    if (matrix_names.GetLength(0) != 1)  // searched more than one data source or neither one
                        throw new System.Exception("found " + matrix_names.GetLength(0).ToString() + " data matrixes");
                    matrix_name = (matrix_names[0].GetPropertyOther("Name") as StringT).stringValue;

                    // searching task name
                    task_name = box.UserName;

                    // searching the list of all hypotheses in this task
                    HypothesesT HypT = box.GetPropertyOther(PropName) as HypothesesT;
                    HypothesisStruct[] HypList = HypT.hypothesesValue.Clone() as HypothesisStruct[];

                    // records for storing the results
                    Rec_hyp_sdcf rHyp = new Rec_hyp_sdcf();   // CF hypothesis
                    Rec_ti_attribute rAnt = new Rec_ti_attribute();  // Antecedent (Attributes)
                    Rec_ti_cedent rCon = new Rec_ti_cedent();  // Condition
                    Rec_ti_cedent rSet1 = new Rec_ti_cedent();  // set 1
                    Rec_ti_cedent rSet2 = new Rec_ti_cedent();  // set 2

                    #region Loop - processing of each hypotheses jedne krabicky CFTask
                    // Loop over all hypotheses
                    for (int i = 0; i < HypList.GetLength(0); i++)
                    {
                        #region element hyp_sdcf

                        rHyp.id = "hypsdcf" + box.ProjectIdentifier.ToString() + "_" + i.ToString();
                        rHyp.db_name = db_name;
                        rHyp.matrix_name = matrix_name;
                        rHyp.task_name = task_name;
                        rHyp.attributes = "attr" + rHyp.id;
                        rHyp.condition = "con" + rHyp.id;
                        rHyp.set1 = "set1" + rHyp.id;
                        rHyp.set2 = "set2" + rHyp.id;

                        OneDimensionalContingencyTable CT1 = new OneDimensionalContingencyTable(HypList[i].quantifierSetting.firstContingencyTableRows); // Contingency Table 1
                        OneDimensionalContingencyTable CT2 = new OneDimensionalContingencyTable(HypList[i].quantifierSetting.secondContingencyTableRows); // Contingency Table 2
                        rHyp.Tab1 = HypList[i].quantifierSetting.firstContingencyTableRows[0];
                        rHyp.Tab2 = HypList[i].quantifierSetting.secondContingencyTableRows[0];

                        // values of quantifiers - set1
                        try
                        {
                            rHyp.sum1 = CT1.SumOfValues.ToString();
                            rHyp.min1 = CT1.MinValue.ToString();
                            rHyp.max1 = CT1.MaxValue.ToString();
                            rHyp.v1 = CT1.VariationRatio.ToString();
                            rHyp.nom_var1 = CT1.NominalVariation.ToString();
                            rHyp.dor_var1 = CT1.DiscreteOrdinaryVariation.ToString();
                            rHyp.avg_a1 = CT1.ArithmeticAverage.ToString();
                            rHyp.avg_g1 = CT1.GeometricAverage.ToString();
                            rHyp.var1 = CT1.Variance.ToString();
                            rHyp.st_dev1 = CT1.StandardDeviation.ToString();
                            rHyp.skew1 = CT1.Skewness.ToString();
                            rHyp.asym1 = CT1.Asymentry.ToString();
                        }
                        catch (System.Exception e) // !Ferda has errors in quantifier values!!
                        {
                            ErrStr += "Box ProjectIdentifier=" + box.ProjectIdentifier.ToString() + ": chyba pri vypoctu kvantifikatoru: " + e.Message + "\n";
                        }

                        // values of quantifiers - set2
                        try
                        {
                            rHyp.sum2 = CT2.SumOfValues.ToString();
                            rHyp.min2 = CT2.MinValue.ToString();
                            rHyp.max2 = CT2.MaxValue.ToString();
                            rHyp.v2 = CT2.VariationRatio.ToString();
                            rHyp.nom_var2 = CT2.NominalVariation.ToString();
                            rHyp.dor_var2 = CT2.DiscreteOrdinaryVariation.ToString();
                            rHyp.avg_a2 = CT2.ArithmeticAverage.ToString();
                            rHyp.avg_g2 = CT2.GeometricAverage.ToString();
                            rHyp.var2 = CT2.Variance.ToString();
                            rHyp.st_dev2 = CT2.StandardDeviation.ToString();
                            rHyp.skew2 = CT2.Skewness.ToString();
                            rHyp.asym2 = CT2.Asymentry.ToString();
                        }
                        catch (System.Exception e) // !Ferda has errors in quantifier values!!
                        {
                            ErrStr += "Box ProjectIdentifier=" + box.ProjectIdentifier.ToString() + ": chyba pri vypoctu kvantifikatoru: " + e.Message + "\n";
                        }

                        // values of quantifiers - diffrent of set1 a set2
                        try
                        {
                            rHyp.da_sum = OneDimensionalContingencyTable.Value<OneDimensionalContingencyTable>(sum_delegat, CT1, CT2, OperationModeEnum.DifferencesOfAbsoluteFrequencies).ToString();
                            rHyp.da_min = OneDimensionalContingencyTable.Value<OneDimensionalContingencyTable>(min_delegat, CT1, CT2, OperationModeEnum.DifferencesOfAbsoluteFrequencies).ToString();
                            rHyp.da_max = OneDimensionalContingencyTable.Value<OneDimensionalContingencyTable>(max_delegat, CT1, CT2, OperationModeEnum.DifferencesOfAbsoluteFrequencies).ToString();
                            rHyp.dr_sum = OneDimensionalContingencyTable.Value<OneDimensionalContingencyTable>(sum_delegat, CT1, CT2, OperationModeEnum.DifferencesOfRelativeFrequencies).ToString();
                            rHyp.dr_min = OneDimensionalContingencyTable.Value<OneDimensionalContingencyTable>(min_delegat, CT1, CT2, OperationModeEnum.DifferencesOfRelativeFrequencies).ToString();
                            rHyp.dr_max = OneDimensionalContingencyTable.Value<OneDimensionalContingencyTable>(max_delegat, CT1, CT2, OperationModeEnum.DifferencesOfRelativeFrequencies).ToString();
                        }
                        catch (System.Exception e) // !Ferda has errors in quantifier values!!
                        {
                            ErrStr += "Box ProjectIdentifier=" + box.ProjectIdentifier.ToString() + ": chyba pri vypoctu kvantifikatoru: " + e.Message + "\n";
                        }

                        #endregion

                        #region element ti_attribute  Attributes (Antecedent)

                        rAnt.id = rHyp.attributes;
                        rAnt.type = "Attributes";
                        rAnt.quant = "";   // deleting previous value
                        // category
                        List<Rec_ti_category> Cat_a = new List<Rec_ti_category>();
                        foreach (LiteralStruct lit in HypList[i].literals)
                        {
                            if (lit.cedentType == CedentEnum.Antecedent)
                            {
                                rAnt.quant += lit.literalName;
                                foreach (string s in lit.categoriesNames)
                                {
                                    Rec_ti_category C = new Rec_ti_category();
                                    C.value = s;
                                    Cat_a.Add(C);
                                }

                            }
                        }

                        #endregion

                        #region element ti_cedent (Condition)

                        int litCounter = 0;  // counter of literals of this cedent
                        rCon.id = "con" + rHyp.id;
                        rCon.type = "Condition";
                        // literals
                        List<Rec_ti_literal> Lit_c = new List<Rec_ti_literal>();
                        foreach (BooleanLiteralStruct lit in HypList[i].booleanLiterals)
                        {
                            if (lit.cedentType == CedentEnum.Condition)
                            {
                                Rec_ti_literal l = new Rec_ti_literal();
                                l.id = "tiLit" + rHyp.id + "_" + litCounter.ToString();
                                litCounter++;
                                if (lit.negation)
                                    l.quant = "¬";
                                l.quant += lit.literalName;
                                int counter = 0;
                                foreach (string s in lit.categoriesNames)
                                {
                                    if (counter > 0)
                                        l.value += ",";
                                    l.value += s;
                                    counter++;
                                }
                                Lit_c.Add(l);
                            }
                        }

                        #endregion

                        #region element ti_cedent (Set1)

                        rSet1.id = rHyp.set1;
                        rSet1.type = "First Set";
                        // literals
                        List<Rec_ti_literal> Lit_s1 = new List<Rec_ti_literal>();
                        foreach (BooleanLiteralStruct lit in HypList[i].booleanLiterals)
                        {
                            if (lit.cedentType == CedentEnum.FirstSet)
                            {
                                Rec_ti_literal l = new Rec_ti_literal();
                                l.id = "tiLit" + rHyp.id + "_" + litCounter.ToString();
                                litCounter++;
                                if (lit.negation)
                                    l.quant = "¬";
                                l.quant += lit.literalName;
                                int counter = 0;
                                foreach (string s in lit.categoriesNames)
                                {
                                    if (counter > 0)
                                        l.value += ",";
                                    l.value += s;
                                    counter++;
                                }
                                Lit_s1.Add(l);
                            }
                        }

                        #endregion

                        #region element ti_cedent (Set2)

                        rSet2.id = rHyp.set2;
                        rSet2.type = "Second Set";
                        // literals
                        List<Rec_ti_literal> Lit_s2 = new List<Rec_ti_literal>();
                        foreach (BooleanLiteralStruct lit in HypList[i].booleanLiterals)
                        {
                            if (lit.cedentType == CedentEnum.SecondSet)
                            {
                                Rec_ti_literal l = new Rec_ti_literal();
                                l.id = "tiLit" + rHyp.id + "_" + litCounter.ToString();
                                litCounter++;
                                if (lit.negation)
                                    l.quant = "¬";
                                l.quant += lit.literalName;
                                int counter = 0;
                                foreach (string s in lit.categoriesNames)
                                {
                                    if (counter > 0)
                                        l.value += ",";
                                    l.value += s;
                                    counter++;
                                }
                                Lit_s2.Add(l);
                            }
                        }

                        #endregion

                        #region Generating of one hypotheses to XML string

                        string oneHypString = "";
                        // generating hypotheses to XML
                        oneHypString += rHyp.ToXML();
                        // generating Attributes (Antecedent) to XML
                        oneHypString += rAnt.ToXML(Cat_a);
                        // generating Condition to XML
                        oneHypString += rCon.ToXML(Lit_c);
                        // generating Set1 to XML
                        oneHypString += rSet1.ToXML(Lit_s1);
                        // generating Set2 to XML
                        oneHypString += rSet2.ToXML(Lit_s2);

                        resultString += oneHypString;

                        #endregion
                    }
                    #endregion
                }
                catch (System.Exception e)
                {
                    ErrStr += "Box ProjectIdentifier=" + box.ProjectIdentifier.ToString() + ": " + e.Message + "\n";
                }
            }
            #endregion

            // root element
            resultString += "</active_list>";

            #if (LADENI)
            // generating of error message:
            if (!String.IsNullOrEmpty(ErrStr))  // LADICI
                MessageBox.Show("Pri nacitani SD-CF hypotheses doslo k chybam:\n" + ErrStr, "Chyba", MessageBoxButtons.OK, MessageBoxIcon.Error);

            // LADICI - Kody - storing output to file "XMLsd4fthypExample.xml" in directory
            XMLHelper.saveXMLexample(resultString, "../XML/XMLsdcfhypExample.xml");
            #endif

            return resultString;
        }
        /// <summary>
        /// Returns XML string with all occurences of Active element "SD-4FFT hypothesis".
        /// </summary>
        /// <param name="index">index of data source in FEplugin data sources table</param>
        /// <returns>XML string</returns>
        public static string getList(int index)
        {
            string resultString = ""; // result XML string

            // loading DTD to resultString
            try { resultString = XMLHelper.loadDTD(); }
            catch (Exception e)
            {
#if (LADENI)
                MessageBox.Show("error while loading DTD: " + e.Message);
#endif
                return(resultString);
            }

            // root element
            resultString += "<active_list>";

            string PropName = "Hypotheses";  // name of property which contain a list of hypotheses
            // searching all boxes SD-4FT-uloh
            IBoxModule[] TaskBoxes = BoxesHelper.ListBoxesWithID(CFEsourcesTab.Sources[index] as CFEsource, "LISpMinerTasks.SDFFTTask");

            // processing of each box - searching all 4ft-hypotheses
            string ErrStr = "";             // error report

            string matrix_name = "unknown"; // analyzed data matrix name
            string db_name     = "unknown"; // analyzed database name
            string task_name   = "unknown"; // task name - given with user name of box FFTTast

            // creating delegate of quantifier function - "sum of value"
            ContingencyTable.QuantifierValue <FourFoldContingencyTable> sum_delegat = new ContingencyTable.QuantifierValue <FourFoldContingencyTable>(FourFoldContingencyTable.GetSumOfValues);



            #region Loop - processing of each SD-4ft-Task from array TaskBoxes

            foreach (IBoxModule box in TaskBoxes)
            {
                try
                {
                    // searching data source name (database)
                    IBoxModule[] db_names = BoxesHelper.ListAncestBoxesWithID(box, "DataMiningCommon.Database");
                    if (db_names.GetLength(0) != 1)  // searched more than one data source or neither one
                    {
                        throw new System.Exception("found " + db_names.GetLength(0).ToString() + " databases");
                    }
                    db_name = (db_names[0].GetPropertyOther("DatabaseName") as StringT).stringValue;

                    // searching data matrix name
                    IBoxModule[] matrix_names = BoxesHelper.ListAncestBoxesWithID(box, "DataMiningCommon.DataMatrix");
                    if (matrix_names.GetLength(0) != 1)  // searched more than one data source or neither one
                    {
                        throw new System.Exception("found " + matrix_names.GetLength(0).ToString() + " data matrixes");
                    }
                    matrix_name = (matrix_names[0].GetPropertyOther("Name") as StringT).stringValue;

                    // searching task name
                    task_name = box.UserName;

                    // searching the list of all hypotheses in this task
                    HypothesesT        HypT    = box.GetPropertyOther(PropName) as HypothesesT;
                    HypothesisStruct[] HypList = HypT.hypothesesValue.Clone() as HypothesisStruct[];

                    // records for storing the results
                    Rec_hyp_sd4ft rHyp  = new Rec_hyp_sd4ft(); // hypothesis
                    Rec_ti_cedent rAnt  = new Rec_ti_cedent(); // antecedent
                    Rec_ti_cedent rSuc  = new Rec_ti_cedent(); // succedent
                    Rec_ti_cedent rCon  = new Rec_ti_cedent(); // condition
                    Rec_ti_cedent rSet1 = new Rec_ti_cedent(); // set 1
                    Rec_ti_cedent rSet2 = new Rec_ti_cedent(); // set 2

                    #region Loop - processing of each hypotheses of one SDFFTTask box
                    // Loop over all hypotheses
                    for (int i = 0; i < HypList.GetLength(0); i++)
                    {
                        #region element hyp_sd4ft

                        rHyp.id          = "hypsd4ft" + box.ProjectIdentifier.ToString() + "_" + i.ToString();
                        rHyp.db_name     = db_name;
                        rHyp.matrix_name = matrix_name;
                        rHyp.task_name   = task_name;
                        rHyp.antecedent  = "ant" + rHyp.id;
                        rHyp.succedent   = "suc" + rHyp.id;
                        rHyp.condition   = "con" + rHyp.id;
                        rHyp.set1        = "set1" + rHyp.id;
                        rHyp.set2        = "set2" + rHyp.id;
                        FourFoldContingencyTable FFT1 = new FourFoldContingencyTable(HypList[i].quantifierSetting.firstContingencyTableRows);
                        FourFoldContingencyTable FFT2 = new FourFoldContingencyTable(HypList[i].quantifierSetting.secondContingencyTableRows);
                        rHyp.a = FFT1.A.ToString();
                        rHyp.b = FFT1.B.ToString();
                        rHyp.c = FFT1.C.ToString();
                        rHyp.d = FFT1.D.ToString();
                        rHyp.e = FFT2.A.ToString();
                        rHyp.f = FFT2.B.ToString();
                        rHyp.g = FFT2.C.ToString();
                        rHyp.h = FFT2.D.ToString();

                        // values of quantifiers - first set
                        double conf1 = FourFoldContingencyTable.FoundedImplicationValue(FFT1);              // Founded implication (a/a+b)
                        rHyp.conf1 = conf1.ToString();
                        double d_conf1 = FourFoldContingencyTable.DoubleFoundedImplicationValue(FFT1);      // Double Founded implication (a/a+b+c)
                        rHyp.d_conf1 = d_conf1.ToString();
                        double e_conf1 = FourFoldContingencyTable.FoundedEquivalenceValue(FFT1);            // Founded Equivalence (a+d)/(a+b+c+d)  ??? BUG ve Ferdovi
                        rHyp.e_conf1  = e_conf1.ToString();
                        rHyp.support1 = FourFoldContingencyTable.BaseCeilValue(FFT1).ToString();            //???  Support (a/a+b+c+d)
                        // helping variable
                        double avg_diff1 = FourFoldContingencyTable.AboveAverageImplicationValue(FFT1) - 1; // Averafe difference ((a*(a+b+c+d))/((a+b)*(a+c)) -1)
                        rHyp.avg_diff1 = avg_diff1.ToString();
                        rHyp.fisher1   = FFT1.FisherValue().ToString();
                        rHyp.chi_sq1   = FFT1.ChiSquareValue().ToString();

                        // values of quantifiers - second set
                        double conf2 = FourFoldContingencyTable.FoundedImplicationValue(FFT2);              // Founded implication (a/a+b)
                        rHyp.conf2 = conf2.ToString();
                        double d_conf2 = FourFoldContingencyTable.DoubleFoundedImplicationValue(FFT2);      // Double Founded implication (a/a+b+c)
                        rHyp.d_conf2 = d_conf2.ToString();
                        double e_conf2 = FourFoldContingencyTable.FoundedEquivalenceValue(FFT2);            // Founded Equivalence (a+d)/(a+b+c+d)  ??? BUG ve Ferdovi
                        rHyp.e_conf2  = e_conf2.ToString();
                        rHyp.support2 = FourFoldContingencyTable.BaseCeilValue(FFT2).ToString();            //???  Support (a/a+b+c+d)
                        // helping variable
                        double avg_diff2 = FourFoldContingencyTable.AboveAverageImplicationValue(FFT2) - 1; // Averafe difference ((a*(a+b+c+d))/((a+b)*(a+c)) -1)
                        rHyp.avg_diff2 = avg_diff2.ToString();
                        rHyp.fisher2   = FFT2.FisherValue().ToString();
                        rHyp.chi_sq2   = FFT2.ChiSquareValue().ToString();

                        // values of quantifiers - diffrent of first and second set
                        rHyp.dr_sum = FourFoldContingencyTable.Value <FourFoldContingencyTable>(sum_delegat, FFT1, FFT2, OperationModeEnum.DifferencesOfRelativeFrequencies).ToString();
                        double df_conf = FourFoldContingencyTable.Combine(conf1, conf2, OperationModeEnum.DifferenceOfQuantifierValues);
                        rHyp.df_conf = df_conf.ToString();
                        double df_dfui = FourFoldContingencyTable.Combine(d_conf1, d_conf2, OperationModeEnum.DifferenceOfQuantifierValues);
                        rHyp.df_dfui = df_dfui.ToString();
                        double df_fue = FourFoldContingencyTable.Combine(e_conf1, e_conf2, OperationModeEnum.DifferenceOfQuantifierValues);
                        rHyp.df_fue = df_fue.ToString();
                        double df_avg = FourFoldContingencyTable.Combine(avg_diff1, avg_diff2, OperationModeEnum.DifferenceOfQuantifierValues);
                        rHyp.df_avg = df_avg.ToString();

                        #endregion

                        #region element ti_cedent (Antecedent)

                        rAnt.id   = rHyp.antecedent;
                        rAnt.type = "Antecedent";
                        // literals
                        int litCounter = 0;  // counter of literals of this hypotheses
                        List <Rec_ti_literal> Lit_a = new List <Rec_ti_literal>();
                        foreach (BooleanLiteralStruct lit in HypList[i].booleanLiterals)
                        {
                            if (lit.cedentType == CedentEnum.Antecedent)
                            {
                                Rec_ti_literal l = new Rec_ti_literal();
                                l.id = "tiLit" + rHyp.id + "_" + litCounter.ToString();
                                litCounter++;
                                if (lit.negation)
                                {
                                    l.quant = "¬";
                                }
                                l.quant += lit.literalName;
                                int counter = 0;
                                foreach (string s in lit.categoriesNames)
                                {
                                    if (counter > 0)
                                    {
                                        l.value += ",";
                                    }
                                    l.value += s;
                                    counter++;
                                }
                                Lit_a.Add(l);
                            }
                        }

                        #endregion

                        #region element ti_cedent (Succedent)

                        rSuc.id   = rHyp.succedent;
                        rSuc.type = "Succedent";
                        // literals
                        List <Rec_ti_literal> Lit_s = new List <Rec_ti_literal>();
                        foreach (BooleanLiteralStruct lit in HypList[i].booleanLiterals)
                        {
                            if (lit.cedentType == CedentEnum.Succedent)
                            {
                                Rec_ti_literal l = new Rec_ti_literal();
                                l.id = "tiLit" + rHyp.id + "_" + litCounter.ToString();
                                litCounter++;
                                if (lit.negation)
                                {
                                    l.quant = "¬";
                                }
                                l.quant += lit.literalName;
                                int counter = 0;
                                foreach (string s in lit.categoriesNames)
                                {
                                    if (counter > 0)
                                    {
                                        l.value += ",";
                                    }
                                    l.value += s;
                                    counter++;
                                }
                                Lit_s.Add(l);
                            }
                        }

                        #endregion

                        #region element ti_cedent (Condition)

                        rCon.id   = rHyp.condition;
                        rCon.type = "Condition";
                        // literals
                        List <Rec_ti_literal> Lit_c = new List <Rec_ti_literal>();
                        foreach (BooleanLiteralStruct lit in HypList[i].booleanLiterals)
                        {
                            if (lit.cedentType == CedentEnum.Condition)
                            {
                                Rec_ti_literal l = new Rec_ti_literal();
                                l.id = "tiLit" + rHyp.id + "_" + litCounter.ToString();
                                litCounter++;
                                if (lit.negation)
                                {
                                    l.quant = "¬";
                                }
                                l.quant += lit.literalName;
                                int counter = 0;
                                foreach (string s in lit.categoriesNames)
                                {
                                    if (counter > 0)
                                    {
                                        l.value += ",";
                                    }
                                    l.value += s;
                                    counter++;
                                }
                                Lit_c.Add(l);
                            }
                        }

                        #endregion

                        #region element ti_cedent (First Set)

                        rSet1.id   = rHyp.set1;
                        rSet1.type = "First Set";
                        // literals
                        List <Rec_ti_literal> Lit_s1 = new List <Rec_ti_literal>();
                        foreach (BooleanLiteralStruct lit in HypList[i].booleanLiterals)
                        {
                            if (lit.cedentType == CedentEnum.FirstSet)
                            {
                                Rec_ti_literal l = new Rec_ti_literal();
                                l.id = "tiLit" + rHyp.id + "_" + litCounter.ToString();
                                litCounter++;
                                if (lit.negation)
                                {
                                    l.quant = "¬";
                                }
                                l.quant += lit.literalName;
                                int counter = 0;
                                foreach (string s in lit.categoriesNames)
                                {
                                    if (counter > 0)
                                    {
                                        l.value += ",";
                                    }
                                    l.value += s;
                                    counter++;
                                }
                                Lit_s1.Add(l);
                            }
                        }

                        #endregion

                        #region element ti_cedent (Second Set)

                        rSet2.id   = rHyp.set2;
                        rSet2.type = "Second Set";
                        // literals
                        List <Rec_ti_literal> Lit_s2 = new List <Rec_ti_literal>();
                        foreach (BooleanLiteralStruct lit in HypList[i].booleanLiterals)
                        {
                            if (lit.cedentType == CedentEnum.SecondSet)
                            {
                                Rec_ti_literal l = new Rec_ti_literal();
                                l.id = "tiLit" + rHyp.id + "_" + litCounter.ToString();
                                litCounter++;
                                if (lit.negation)
                                {
                                    l.quant = "¬";
                                }
                                l.quant += lit.literalName;
                                int counter = 0;
                                foreach (string s in lit.categoriesNames)
                                {
                                    if (counter > 0)
                                    {
                                        l.value += ",";
                                    }
                                    l.value += s;
                                    counter++;
                                }
                                Lit_s2.Add(l);
                            }
                        }

                        #endregion

                        #region Generating of one hypotheses to XML string

                        string oneHypString = "";
                        // generating hypotheses to XML
                        oneHypString += rHyp.ToXML();
                        // generating Antecedent to XML
                        oneHypString += rAnt.ToXML(Lit_a);
                        // generating Succedent to XML
                        oneHypString += rSuc.ToXML(Lit_s);
                        // generating Condition to XML
                        oneHypString += rCon.ToXML(Lit_c);
                        // generating First Set to XML
                        oneHypString += rSet1.ToXML(Lit_s1);
                        // generating Second Set to XML
                        oneHypString += rSet2.ToXML(Lit_s2);


                        resultString += oneHypString;

                        #endregion
                    }
                    #endregion
                }
                catch (System.Exception e)
                {
                    ErrStr += "Box ProjectIdentifier=" + box.ProjectIdentifier.ToString() + ": " + e.Message + "\n";
                }
            }
            #endregion

            // root element
            resultString += "</active_list>";

#if (LADENI)
            // generating of error message:
            if (!String.IsNullOrEmpty(ErrStr))  // LADICI
            {
                MessageBox.Show("Pri nacitani SD4FT hypotheses doslo k chybam:\n" + ErrStr, "Chyba", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            // LADICI - Kody - storing output to file "XMLsd4fthypExample.xml" in directory
            XMLHelper.saveXMLexample(resultString, "../XML/XMLsd4fthypExample.xml");
#endif

            return(resultString);
        }