#region License Information
/* HeuristicLab
* Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using HeuristicLab.Common;
using HeuristicLab.Core;
using HeuristicLab.Encodings.PermutationEncoding;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
namespace HeuristicLab.Analysis.SolutionCaching.PermutationEncoding {
[Item("PermutationSolutionInformation", "Displays information about a real vector solution.")]
[StorableClass]
public class PermutationSolutionInformation : SolutionInformation {
public PermutationSolutionInformation() : base() { }
[StorableConstructor]
protected PermutationSolutionInformation(bool deserializing) : base(deserializing) { }
protected PermutationSolutionInformation(PermutationSolutionInformation original, Cloner cloner)
: base(original, cloner) {
}
public override IDeepCloneable Clone(Cloner cloner) {
return new PermutationSolutionInformation(this, cloner);
}
public override int GetHashCode() {
//use rotating hash, should be enough
//see: http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx
var pweq = new PermutationEqualityComparer();
int h = 0;
h = (h << 4) ^ (h >> 28) ^ ProducedBy.GetHashCode();
h = (h << 4) ^ (h >> 28) ^ Iteration.GetHashCode();
if (Predecessors != null) {
foreach (var parent in Predecessors) {
h = (h << 4) ^ (h >> 28) ^ pweq.GetHashCode(parent);
}
}
return h;
}
}
}