#region License Information /* HeuristicLab * Copyright (C) 2002-2018 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; using HEAL.Attic; namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment { [Item("GQAPSolutionCreator", "Base class for solution creators of the Generalized Quadratic Assignment Problem.")] [StorableType("1FD56558-5E7C-470C-8E7C-B3CEF7DB1D61")] public abstract class GQAPSolutionCreator : SingleSuccessorOperator, IProblemInstanceAwareGQAPOperator, IGQAPSolutionCreator { #region Parameter Descriptions public static readonly string AssignmentDescription = "The vector that encodes the assignment."; #endregion public ILookupParameter IntegerVectorParameter { get { return (ILookupParameter)Parameters["IntegerVector"]; } } public ILookupParameter ProblemInstanceParameter { get { return (ILookupParameter)Parameters["ProblemInstance"]; } } public IValueLookupParameter LengthParameter { get { return (IValueLookupParameter)Parameters["Length"]; } } public IValueLookupParameter BoundsParameter { get { return (IValueLookupParameter)Parameters["Bounds"]; } } [StorableConstructor] protected GQAPSolutionCreator(StorableConstructorFlag _) : base(_) { } protected GQAPSolutionCreator(GQAPSolutionCreator original, Cloner cloner) : base(original, cloner) { } public GQAPSolutionCreator() : base() { Parameters.Add(new LookupParameter("IntegerVector", AssignmentDescription)); Parameters.Add(new LookupParameter("ProblemInstance", GQAP.ProblemInstanceDescription)); Parameters.Add(new ValueLookupParameter("Length", "The length of the vector.") { Hidden = true }); Parameters.Add(new ValueLookupParameter("Bounds", "") { Hidden = true }); } public override IOperation Apply() { IntegerVectorParameter.ActualValue = CreateSolution(ProblemInstanceParameter.ActualValue); return base.Apply(); } protected abstract IntegerVector CreateSolution(GQAPInstance problemInstance); } }