1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
4 | *
|
---|
5 | * This file is part of HeuristicLab.
|
---|
6 | *
|
---|
7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
10 | * (at your option) any later version.
|
---|
11 | *
|
---|
12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 | #endregion
|
---|
21 |
|
---|
22 | using System.Collections.Generic;
|
---|
23 | using System.Linq;
|
---|
24 | using HeuristicLab.Services.OKB.DataAccess;
|
---|
25 |
|
---|
26 | namespace HeuristicLab.Services.OKB {
|
---|
27 | public class ExperimentEqualityComparer : IEqualityComparer<Experiment> {
|
---|
28 | public bool Equals(Experiment x, Experiment y) {
|
---|
29 | bool equal = true;
|
---|
30 | equal = equal && x.AlgorithmId == y.AlgorithmId;
|
---|
31 | equal = equal && x.ProblemId == y.ProblemId;
|
---|
32 | equal = equal && x.AlgorithmParameterBlobValues.Count == y.AlgorithmParameterBlobValues.Count;
|
---|
33 | equal = equal && x.AlgorithmParameterBoolValues.Count == y.AlgorithmParameterBoolValues.Count;
|
---|
34 | equal = equal && x.AlgorithmParameterFloatValues.Count == y.AlgorithmParameterFloatValues.Count;
|
---|
35 | equal = equal && x.AlgorithmParameterIntValues.Count == y.AlgorithmParameterIntValues.Count;
|
---|
36 | equal = equal && x.AlgorithmParameterStringValues.Count == y.AlgorithmParameterStringValues.Count;
|
---|
37 | equal = equal && x.ProblemParameterBlobValues.Count == y.ProblemParameterBlobValues.Count;
|
---|
38 | equal = equal && x.ProblemParameterBoolValues.Count == y.ProblemParameterBoolValues.Count;
|
---|
39 | equal = equal && x.ProblemParameterFloatValues.Count == y.ProblemParameterFloatValues.Count;
|
---|
40 | equal = equal && x.ProblemParameterIntValues.Count == y.ProblemParameterIntValues.Count;
|
---|
41 | equal = equal && x.ProblemParameterStringValues.Count == y.ProblemParameterStringValues.Count;
|
---|
42 |
|
---|
43 | if (equal) {
|
---|
44 | var values = x.AlgorithmParameterBlobValues.Zip(y.AlgorithmParameterBlobValues, (a, b) => new { X = a, Y = b });
|
---|
45 | foreach (var value in values) {
|
---|
46 | equal = equal && value.X.AlgorithmParameterId == value.Y.AlgorithmParameterId;
|
---|
47 | equal = equal && value.X.DataTypeId == value.Y.DataTypeId;
|
---|
48 | equal = equal && value.X.Value.Equals(value.Y.Value);
|
---|
49 | }
|
---|
50 | }
|
---|
51 | if (equal) {
|
---|
52 | var values = x.AlgorithmParameterBoolValues.Zip(y.AlgorithmParameterBoolValues, (a, b) => new { X = a, Y = b });
|
---|
53 | foreach (var value in values) {
|
---|
54 | equal = equal && value.X.AlgorithmParameterId == value.Y.AlgorithmParameterId;
|
---|
55 | equal = equal && value.X.DataTypeId == value.Y.DataTypeId;
|
---|
56 | equal = equal && value.X.Value == value.Y.Value;
|
---|
57 | }
|
---|
58 | }
|
---|
59 | if (equal) {
|
---|
60 | var values = x.AlgorithmParameterFloatValues.Zip(y.AlgorithmParameterFloatValues, (a, b) => new { X = a, Y = b });
|
---|
61 | foreach (var value in values) {
|
---|
62 | equal = equal && value.X.AlgorithmParameterId == value.Y.AlgorithmParameterId;
|
---|
63 | equal = equal && value.X.DataTypeId == value.Y.DataTypeId;
|
---|
64 | equal = equal && value.X.Value == value.Y.Value;
|
---|
65 | }
|
---|
66 | }
|
---|
67 | if (equal) {
|
---|
68 | var values = x.AlgorithmParameterIntValues.Zip(y.AlgorithmParameterIntValues, (a, b) => new { X = a, Y = b });
|
---|
69 | foreach (var value in values) {
|
---|
70 | equal = equal && value.X.AlgorithmParameterId == value.Y.AlgorithmParameterId;
|
---|
71 | equal = equal && value.X.DataTypeId == value.Y.DataTypeId;
|
---|
72 | equal = equal && value.X.Value == value.Y.Value;
|
---|
73 | }
|
---|
74 | }
|
---|
75 | if (equal) {
|
---|
76 | var values = x.AlgorithmParameterStringValues.Zip(y.AlgorithmParameterStringValues, (a, b) => new { X = a, Y = b });
|
---|
77 | foreach (var value in values) {
|
---|
78 | equal = equal && value.X.AlgorithmParameterId == value.Y.AlgorithmParameterId;
|
---|
79 | equal = equal && value.X.DataTypeId == value.Y.DataTypeId;
|
---|
80 | equal = equal && value.X.Value == value.Y.Value;
|
---|
81 | }
|
---|
82 | }
|
---|
83 |
|
---|
84 | if (equal) {
|
---|
85 | var values = x.ProblemParameterBlobValues.Zip(y.ProblemParameterBlobValues, (a, b) => new { X = a, Y = b });
|
---|
86 | foreach (var value in values) {
|
---|
87 | equal = equal && value.X.ProblemParameterId == value.Y.ProblemParameterId;
|
---|
88 | equal = equal && value.X.DataTypeId == value.Y.DataTypeId;
|
---|
89 | equal = equal && value.X.Value.Equals(value.Y.Value);
|
---|
90 | }
|
---|
91 | }
|
---|
92 | if (equal) {
|
---|
93 | var values = x.ProblemParameterBoolValues.Zip(y.ProblemParameterBoolValues, (a, b) => new { X = a, Y = b });
|
---|
94 | foreach (var value in values) {
|
---|
95 | equal = equal && value.X.ProblemParameterId == value.Y.ProblemParameterId;
|
---|
96 | equal = equal && value.X.DataTypeId == value.Y.DataTypeId;
|
---|
97 | equal = equal && value.X.Value == value.Y.Value;
|
---|
98 | }
|
---|
99 | }
|
---|
100 | if (equal) {
|
---|
101 | var values = x.ProblemParameterFloatValues.Zip(y.ProblemParameterFloatValues, (a, b) => new { X = a, Y = b });
|
---|
102 | foreach (var value in values) {
|
---|
103 | equal = equal && value.X.ProblemParameterId == value.Y.ProblemParameterId;
|
---|
104 | equal = equal && value.X.DataTypeId == value.Y.DataTypeId;
|
---|
105 | equal = equal && value.X.Value == value.Y.Value;
|
---|
106 | }
|
---|
107 | }
|
---|
108 | if (equal) {
|
---|
109 | var values = x.ProblemParameterIntValues.Zip(y.ProblemParameterIntValues, (a, b) => new { X = a, Y = b });
|
---|
110 | foreach (var value in values) {
|
---|
111 | equal = equal && value.X.ProblemParameterId == value.Y.ProblemParameterId;
|
---|
112 | equal = equal && value.X.DataTypeId == value.Y.DataTypeId;
|
---|
113 | equal = equal && value.X.Value == value.Y.Value;
|
---|
114 | }
|
---|
115 | }
|
---|
116 | if (equal) {
|
---|
117 | var values = x.ProblemParameterStringValues.Zip(y.ProblemParameterStringValues, (a, b) => new { X = a, Y = b });
|
---|
118 | foreach (var value in values) {
|
---|
119 | equal = equal && value.X.ProblemParameterId == value.Y.ProblemParameterId;
|
---|
120 | equal = equal && value.X.DataTypeId == value.Y.DataTypeId;
|
---|
121 | equal = equal && value.X.Value == value.Y.Value;
|
---|
122 | }
|
---|
123 | }
|
---|
124 |
|
---|
125 | return equal;
|
---|
126 | }
|
---|
127 |
|
---|
128 | public int GetHashCode(Experiment obj) {
|
---|
129 | return obj.GetHashCode();
|
---|
130 | }
|
---|
131 | }
|
---|
132 | }
|
---|