1 | using System.Linq;
|
---|
2 | using HeuristicLab.Common;
|
---|
3 | using HeuristicLab.Core;
|
---|
4 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
5 |
|
---|
6 | namespace 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 < 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 | }
|
---|