source: branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/Interfaces/Interfaces.cs @ 14552

Last change on this file since 14552 was 14552, checked in by abeham, 3 years ago

#2701:

  • Added alternating bits binary test Problem
  • Refactored MemPR to work with programmable problem in current trunk
  • fixed a bug in permutation MemPR when crossover doesn't assign an offspring
File size: 4.9 KB
Line 
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 
22using System.Collections.Generic;
23using System.Threading;
24using HeuristicLab.Algorithms.MemPR.Binary;
25using HeuristicLab.Algorithms.MemPR.Grouping;
26using HeuristicLab.Algorithms.MemPR.Permutation;
27using HeuristicLab.Core;
28using HeuristicLab.Encodings.BinaryVectorEncoding;
29using HeuristicLab.Optimization;
30
31namespace HeuristicLab.Algorithms.MemPR.Interfaces {
32
33  /*************************************************
34   * ********************************************* *
35   *                    DATA                       *
36   * ********************************************* *
37   *************************************************/
38
39  public interface ISolutionModel<TSolution> : IItem {
40    TSolution Sample();
41  }
42
43  public interface ISolutionSubspace<TSolution> : IItem { }
44
45  /*************************************************
46   * ********************************************* *
47   *                  OPERATORS                    *
48   * ********************************************* *
49   *************************************************/
50   
51  public interface ISolutionModelTrainer<TContext> : IItem {
52    void TrainModel(TContext context);
53  }
54
55  public interface ILocalSearch<TContext> : IItem {
56    void Optimize(TContext context);
57  }
58 
59  /*************************************************
60   * ********************************************* *
61   *                  CONTEXTS                     *
62   * ********************************************* *
63   *************************************************/
64
65  public interface IHeuristicAlgorithmContext<TProblem, TSolution> : IExecutionContext
66      where TProblem : class, ISingleObjectiveHeuristicOptimizationProblem {
67    TProblem Problem { get; }
68    bool Maximization { get; }
69    IRandom Random { get; }
70    int Iterations { get; set; }
71    int EvaluatedSolutions { get; }
72    void IncrementEvaluatedSolutions(int byEvaluations);
73    double BestQuality { get; set; }
74    TSolution BestSolution { get; set; }
75  }
76
77  public interface IEvaluationServiceContext<TSolution> : IExecutionContext {
78    double Evaluate(TSolution solution, CancellationToken token);
79    void Evaluate(ISingleObjectiveSolutionScope<TSolution> scope, CancellationToken token);
80  }
81
82  public interface IPopulationBasedHeuristicAlgorithmContext<TProblem, TSolution> : IHeuristicAlgorithmContext<TProblem, TSolution>
83      where TProblem : class, ISingleObjectiveHeuristicOptimizationProblem {
84    IEnumerable<ISingleObjectiveSolutionScope<TSolution>> Population { get; }
85  }
86
87  public interface ISingleSolutionHeuristicAlgorithmContext<TProblem, TSolution> : IHeuristicAlgorithmContext<TProblem, TSolution>
88      where TProblem : class, ISingleObjectiveHeuristicOptimizationProblem {
89    ISingleObjectiveSolutionScope<TSolution> Solution { get; }
90  }
91
92  public interface ISolutionModelContext<TSolution> : IExecutionContext {
93    ISolutionModel<TSolution> Model { get; set; }
94  }
95
96  public interface ISolutionSubspaceContext<TSolution> : IExecutionContext {
97    ISolutionSubspace<TSolution> Subspace { get; }
98  }
99  public interface IBinaryVectorSubspaceContext : ISolutionSubspaceContext<BinaryVector> {
100    new BinarySolutionSubspace Subspace { get; }
101  }
102  public interface IPermutationSubspaceContext : ISolutionSubspaceContext<Encodings.PermutationEncoding.Permutation> {
103    new PermutationSolutionSubspace Subspace { get; }
104  }
105  public interface ILinearLinkageSubspaceContext : ISolutionSubspaceContext<Encodings.LinearLinkageEncoding.LinearLinkage> {
106    new LinearLinkageSolutionSubspace Subspace { get; }
107  }
108
109
110  /*************************************************
111   * ********************************************* *
112   *                   SCOPES                      *
113   * ********************************************* *
114   *************************************************/
115
116  public interface ISingleObjectiveSolutionScope<TSolution> : IScope {
117    TSolution Solution { get; set; }
118    double Fitness { get; set; }
119
120    void Adopt(ISingleObjectiveSolutionScope<TSolution> orphan);
121  }
122}
Note: See TracBrowser for help on using the repository browser.