Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 15510 was 15510, checked in by abeham, 7 years ago

#1614:

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