#region License Information /* HeuristicLab * Copyright (C) 2002-2017 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 System.Collections.Generic; using System.Linq; using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment { [Item("GQAP Evaluation", "Class that contains the results of evaluating a solution to the GQAP.")] [StorableClass] public class Evaluation : Item { /// /// The solution is feasible if there is no excess demand /// public bool IsFeasible { get { return ExcessDemand <= double.Epsilon; } } /// /// The amount of demand that exceeds the respective capacities /// [Storable] public double ExcessDemand { get; private set; } /// /// The amount of slack at each location, is negative in case of excess demand. /// /// /// Slack.Select(x => x < 0 ? -x : 0).Sum() is equivalent to . /// [Storable] private double[] slack; public IReadOnlyList Slack { get { return slack; } } /// /// The quadratic part of the fitness function that represents the flow or transportation costs. /// [Storable] public double FlowCosts { get; private set; } /// /// The linear part of the fitness function that represents the installation costs. /// [Storable] public double InstallationCosts { get; private set; } [StorableConstructor] protected Evaluation(bool deserializing) : base(deserializing) { } protected Evaluation(Evaluation original, Cloner cloner) : base(original, cloner) { ExcessDemand = original.ExcessDemand; if (original.slack != null) slack = original.slack.ToArray(); FlowCosts = original.FlowCosts; InstallationCosts = original.InstallationCosts; } public Evaluation(double flowCosts, double installationCosts, double excessDemand, double[] slack) { FlowCosts = flowCosts; InstallationCosts = installationCosts; ExcessDemand = excessDemand; this.slack = slack; } public override IDeepCloneable Clone(Cloner cloner) { return new Evaluation(this, cloner); } } }