#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.Optimization; using HeuristicLab.Parameters; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment { [Item("NMoveMaker", "Performs an n-move.")] [StorableClass] public class NMoveMaker : SingleSuccessorOperator, IGQAPNMoveOperator, IMoveMaker { public ILookupParameter AssignmentParameter { get { return (ILookupParameter)Parameters["Assignment"]; } } public ILookupParameter MoveParameter { get { return (ILookupParameter)Parameters["Move"]; } } public ILookupParameter QualityParameter { get { return (ILookupParameter)Parameters["Quality"]; } } public ILookupParameter FlowDistanceQualityParameter { get { return (ILookupParameter)Parameters["FlowDistanceQuality"]; } } public ILookupParameter InstallationQualityParameter { get { return (ILookupParameter)Parameters["InstallationQuality"]; } } public ILookupParameter OverbookedCapacityParameter { get { return (ILookupParameter)Parameters["OverbookedCapacity"]; } } public ILookupParameter MoveQualityParameter { get { return (ILookupParameter)Parameters["MoveQuality"]; } } public ILookupParameter MoveFlowDistanceQualityParameter { get { return (ILookupParameter)Parameters["MoveFlowDistanceQuality"]; } } public ILookupParameter MoveInstallationQualityParameter { get { return (ILookupParameter)Parameters["MoveInstallationQuality"]; } } public ILookupParameter MoveOverbookedCapacityParameter { get { return (ILookupParameter)Parameters["MoveOverbookedCapacity"]; } } [StorableConstructor] protected NMoveMaker(bool deserializing) : base(deserializing) { } protected NMoveMaker(NMoveMaker original, Cloner cloner) : base(original, cloner) { } public NMoveMaker() : base() { Parameters.Add(new LookupParameter("Assignment", "The equipment-location assignment vector.")); Parameters.Add(new LookupParameter("Move", "The move to perform.")); Parameters.Add(new LookupParameter("Quality", "The solution quality.")); Parameters.Add(new LookupParameter("FlowDistanceQuality", "The quality regarding the flow-distance criteria.")); Parameters.Add(new LookupParameter("InstallationQuality", "The quality regarding the installation costs.")); Parameters.Add(new LookupParameter("OverbookedCapacity", "The sum of the overbooked capacities relative to the capacity of each location.")); Parameters.Add(new LookupParameter("MoveQuality", "The quality of the move if it would be applied.")); Parameters.Add(new LookupParameter("MoveFlowDistanceQuality", "The quality of the move regarding the flow-distance criteria.")); Parameters.Add(new LookupParameter("MoveInstallationQuality", "The quality of the move regarding the installation costs.")); Parameters.Add(new LookupParameter("MoveOverbookedCapacity", "The sum of the overbooked capacities of the move relative to the capacity of each location.")); } public override IDeepCloneable Clone(Cloner cloner) { return new NMoveMaker(this, cloner); } public static void Apply(IntegerVector vector, NMove move) { for (int i = 0; i < move.N; i++) { vector[move.Equipments[i]] = move.Locations[i]; } } public override IOperation Apply() { Apply(AssignmentParameter.ActualValue, MoveParameter.ActualValue); QualityParameter.ActualValue.Value = MoveQualityParameter.ActualValue.Value; FlowDistanceQualityParameter.ActualValue.Value = MoveFlowDistanceQualityParameter.ActualValue.Value; InstallationQualityParameter.ActualValue.Value = MoveInstallationQualityParameter.ActualValue.Value; OverbookedCapacityParameter.ActualValue.Value = MoveOverbookedCapacityParameter.ActualValue.Value; return base.Apply(); } } }