#region License Information /* HeuristicLab * Copyright (C) 2002-2012 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.Data; using HeuristicLab.Encodings.IntegerVectorEncoding; using HeuristicLab.Operators; using HeuristicLab.Parameters; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment { [Item("GQAPSolutionCreator", "Base class for solution creators of the Generalized Quadratic Assignment Problem.")] [StorableClass] public abstract class GQAPSolutionCreator : SingleSuccessorOperator, IDemandsAwareGQAPOperator, ICapacitiesAwareGQAPOperator, IGQAPSolutionCreator { #region Parameter Descriptions public static readonly string AssignmentDescription = "The vector that encodes the assignment."; #endregion public ILookupParameter AssignmentParameter { get { return (ILookupParameter)Parameters["Assignment"]; } } public ILookupParameter DemandsParameter { get { return (ILookupParameter)Parameters["Demands"]; } } public ILookupParameter CapacitiesParameter { get { return (ILookupParameter)Parameters["Capacities"]; } } [StorableConstructor] protected GQAPSolutionCreator(bool deserializing) : base(deserializing) { } protected GQAPSolutionCreator(GQAPSolutionCreator original, Cloner cloner) : base(original, cloner) { } public GQAPSolutionCreator() : base() { Parameters.Add(new LookupParameter("Assignment", AssignmentDescription)); Parameters.Add(new LookupParameter("Demands", GeneralizedQuadraticAssignmentProblem.DemandsDescription)); Parameters.Add(new LookupParameter("Capacities", GeneralizedQuadraticAssignmentProblem.CapacitiesDescription)); } public override IOperation Apply() { AssignmentParameter.ActualValue = CreateSolution(DemandsParameter.ActualValue, CapacitiesParameter.ActualValue); return base.Apply(); } protected abstract IntegerVector CreateSolution(DoubleArray demands, DoubleArray capacities); } }