public readonly long elapsedTime; // in milliseconds

        //public readonly double densityDiffAverage, densityDifferenceDeviation;
        //public readonly double editDistanceAverage, editDistanceDeviation;

        public MeasurementResultSet(PDLPred originalFormula, IEnumerable<PDLPred> generatedFormulas, long time, VariableCache.ConstraintMode constraintmode, 
            PdlFilter.Filtermode filtermode, HashSet<char> alphabet, IDictionary<PDLPred, SingleMeasurementResult> cache,
            IDictionary<Automaton<BDD>, SingleMeasurementResult> automatonCache)
        {
            this.originalFormula = originalFormula;
            this.alphabet = alphabet;
            this.originalAutomaton = originalFormula.GetDFA(alphabet, new CharSetSolver());

            this.constraintmode = constraintmode;
            this.filtermode = filtermode;

            this.elapsedTime = time;

            this.results = new List<SingleMeasurementResult>();

            foreach (PDLPred generatedFormula in generatedFormulas)
            {
                SingleMeasurementResult result;
                if (cache.ContainsKey(generatedFormula))
                {
                    result = cache[generatedFormula];
                }
                else
                {
                    result = SingleMeasurementResult.Create(this.originalAutomaton, generatedFormula, this.alphabet, automatonCache);
                    cache[generatedFormula] = result;
                }
                this.results.Add(result);
            }

            // Compute statistics
            /*
            double densityDiffSum = 0;
            int editDistanceSum = 0;

            foreach (SingleMeasurementResult result in this.results)
            {
                densityDiffSum += result.densityDiff;
                editDistanceSum += result.editDistance;
            }

            this.densityDiffAverage = ((double)densityDiffSum) / ((double)this.results.Count);
            this.editDistanceAverage = ((double)editDistanceSum) / ((double)this.results.Count);

            double densityDiffDeviation = 0;
            double editDistanceDeviation = 0;
            foreach (SingleMeasurementResult result in this.results)
            {
                densityDiffDeviation += Math.Pow(result.densityDiff - this.densityDiffAverage, 2.0);
                editDistanceDeviation += Math.Pow(((double)result.editDistance) - this.editDistanceAverage, 2.0);
            }
            densityDiffDeviation /= this.results.Count;
            densityDiffDeviation = Math.Sqrt(densityDiffDeviation);

            editDistanceDeviation /= this.results.Count;
            editDistanceDeviation = Math.Sqrt(editDistanceDeviation);
            */
        }
 public ICollection<PDLPred> FilterPredicates(PdlFilter filter, ICollection<PDLPred> candidates)
 {
     ICollection<PDLPred> returnValue = new HashSet<PDLPred>();
     foreach (PDLPred candidate in candidates)
     {
         if(filter.KeepPredicate(candidate)) {
             returnValue.Add(candidate);
         }
     }
     return returnValue;
 }
 private string GetFilenameTest(Testcase testcase, VariableCache.ConstraintMode constraintMode, PdlFilter.Filtermode filtermode)
 {
     return String.Format("C:/Users/alexander/Desktop/results/{0}.{1}.{2}.csv", testcase.id, constraintMode, filtermode);
 }
        public Measurement.MeasurementResultSet RunBenchmark(Testcase testcase, VariableCache.ConstraintMode constraintMode, PdlFilter.Filtermode filtermode, IDictionary<PDLPred, Measurement.SingleMeasurementResult> cache, IDictionary<Automaton<BDD>, Measurement.SingleMeasurementResult> automatonCache)
        {
            ICollection<PDLPred> bareResults = new LinkedList<PDLPred>();

            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
            stopwatch.Start();
            foreach(PDLPred result in ProblemGeneration.GeneratePDLWithEDn(testcase.language, testcase.alphabet, constraintMode, filtermode)) {
                bareResults.Add(result);
            }
            stopwatch.Stop();

            return new Measurement.MeasurementResultSet(testcase.language, bareResults, stopwatch.ElapsedMilliseconds, constraintMode, filtermode, new HashSet<char>(testcase.alphabet), cache, automatonCache);
        }
 public ConsFilter(PdlFilter firstFilter, PdlFilter secondFilter)
 {
     this.firstFilter = firstFilter;
     this.secondFilter = secondFilter;
 }
        public static IEnumerable<PDLPred> GeneratePDLWithEDn(PDLPred phi, IEnumerable<char> alphabet, VariableCache.ConstraintMode constConst, PdlFilter.Filtermode filtermode)
        {
            CPDLPred choiceTree = phi.GetCPDL();
            HashSet<char> alphabetHashSet = new HashSet<char>(alphabet);

            PdlFilter filter = PdlFilter.Create(filtermode, phi, alphabetHashSet);

            // Concretize yields all feasible concretizations of the choiceTree
            foreach(PDLPred candidate in Concretize(choiceTree, alphabetHashSet, constConst)) {
                if (filter.KeepPredicate(candidate) == true)
                {
                    yield return candidate;
                }
            }
        }