Free cookie consent management tool by TermsFeed Policy Generator

source: branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Evaluation/Evaluation.cs @ 15504

Last change on this file since 15504 was 15504, checked in by abeham, 6 years ago

#1614: refactored code

  • change problem to derive from basic problem
  • using a combined instance class instead of individual parameters
File size: 2.0 KB
Line 
1using System.Linq;
2using HeuristicLab.Common;
3using HeuristicLab.Core;
4using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
5
6namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment {
7  [Item("GQAP Evaluation", "Class that contains the results of evaluating a solution to the GQAP.")]
8  [StorableClass]
9  public class Evaluation : Item {
10
11    /// <summary>
12    /// The solution is feasible if there is no excess demand
13    /// </summary>
14    public bool IsFeasible { get { return ExcessDemand <= double.Epsilon; } }
15
16    /// <summary>
17    /// The amount of demand that exceeds the respective capacities
18    /// </summary>
19    [Storable]
20    public double ExcessDemand { get; set; }
21    /// <summary>
22    /// The amount of slack at each location, is negative in case of excess demand.
23    /// </summary>
24    /// <remarks>
25    /// Slack.Select(x => x &lt; 0 ? -x : 0).Sum() is equivalent to <see cref="ExcessDemand"/>.
26    /// </remarks>
27    [Storable]
28    public double[] Slack { get; set; }
29    /// <summary>
30    /// The quadratic part of the fitness function that represents the flow or transportation costs.
31    /// </summary>
32    [Storable]
33    public double FlowCosts { get; set; }
34    /// <summary>
35    /// The linear part of the fitness function that represents the installation costs.
36    /// </summary>
37    [Storable]
38    public double InstallationCosts { get; set; }
39   
40    [StorableConstructor]
41    protected Evaluation(bool deserializing) : base(deserializing) { }
42    protected Evaluation(Evaluation original, Cloner cloner)
43      : base(original, cloner) {
44      ExcessDemand = original.ExcessDemand;
45      if (original.Slack != null)
46        Slack = original.Slack.ToArray();
47      FlowCosts = original.FlowCosts;
48      InstallationCosts = original.InstallationCosts;
49    }
50    public Evaluation() { }
51
52    public override IDeepCloneable Clone(Cloner cloner) {
53      return new Evaluation(this, cloner);
54    }
55  }
56}
Note: See TracBrowser for help on using the repository browser.