Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Helpers/RunCollectionData.cs @ 8084

Last change on this file since 8084 was 6226, checked in by msammer, 13 years ago

#1446 rebuild the shown table. Now it is possible to make a right 'details'-call via an action within the MVC

File size: 8.6 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Web;
5
6using HLWebOKBQueryPlugin.OKBQueryService;
7
8namespace HLWebOKBQueryPlugin.Helpers {
9    public class RunCollectionData : IResult, IParams {
10
11        #region properties
12        // Run
13        public long Id { get; set; }
14
15        // Result
16        public string ExecutionTime { get; set; }
17        public int EvaluatedSolutions { get; set; }
18        public int Generations { get; set; }
19        public string BestTSPSolution { get; set; }
20        public double CurrentBestQuality { get; set; }
21        public double CurrentAverageQuality { get; set; }
22        public double CurrentWorstQuality { get; set; }
23        public double BestQuality { get; set; }
24        public double BestKnownQuality { get; set; }
25        public double AbsoluteDifferenceBestKnownToBest { get; set; }
26        public double RelativeDifferenceBestKnownToBest { get; set; }
27        public string Qualities { get; set; }
28
29        // Parameters
30        public int Seed { get; set; }
31        public bool SetSeedRandomly { get; set; }
32        public int PopulationSize { get; set; }
33        public string Selector { get; set; }
34        public bool Selector_CopySelected { get; set; }
35        public int Selector_NumberOfSelectedSubScopes { get; set; }
36        public bool Selector_Windowing { get; set; }
37        public string Crossover { get; set; }
38        public double MutationProbability { get; set; }
39        public string Mutator { get; set; }
40        public int Elites { get; set; }
41        public string Analyzer { get; set; }
42        public int Analyzer_UpdateInterval { get; set; }
43        public string Analyzer_1 { get; set; }
44        public bool Analyzer_1_StoreHistory { get; set; }
45        public int Analyzer_1_UpdateInterval { get; set; }
46        public string Analyzer_2 { get; set; }
47        public bool Analyzer_2_StoreHistory { get; set; }
48        public int Analyzer_2_UpdateInterval { get; set; }
49        public string Analyzer_0 { get; set; }
50        public string Analyzer_3 { get; set; }
51        public int MaximumGenerations { get; set; }
52        public string AlgorithmName { get; set; }
53        public string AlgorithmType { get; set; }
54        public bool Maximization { get; set; }
55        public string Coordinates { get; set; }
56        public string DistanceMatrix { get; set; }
57        public bool UseDistanceMatrix { get; set; }
58        public string SolutionCreator { get; set; }
59        public int SolutionCreator_Length { get; set; }
60        public string SolutionCreator_PermutationType { get; set; }
61        public string Evaluator { get; set; }
62        public string BestKnownSolution { get; set; }
63        public string ProblemName { get; set; }
64        public string ProblemType { get; set; }
65#endregion
66
67        #region constructor/initialisation
68        public RunCollectionData(Run run) {
69            Id = run.Id;
70
71            // results
72            ExecutionTime = (string)getValue("Execution Time", run.ResultValues);
73            EvaluatedSolutions = (int)getValue("EvaluatedSolutions", run.ResultValues);
74            Generations = (int)getValue("Generations", run.ResultValues);
75            BestTSPSolution = (string)getValue("Best TSP Solution", run.ResultValues);
76            CurrentBestQuality = (double)getValue("CurrentBestQuality", run.ResultValues);
77            CurrentAverageQuality = (double)getValue("CurrentAverageQuality", run.ResultValues);
78            CurrentWorstQuality = (double)getValue("CurrentWorstQuality", run.ResultValues);
79            BestQuality = (double)getValue("BestQuality", run.ResultValues);
80            BestKnownQuality = (double)getValue("BestKnownQuality", run.ResultValues);
81            AbsoluteDifferenceBestKnownToBest = (double)getValue("AbsoluteDifferenceBestKnownToBest", run.ResultValues);
82            RelativeDifferenceBestKnownToBest = (double)getValue("RelativeDifferenceBestKnownToBest", run.ResultValues);
83            Qualities = (string)getValue("Qualities", run.ResultValues);
84
85            // parameter
86            Seed = (int)getValue("Seed", run.ParameterValues);
87            SetSeedRandomly = (bool)getValue("SetSeedRandomly", run.ParameterValues);
88            PopulationSize = (int)getValue("PopulationSize", run.ParameterValues);
89            Selector = (string)getValue("Selector", run.ParameterValues);
90            Selector_CopySelected = (bool)getValue("Selector.CopySelected", run.ParameterValues);
91            Selector_NumberOfSelectedSubScopes = (int)getValue("Selector.NumberOfSelectedSubScopes", run.ParameterValues);
92            Selector_Windowing = (bool)getValue("Selector.Windowing", run.ParameterValues);
93            Crossover = (string)getValue("Crossover", run.ParameterValues);
94            MutationProbability = (double)getValue("MutationProbability", run.ParameterValues);
95            Mutator = (string)getValue("Mutator", run.ParameterValues);
96
97            Elites = (int)getValue("Elites", run.ParameterValues);
98            Analyzer = (string)getValue("Analyzer", run.ParameterValues);
99            Analyzer_UpdateInterval = (int)getValue("Analyzer.UpdateInterval", run.ParameterValues);
100            Analyzer_1 = (string)getValue("Analyzer.1", run.ParameterValues);
101            Analyzer_1_StoreHistory = (bool)getValue("Analyzer.1.StoreHistory", run.ParameterValues);
102            Analyzer_1_UpdateInterval = (int)getValue("Analyzer.1.UpdateInterval", run.ParameterValues);
103            Analyzer_2 = (string)getValue("Analyzer.2", run.ParameterValues);
104            Analyzer_2_StoreHistory = (bool)getValue("Analyzer.2.StoreHistory", run.ParameterValues);
105            Analyzer_2_UpdateInterval = (int)getValue("Analyzer.2.UpdateInterval", run.ParameterValues);
106            Analyzer_0 = (string)getValue("Analyzer.0", run.ParameterValues);
107
108            Analyzer_3 = (string)getValue("Analyzer.3", run.ParameterValues);
109            MaximumGenerations = (int)getValue("MaximumGenerations", run.ParameterValues);
110            AlgorithmName = (string)getValue("Algorithm Name", run.ParameterValues);
111            AlgorithmType = (string)getValue("Algorithm Type", run.ParameterValues);
112            Maximization = (bool)getValue("Maximization", run.ParameterValues);
113            Coordinates = (string)getValue("Coordinates", run.ParameterValues);
114            DistanceMatrix = (string)getValue("DistanceMatrix", run.ParameterValues);
115            UseDistanceMatrix = (bool)getValue("UseDistanceMatrix", run.ParameterValues);
116            SolutionCreator = (string)getValue("SolutionCreator", run.ParameterValues);
117            SolutionCreator_Length = (int)getValue("SolutionCreator.Length", run.ParameterValues);
118
119            SolutionCreator_PermutationType = (string)getValue("SolutionCreator.PermutationType", run.ParameterValues);
120            Evaluator = (string)getValue("Evaluator", run.ParameterValues);
121            BestKnownQuality = (double)getValue("BestKnownQuality", run.ParameterValues);
122            BestKnownSolution = (string)getValue("BestKnownSolution", run.ParameterValues);
123            ProblemName = (string)getValue("Problem Name", run.ParameterValues);
124            ProblemType = (string)getValue("Problem Type", run.ParameterValues);
125
126        }
127        #endregion
128
129        private object getValue(string name, Value[] vals) {
130            foreach (Value val in vals) {
131                if (val.Name.Equals(name)) {
132                    if (val.DataType.Name == typeof(OKBQueryService.BinaryValue).Name)
133                        return ((BinaryValue)val).Value;
134                    else if (val.DataType.Name == typeof(OKBQueryService.BoolValue).Name)
135                        return ((BoolValue)val).Value;
136                    else if (val.DataType.Name == typeof(OKBQueryService.DoubleValue).Name)
137                        return ((DoubleValue)val).Value;
138                    else if (val.DataType.Name == typeof(OKBQueryService.FloatValue).Name)
139                        return ((FloatValue)val).Value;
140                    else if (val.DataType.Name == typeof(OKBQueryService.IntValue).Name)
141                        return ((IntValue)val).Value;
142                    else if (val.DataType.Name == typeof(OKBQueryService.LongValue).Name)
143                        return ((LongValue)val).Value;
144                    else if (val.DataType.Name == typeof(OKBQueryService.StringValue).Name)
145                        return ((StringValue)val).Value;
146                    else if (val.DataType.Name == "PercentValue")
147                        return ((DoubleValue)val).Value;
148                    else
149                        return val.DataType.Name;
150                }
151            }
152            return null;
153        }
154
155    }
156}
Note: See TracBrowser for help on using the repository browser.