Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2936_GQAPIntegration/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/SolutionCreators/GQAPSolutionCreator.cs

Last change on this file was 16712, checked in by gkronber, 5 years ago

#2936: adapted branch to new persistence (works with HL trunk r16711)

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 HeuristicLab.Common;
23using HeuristicLab.Core;
24using HeuristicLab.Data;
25using HeuristicLab.Encodings.IntegerVectorEncoding;
26using HeuristicLab.Operators;
27using HeuristicLab.Parameters;
28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
29using HEAL.Attic;
30
31namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment {
32  [Item("GQAPSolutionCreator", "Base class for solution creators of the Generalized Quadratic Assignment Problem.")]
33  [StorableType("1FD56558-5E7C-470C-8E7C-B3CEF7DB1D61")]
34  public abstract class GQAPSolutionCreator : SingleSuccessorOperator, IProblemInstanceAwareGQAPOperator, IGQAPSolutionCreator {
35
36    #region Parameter Descriptions
37    public static readonly string AssignmentDescription = "The vector that encodes the assignment.";
38    #endregion
39
40    public ILookupParameter<IntegerVector> IntegerVectorParameter {
41      get { return (ILookupParameter<IntegerVector>)Parameters["IntegerVector"]; }
42    }
43    public ILookupParameter<GQAPInstance> ProblemInstanceParameter {
44      get { return (ILookupParameter<GQAPInstance>)Parameters["ProblemInstance"]; }
45    }
46    public IValueLookupParameter<IntValue> LengthParameter {
47      get { return (IValueLookupParameter<IntValue>)Parameters["Length"]; }
48    }
49    public IValueLookupParameter<IntMatrix> BoundsParameter {
50      get { return (IValueLookupParameter<IntMatrix>)Parameters["Bounds"]; }
51    }
52
53    [StorableConstructor]
54    protected GQAPSolutionCreator(StorableConstructorFlag _) : base(_) { }
55    protected GQAPSolutionCreator(GQAPSolutionCreator original, Cloner cloner)
56      : base(original, cloner) { }
57    public GQAPSolutionCreator()
58      : base() {
59      Parameters.Add(new LookupParameter<IntegerVector>("IntegerVector", AssignmentDescription));
60      Parameters.Add(new LookupParameter<GQAPInstance>("ProblemInstance", GQAP.ProblemInstanceDescription));
61      Parameters.Add(new ValueLookupParameter<IntValue>("Length", "The length of the vector.") { Hidden = true });
62      Parameters.Add(new ValueLookupParameter<IntMatrix>("Bounds", "") { Hidden = true });
63    }
64
65    public override IOperation Apply() {
66      IntegerVectorParameter.ActualValue = CreateSolution(ProblemInstanceParameter.ActualValue);
67      return base.Apply();
68    }
69
70    protected abstract IntegerVector CreateSolution(GQAPInstance problemInstance);
71  }
72}
Note: See TracBrowser for help on using the repository browser.