Exemplo n.º 1
0
        static void daErdalAlgorithm()
        {
            for (int TestOrder = 0; TestOrder < TESTCASE_LIST.Count; TestOrder++)
            {
                for (int orderOfFailingConfig = 0; orderOfFailingConfig < TESTCASE_LIST[TestOrder].getFailingList().Count; orderOfFailingConfig++)
                {
                    Configuration originalFailingConfig = new Configuration();
                    originalFailingConfig.setEqualTo(TESTCASE_LIST[TestOrder].getFailingList()[orderOfFailingConfig]);

                    List<Item> ruleViolatingOptions = getRuleViolatingOptions(originalFailingConfig,TestOrder);

                    if (ruleViolatingOptions != null)
                    {
                        List<List<string>> subsetOfFailingOptions = getSubset(ruleViolatingOptions);

                        for (int subsetOrder = 0; subsetOrder < subsetOfFailingOptions.Count; subsetOrder++)
                        {
                            List<List<Item>> changeList = getTruthTable(subsetOfFailingOptions[subsetOrder]);
                            for (int changeOrder = 0; changeOrder < changeList.Count; changeOrder++)
                            {
                                Configuration changedConfig = applyChange(originalFailingConfig, changeList[changeOrder]);
                                bool configPasses = doesThisConfigPass(changedConfig, TestOrder);

                                if (configPasses)
                                {
                                    if (!doesExistInScoreList(changedConfig))
                                    {
                                        int score = calculateScore(changedConfig, TestOrder);
                                        if (score > 0)
                                        {
                                            Triplet tr = new Triplet(originalFailingConfig, changedConfig, score);
                                            TRIPLET_LIST.Add(tr);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    TRIPLET_LIST.Sort(delegate(Triplet a, Triplet b) { return a.getScore().CompareTo(b.getScore()); });

                    if (TRIPLET_LIST.Count > 0)
                    {
                        Configuration toAdd = new Configuration();
                        toAdd.setEqualTo(TRIPLET_LIST[TRIPLET_LIST.Count - 1].getChangedConf());
                        Configuration orig = new Configuration();
                        orig.setEqualTo(TRIPLET_LIST[TRIPLET_LIST.Count - 1].getOriginalConf());

                        toAdd.setResult("p");
                        TESTCASE_LIST[TestOrder].addNewConfiguration(toAdd);

                        Console.Write("**old**\t");
                        print(orig);
                        Console.Write("**new**\t");
                        print(toAdd);
                        Console.Write("\n");

                        TRIPLET_LIST.RemoveAt(TRIPLET_LIST.Count - 1);

                        if (CHOOSE_GLOBAL)
                        {
                            updateTripletList(TestOrder);
                        }
                        else
                        {
                            TRIPLET_LIST.Clear();
                        }
                    }
                }

                TRIPLET_LIST.Clear();
            }
        }
Exemplo n.º 2
0
        //given a changed configuration, check if that configuration was in TRIPLE_LIST before
        static bool doesExistInScoreList(Configuration input)
        {
            for (int counter = 0; counter < TRIPLET_LIST.Count; counter++)
            {
                bool exists = true;

                Triplet tempTrip = new Triplet();
                tempTrip.setEqualTo(TRIPLET_LIST[counter]);

                List<Item> tripOptionList = tempTrip.getChangedConf().getItemList();
                List<Item> inputOptionList = input.getItemList();

                for (int a = 0; a < inputOptionList.Count; a++)
                {
                    if (!doesExist(tripOptionList, inputOptionList[a]))
                        exists = false;
                }

                if (exists)
                    return true;
            }
            return false;
        }
Exemplo n.º 3
0
 public void setEqualTo(Triplet param1)
 {
     setChangedConf(param1.getChangedConf());
     setOriginalConf(param1.getOriginalConf());
     setScore(param1.getScore());
 }