Free cookie consent management tool by TermsFeed Policy Generator

source: branches/1614_GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Evaluation/Evaluation.cs @ 17485

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

#1614: updated to new persistence and .NET 4.6.1

File size: 3.2 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
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;
23using System.Linq;
24using HeuristicLab.Common;
25using HeuristicLab.Core;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27using HEAL.Attic;
28
29namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment {
30  [Item("GQAP Evaluation", "Class that contains the results of evaluating a solution to the GQAP.")]
31  [StorableType("765222A4-9184-42FF-9413-886BC9B2EF03")]
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]
43    public double ExcessDemand { get; private set; }
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 &lt; 0 ? -x : 0).Sum() is equivalent to <see cref="ExcessDemand"/>.
49    /// </remarks>
50    [Storable]
51    private double[] slack;
52    public IReadOnlyList<double> Slack {
53      get { return slack; }
54    }
55    /// <summary>
56    /// The quadratic part of the fitness function that represents the flow or transportation costs.
57    /// </summary>
58    [Storable]
59    public double FlowCosts { get; private set; }
60    /// <summary>
61    /// The linear part of the fitness function that represents the installation costs.
62    /// </summary>
63    [Storable]
64    public double InstallationCosts { get; private set; }
65   
66    [StorableConstructor]
67    protected Evaluation(StorableConstructorFlag _) : base(_) { }
68    protected Evaluation(Evaluation original, Cloner cloner)
69      : base(original, cloner) {
70      ExcessDemand = original.ExcessDemand;
71      if (original.slack != null)
72        slack = original.slack.ToArray();
73      FlowCosts = original.FlowCosts;
74      InstallationCosts = original.InstallationCosts;
75    }
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    }
82
83    public override IDeepCloneable Clone(Cloner cloner) {
84      return new Evaluation(this, cloner);
85    }
86  }
87}
Note: See TracBrowser for help on using the repository browser.