using System; using System.Collections.Generic; using System.Linq; using System.Web; using HLWebOKBQueryPlugin.OKBQueryService; namespace HLWebOKBQueryPlugin.Helpers { public class RunCollectionData : IResult, IParams { #region properties // Run public long Id { get; set; } // Result public string ExecutionTime { get; set; } public int EvaluatedSolutions { get; set; } public int Generations { get; set; } public string BestTSPSolution { get; set; } public double CurrentBestQuality { get; set; } public double CurrentAverageQuality { get; set; } public double CurrentWorstQuality { get; set; } public double BestQuality { get; set; } public double BestKnownQuality { get; set; } public double AbsoluteDifferenceBestKnownToBest { get; set; } public double RelativeDifferenceBestKnownToBest { get; set; } public string Qualities { get; set; } // Parameters public int Seed { get; set; } public bool SetSeedRandomly { get; set; } public int PopulationSize { get; set; } public string Selector { get; set; } public bool Selector_CopySelected { get; set; } public int Selector_NumberOfSelectedSubScopes { get; set; } public bool Selector_Windowing { get; set; } public string Crossover { get; set; } public double MutationProbability { get; set; } public string Mutator { get; set; } public int Elites { get; set; } public string Analyzer { get; set; } public int Analyzer_UpdateInterval { get; set; } public string Analyzer_1 { get; set; } public bool Analyzer_1_StoreHistory { get; set; } public int Analyzer_1_UpdateInterval { get; set; } public string Analyzer_2 { get; set; } public bool Analyzer_2_StoreHistory { get; set; } public int Analyzer_2_UpdateInterval { get; set; } public string Analyzer_0 { get; set; } public string Analyzer_3 { get; set; } public int MaximumGenerations { get; set; } public string AlgorithmName { get; set; } public string AlgorithmType { get; set; } public bool Maximization { get; set; } public string Coordinates { get; set; } public string DistanceMatrix { get; set; } public bool UseDistanceMatrix { get; set; } public string SolutionCreator { get; set; } public int SolutionCreator_Length { get; set; } public string SolutionCreator_PermutationType { get; set; } public string Evaluator { get; set; } public string BestKnownSolution { get; set; } public string ProblemName { get; set; } public string ProblemType { get; set; } #endregion #region constructor/initialisation public RunCollectionData(Run run) { Id = run.Id; // results ExecutionTime = (string)getValue("Execution Time", run.ResultValues); EvaluatedSolutions = (int)getValue("EvaluatedSolutions", run.ResultValues); Generations = (int)getValue("Generations", run.ResultValues); BestTSPSolution = (string)getValue("Best TSP Solution", run.ResultValues); CurrentBestQuality = (double)getValue("CurrentBestQuality", run.ResultValues); CurrentAverageQuality = (double)getValue("CurrentAverageQuality", run.ResultValues); CurrentWorstQuality = (double)getValue("CurrentWorstQuality", run.ResultValues); BestQuality = (double)getValue("BestQuality", run.ResultValues); BestKnownQuality = (double)getValue("BestKnownQuality", run.ResultValues); AbsoluteDifferenceBestKnownToBest = (double)getValue("AbsoluteDifferenceBestKnownToBest", run.ResultValues); RelativeDifferenceBestKnownToBest = (double)getValue("RelativeDifferenceBestKnownToBest", run.ResultValues); Qualities = (string)getValue("Qualities", run.ResultValues); // parameter Seed = (int)getValue("Seed", run.ParameterValues); SetSeedRandomly = (bool)getValue("SetSeedRandomly", run.ParameterValues); PopulationSize = (int)getValue("PopulationSize", run.ParameterValues); Selector = (string)getValue("Selector", run.ParameterValues); Selector_CopySelected = (bool)getValue("Selector.CopySelected", run.ParameterValues); Selector_NumberOfSelectedSubScopes = (int)getValue("Selector.NumberOfSelectedSubScopes", run.ParameterValues); Selector_Windowing = (bool)getValue("Selector.Windowing", run.ParameterValues); Crossover = (string)getValue("Crossover", run.ParameterValues); MutationProbability = (double)getValue("MutationProbability", run.ParameterValues); Mutator = (string)getValue("Mutator", run.ParameterValues); Elites = (int)getValue("Elites", run.ParameterValues); Analyzer = (string)getValue("Analyzer", run.ParameterValues); Analyzer_UpdateInterval = (int)getValue("Analyzer.UpdateInterval", run.ParameterValues); Analyzer_1 = (string)getValue("Analyzer.1", run.ParameterValues); Analyzer_1_StoreHistory = (bool)getValue("Analyzer.1.StoreHistory", run.ParameterValues); Analyzer_1_UpdateInterval = (int)getValue("Analyzer.1.UpdateInterval", run.ParameterValues); Analyzer_2 = (string)getValue("Analyzer.2", run.ParameterValues); Analyzer_2_StoreHistory = (bool)getValue("Analyzer.2.StoreHistory", run.ParameterValues); Analyzer_2_UpdateInterval = (int)getValue("Analyzer.2.UpdateInterval", run.ParameterValues); Analyzer_0 = (string)getValue("Analyzer.0", run.ParameterValues); Analyzer_3 = (string)getValue("Analyzer.3", run.ParameterValues); MaximumGenerations = (int)getValue("MaximumGenerations", run.ParameterValues); AlgorithmName = (string)getValue("Algorithm Name", run.ParameterValues); AlgorithmType = (string)getValue("Algorithm Type", run.ParameterValues); Maximization = (bool)getValue("Maximization", run.ParameterValues); Coordinates = (string)getValue("Coordinates", run.ParameterValues); DistanceMatrix = (string)getValue("DistanceMatrix", run.ParameterValues); UseDistanceMatrix = (bool)getValue("UseDistanceMatrix", run.ParameterValues); SolutionCreator = (string)getValue("SolutionCreator", run.ParameterValues); SolutionCreator_Length = (int)getValue("SolutionCreator.Length", run.ParameterValues); SolutionCreator_PermutationType = (string)getValue("SolutionCreator.PermutationType", run.ParameterValues); Evaluator = (string)getValue("Evaluator", run.ParameterValues); BestKnownQuality = (double)getValue("BestKnownQuality", run.ParameterValues); BestKnownSolution = (string)getValue("BestKnownSolution", run.ParameterValues); ProblemName = (string)getValue("Problem Name", run.ParameterValues); ProblemType = (string)getValue("Problem Type", run.ParameterValues); } #endregion private object getValue(string name, Value[] vals) { foreach (Value val in vals) { if (val.Name.Equals(name)) { if (val.DataType.Name == typeof(OKBQueryService.BinaryValue).Name) return ((BinaryValue)val).Value; else if (val.DataType.Name == typeof(OKBQueryService.BoolValue).Name) return ((BoolValue)val).Value; else if (val.DataType.Name == typeof(OKBQueryService.DoubleValue).Name) return ((DoubleValue)val).Value; else if (val.DataType.Name == typeof(OKBQueryService.FloatValue).Name) return ((FloatValue)val).Value; else if (val.DataType.Name == typeof(OKBQueryService.IntValue).Name) return ((IntValue)val).Value; else if (val.DataType.Name == typeof(OKBQueryService.LongValue).Name) return ((LongValue)val).Value; else if (val.DataType.Name == typeof(OKBQueryService.StringValue).Name) return ((StringValue)val).Value; else if (val.DataType.Name == "PercentValue") return ((DoubleValue)val).Value; else return val.DataType.Name; } } return null; } } }