source: branches/2936_GQAPIntegration/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Evaluation/Evaluation.cs @ 16077

Last change on this file since 16077 was 16077, checked in by abeham, 16 months ago

#2936: Added integration branch

File size: 3.1 KB
RevLine 
[15553]1#region License Information
2/* HeuristicLab
[16077]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
22using System.Collections.Generic;
[15510]23using System.Linq;
[15504]24using HeuristicLab.Common;
25using HeuristicLab.Core;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27
28namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment {
29  [Item("GQAP Evaluation", "Class that contains the results of evaluating a solution to the GQAP.")]
30  [StorableClass]
31  public class Evaluation : Item {
32
33    /// <summary>
34    /// The solution is feasible if there is no excess demand
35    /// </summary>
36    public bool IsFeasible { get { return ExcessDemand <= double.Epsilon; } }
37
38    /// <summary>
39    /// The amount of demand that exceeds the respective capacities
40    /// </summary>
41    [Storable]
[15510]42    public double ExcessDemand { get; private set; }
[15504]43    /// <summary>
44    /// The amount of slack at each location, is negative in case of excess demand.
45    /// </summary>
46    /// <remarks>
47    /// Slack.Select(x => x &lt; 0 ? -x : 0).Sum() is equivalent to <see cref="ExcessDemand"/>.
48    /// </remarks>
49    [Storable]
[15510]50    private double[] slack;
51    public IReadOnlyList<double> Slack {
52      get { return slack; }
53    }
[15504]54    /// <summary>
55    /// The quadratic part of the fitness function that represents the flow or transportation costs.
56    /// </summary>
57    [Storable]
[15510]58    public double FlowCosts { get; private set; }
[15504]59    /// <summary>
60    /// The linear part of the fitness function that represents the installation costs.
61    /// </summary>
62    [Storable]
[15510]63    public double InstallationCosts { get; private set; }
[15504]64   
65    [StorableConstructor]
66    protected Evaluation(bool deserializing) : base(deserializing) { }
67    protected Evaluation(Evaluation original, Cloner cloner)
68      : base(original, cloner) {
69      ExcessDemand = original.ExcessDemand;
[15510]70      if (original.slack != null)
71        slack = original.slack.ToArray();
[15504]72      FlowCosts = original.FlowCosts;
73      InstallationCosts = original.InstallationCosts;
74    }
[15510]75    public Evaluation(double flowCosts, double installationCosts, double excessDemand, double[] slack) {
76      FlowCosts = flowCosts;
77      InstallationCosts = installationCosts;
78      ExcessDemand = excessDemand;
79      this.slack = slack;
80    }
[15504]81
82    public override IDeepCloneable Clone(Cloner cloner) {
83      return new Evaluation(this, cloner);
84    }
85  }
86}
Note: See TracBrowser for help on using the repository browser.