[14420] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2016 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 |
|
---|
[14552] | 22 | using System;
|
---|
| 23 | using System.Runtime.Remoting.Contexts;
|
---|
[14450] | 24 | using HeuristicLab.Algorithms.MemPR.Interfaces;
|
---|
[14420] | 25 | using HeuristicLab.Common;
|
---|
| 26 | using HeuristicLab.Core;
|
---|
[14466] | 27 | using HeuristicLab.Encodings.LinearLinkageEncoding;
|
---|
[14420] | 28 | using HeuristicLab.Optimization;
|
---|
| 29 | using HeuristicLab.Parameters;
|
---|
| 30 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 31 |
|
---|
[14544] | 32 | namespace HeuristicLab.Algorithms.MemPR.Grouping {
|
---|
[14466] | 33 | [Item("MemPR Population Context (linear linkage)", "MemPR population context for linear linkage encoded problems.")]
|
---|
[14420] | 34 | [StorableClass]
|
---|
[14552] | 35 | public sealed class LinearLinkageMemPRPopulationContext : MemPRPopulationContext<ISingleObjectiveHeuristicOptimizationProblem, LinearLinkage, LinearLinkageMemPRPopulationContext, LinearLinkageMemPRSolutionContext> {
|
---|
[14420] | 36 |
|
---|
| 37 | [StorableConstructor]
|
---|
[14466] | 38 | private LinearLinkageMemPRPopulationContext(bool deserializing) : base(deserializing) { }
|
---|
| 39 | private LinearLinkageMemPRPopulationContext(LinearLinkageMemPRPopulationContext original, Cloner cloner)
|
---|
[14420] | 40 | : base(original, cloner) { }
|
---|
[14466] | 41 | public LinearLinkageMemPRPopulationContext() : base("LinearLinkageMemPRPopulationContext") { }
|
---|
| 42 | public LinearLinkageMemPRPopulationContext(string name) : base(name) { }
|
---|
[14420] | 43 |
|
---|
| 44 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
[14466] | 45 | return new LinearLinkageMemPRPopulationContext(this, cloner);
|
---|
[14420] | 46 | }
|
---|
| 47 |
|
---|
[14544] | 48 | public override LinearLinkageMemPRSolutionContext CreateSingleSolutionContext(ISingleObjectiveSolutionScope<LinearLinkage> solution) {
|
---|
[14466] | 49 | return new LinearLinkageMemPRSolutionContext(this, solution);
|
---|
[14420] | 50 | }
|
---|
[14552] | 51 |
|
---|
| 52 | public override ISingleObjectiveSolutionScope<LinearLinkage> ToScope(LinearLinkage code, double fitness = double.NaN) {
|
---|
| 53 | var creator = Problem.SolutionCreator as ILinearLinkageCreator;
|
---|
| 54 | if (creator == null) throw new InvalidOperationException("Can only solve linear linkage encoded problems with MemPR (linear linkage)");
|
---|
| 55 | return new SingleObjectiveSolutionScope<LinearLinkage>(code, creator.LLEParameter.ActualName, fitness, Problem.Evaluator.QualityParameter.ActualName) {
|
---|
| 56 | Parent = Scope
|
---|
| 57 | };
|
---|
| 58 | }
|
---|
[14420] | 59 | }
|
---|
| 60 |
|
---|
[14466] | 61 | [Item("MemPR Solution Context (linear linkage)", "MemPR solution context for linear linkage encoded problems.")]
|
---|
[14420] | 62 | [StorableClass]
|
---|
[14552] | 63 | public sealed class LinearLinkageMemPRSolutionContext : MemPRSolutionContext<ISingleObjectiveHeuristicOptimizationProblem, LinearLinkage, LinearLinkageMemPRPopulationContext, LinearLinkageMemPRSolutionContext>, ILinearLinkageSubspaceContext {
|
---|
[14420] | 64 |
|
---|
| 65 | [Storable]
|
---|
[14466] | 66 | private IValueParameter<LinearLinkageSolutionSubspace> subspace;
|
---|
| 67 | public LinearLinkageSolutionSubspace Subspace {
|
---|
[14420] | 68 | get { return subspace.Value; }
|
---|
| 69 | }
|
---|
[14544] | 70 | ISolutionSubspace<LinearLinkage> ISolutionSubspaceContext<LinearLinkage>.Subspace {
|
---|
[14420] | 71 | get { return Subspace; }
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | [StorableConstructor]
|
---|
[14466] | 75 | private LinearLinkageMemPRSolutionContext(bool deserializing) : base(deserializing) { }
|
---|
| 76 | private LinearLinkageMemPRSolutionContext(LinearLinkageMemPRSolutionContext original, Cloner cloner)
|
---|
[14420] | 77 | : base(original, cloner) {
|
---|
| 78 |
|
---|
| 79 | }
|
---|
[14544] | 80 | public LinearLinkageMemPRSolutionContext(LinearLinkageMemPRPopulationContext baseContext, ISingleObjectiveSolutionScope<LinearLinkage> solution)
|
---|
[14420] | 81 | : base(baseContext, solution) {
|
---|
| 82 |
|
---|
[14466] | 83 | Parameters.Add(subspace = new ValueParameter<LinearLinkageSolutionSubspace>("Subspace", new LinearLinkageSolutionSubspace(null)));
|
---|
[14420] | 84 | }
|
---|
| 85 |
|
---|
| 86 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
[14466] | 87 | return new LinearLinkageMemPRSolutionContext(this, cloner);
|
---|
[14420] | 88 | }
|
---|
| 89 | }
|
---|
| 90 | }
|
---|