#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.Parameters; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment { [Item("GQAPPenaltyLevelEvaluator", "Evaluates solutions to the generalized quadratic assignment problem using a penalty level strategy. Infeasible solutions have a certain base quality to which the amount of constraint violation is added.")] [StorableClass] public class GQAPPenaltyLevelEvaluator : GQAPEvaluator { public static readonly string PenaltyDescription = "The percentage of the expected random quality that should be used as a base level for infeasible solutions."; protected IValueParameter PenaltyParameter { get { return (IValueParameter)Parameters["Penalty"]; } } public PercentValue Penalty { get { return PenaltyParameter.Value; } set { PenaltyParameter.Value = value; } } [StorableConstructor] protected GQAPPenaltyLevelEvaluator(bool deserializing) : base(deserializing) { } protected GQAPPenaltyLevelEvaluator(GQAPPenaltyLevelEvaluator original, Cloner cloner) : base(original, cloner) { } public GQAPPenaltyLevelEvaluator() : base() { Parameters.Add(new ValueParameter("Penalty", PenaltyDescription, new PercentValue(1), true)); } public override IDeepCloneable Clone(Cloner cloner) { return new GQAPPenaltyLevelEvaluator(this, cloner); } public override double GetFitness(double flowDistanceQuality, double installationQuality, double overbookedCapacity, double transportationCosts, double expectedRandomQuality) { if (overbookedCapacity > 0) { return expectedRandomQuality * Penalty.Value + overbookedCapacity; } else { return installationQuality + transportationCosts * flowDistanceQuality; } } } }