Free cookie consent management tool by TermsFeed Policy Generator

source: branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/NewInfrastructure/Interfaces.cs @ 14429

Last change on this file since 14429 was 14429, checked in by abeham, 7 years ago

#2701, #2708: Made a new branch from ProblemRefactoring and removed ScopedBasicAlgorithm branch (which becomes MemPR branch)

File size: 5.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;
23using System.Collections.Generic;
24using System.Threading;
25using HeuristicLab.Core;
26using HeuristicLab.Optimization;
27
28/*************************************************
29 * ********************************************* *
30 *                    DATA                       *
31 * ********************************************* *
32 *************************************************/
33
34
35
36/*************************************************
37   * ********************************************* *
38   *                  OPERATORS                    *
39   * ********************************************* *
40   *************************************************/
41
42
43namespace HeuristicLab.Optimization.LocalSearch {
44  public interface ILocalSearch<TContext> : IItem {
45    void Optimize(TContext context);
46  }
47}
48
49namespace HeuristicLab.Optimization.Crossover {
50  public interface ICrossover<TContext> : IItem {
51
52    void Cross(TContext context);
53  }
54}
55
56namespace HeuristicLab.Optimization.Manipulation {
57  public interface IManipulator<TContext> : IItem {
58    void Manipulate(TContext context);
59  }
60}
61
62namespace HeuristicLab.Optimization.Selection {
63  public interface ISelector<TContext> : IItem {
64
65    void Select(TContext context, int n, bool withRepetition);
66  }
67}
68
69/*************************************************
70   * ********************************************* *
71   *                  CONTEXTS                     *
72   * ********************************************* *
73   *************************************************/
74
75namespace HeuristicLab.Optimization {
76
77  public interface ILongRunningOperationContext : IExecutionContext {
78    CancellationToken CancellationToken { get; set; }
79  }
80
81  public interface IStochasticContext : IExecutionContext {
82    IRandom Random { get; }
83  }
84
85  public interface IEvaluatedSolutionsContext : IExecutionContext {
86    int EvaluatedSolutions { get; }
87    void IncEvaluatedSolutions(int inc);
88  }
89
90  public interface IBestQualityContext : IExecutionContext {
91    double BestQuality { get; set; }
92  }
93
94  public interface IBestSolutionContext<TSolution> : IExecutionContext {
95    TSolution BestSolution { get; set; }
96  }
97
98  public interface IIterationsContext : IExecutionContext {
99    int Iterations { get; }
100  }
101
102  public interface IImprovementStepsContext : IExecutionContext {
103    int ImprovementSteps { get; set; }
104  }
105
106  public interface IProblemContext<TProblem, TEncoding, TSolution> : IExecutionContext
107      where TProblem : class, ISingleObjectiveProblem<TEncoding, TSolution>
108      where TEncoding : class, IEncoding<TSolution>
109      where TSolution : class, ISolution {
110    TProblem Problem { get; }
111  }
112
113  public interface IPopulationContext : IExecutionContext {
114    IEnumerable<IScope> Population { get; }
115  }
116
117  public interface IPopulationContext<TSolution> : IPopulationContext {
118    new IEnumerable<ISolutionScope<TSolution>> Population { get; }
119  }
120
121  public interface ISingleObjectivePopulationContext<TSolution> : IPopulationContext<TSolution> {
122    new IEnumerable<ISingleObjectiveSolutionScope<TSolution>> Population { get; }
123  }
124
125  public interface ISolutionContext : IExecutionContext {
126    IScope Solution { get; }
127  }
128
129  public interface ISolutionContext<TSolution> : ISolutionContext {
130    new ISolutionScope<TSolution> Solution { get; }
131  }
132
133  public interface ISingleObjectiveSolutionContext<TSolution> : ISolutionContext<TSolution> {
134    new ISingleObjectiveSolutionScope<TSolution> Solution { get; }
135  }
136
137  public interface IMatingContext<TSolution> : IExecutionContext {
138    Tuple<ISolutionScope<TSolution>, ISolutionScope<TSolution>>  Parents { get; }
139    ISolutionScope<TSolution> Child { get; }
140  }
141
142  public interface ISingleObjectiveMatingContext<TSolution> : IMatingContext<TSolution> {
143    new Tuple<ISingleObjectiveSolutionScope<TSolution>, ISingleObjectiveSolutionScope<TSolution>> Parents { get; }
144    new ISingleObjectiveSolutionScope<TSolution> Child { get; }
145  }
146
147  public interface IMatingpoolContext<TSolution> : IExecutionContext
148      where TSolution : class, ISolution {
149    IEnumerable<ISolutionScope<TSolution>> MatingPool { get; set; }
150  }
151
152  public interface ISingleObjectiveMatingpoolContext<TSolution> : IMatingpoolContext<TSolution>
153      where TSolution : class, ISolution {
154    new IEnumerable<ISingleObjectiveSolutionScope<TSolution>> MatingPool { get; set; }
155  }
156}
157
158
159/*************************************************
160   * ********************************************* *
161   *                   SCOPES                      *
162   * ********************************************* *
163   *************************************************/
164
165namespace HeuristicLab.Core {
166  public interface ISolutionScope<TSolution> : IScope {
167    TSolution Solution { get; set; }
168
169    void Adopt(ISolutionScope<TSolution> orphan);
170  }
171
172  public interface ISingleObjectiveSolutionScope<TSolution> : ISolutionScope<TSolution> {
173    double Fitness { get; set; }
174
175    void Adopt(ISingleObjectiveSolutionScope<TSolution> orphan);
176  }
177}
Note: See TracBrowser for help on using the repository browser.