[15553] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[16728] | 3 | * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[15553] | 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
| 22 | using System.Collections.Generic;
|
---|
[15510] | 23 | using System.Linq;
|
---|
[15504] | 24 | using HeuristicLab.Common;
|
---|
| 25 | using HeuristicLab.Core;
|
---|
| 26 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
[16728] | 27 | using HEAL.Attic;
|
---|
[15504] | 28 |
|
---|
| 29 | namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment {
|
---|
| 30 | [Item("GQAP Evaluation", "Class that contains the results of evaluating a solution to the GQAP.")]
|
---|
[16728] | 31 | [StorableType("765222A4-9184-42FF-9413-886BC9B2EF03")]
|
---|
[15504] | 32 | public class Evaluation : Item {
|
---|
| 33 |
|
---|
| 34 | /// <summary>
|
---|
| 35 | /// The solution is feasible if there is no excess demand
|
---|
| 36 | /// </summary>
|
---|
| 37 | public bool IsFeasible { get { return ExcessDemand <= double.Epsilon; } }
|
---|
| 38 |
|
---|
| 39 | /// <summary>
|
---|
| 40 | /// The amount of demand that exceeds the respective capacities
|
---|
| 41 | /// </summary>
|
---|
| 42 | [Storable]
|
---|
[15510] | 43 | public double ExcessDemand { get; private set; }
|
---|
[15504] | 44 | /// <summary>
|
---|
| 45 | /// The amount of slack at each location, is negative in case of excess demand.
|
---|
| 46 | /// </summary>
|
---|
| 47 | /// <remarks>
|
---|
| 48 | /// Slack.Select(x => x < 0 ? -x : 0).Sum() is equivalent to <see cref="ExcessDemand"/>.
|
---|
| 49 | /// </remarks>
|
---|
| 50 | [Storable]
|
---|
[15510] | 51 | private double[] slack;
|
---|
| 52 | public IReadOnlyList<double> Slack {
|
---|
| 53 | get { return slack; }
|
---|
| 54 | }
|
---|
[15504] | 55 | /// <summary>
|
---|
| 56 | /// The quadratic part of the fitness function that represents the flow or transportation costs.
|
---|
| 57 | /// </summary>
|
---|
| 58 | [Storable]
|
---|
[15510] | 59 | public double FlowCosts { get; private set; }
|
---|
[15504] | 60 | /// <summary>
|
---|
| 61 | /// The linear part of the fitness function that represents the installation costs.
|
---|
| 62 | /// </summary>
|
---|
| 63 | [Storable]
|
---|
[15510] | 64 | public double InstallationCosts { get; private set; }
|
---|
[15504] | 65 |
|
---|
| 66 | [StorableConstructor]
|
---|
[16728] | 67 | protected Evaluation(StorableConstructorFlag _) : base(_) { }
|
---|
[15504] | 68 | protected Evaluation(Evaluation original, Cloner cloner)
|
---|
| 69 | : base(original, cloner) {
|
---|
| 70 | ExcessDemand = original.ExcessDemand;
|
---|
[15510] | 71 | if (original.slack != null)
|
---|
| 72 | slack = original.slack.ToArray();
|
---|
[15504] | 73 | FlowCosts = original.FlowCosts;
|
---|
| 74 | InstallationCosts = original.InstallationCosts;
|
---|
| 75 | }
|
---|
[15510] | 76 | public Evaluation(double flowCosts, double installationCosts, double excessDemand, double[] slack) {
|
---|
| 77 | FlowCosts = flowCosts;
|
---|
| 78 | InstallationCosts = installationCosts;
|
---|
| 79 | ExcessDemand = excessDemand;
|
---|
| 80 | this.slack = slack;
|
---|
| 81 | }
|
---|
[15504] | 82 |
|
---|
| 83 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 84 | return new Evaluation(this, cloner);
|
---|
| 85 | }
|
---|
| 86 | }
|
---|
| 87 | }
|
---|