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

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

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

File size: 6.6 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 HeuristicLab.Algorithms.MemPR.Binary;
25using HeuristicLab.Core;
26using HeuristicLab.Encodings.BinaryVectorEncoding;
27
28/*************************************************
29 * ********************************************* *
30 *                    DATA                       *
31 * ********************************************* *
32 *************************************************/
33
34namespace HeuristicLab.Optimization.SolutionModel {
35
36  public interface ISolutionModel<TSolution> : IItem {
37    TSolution Sample();
38  }
39}
40
41namespace HeuristicLab.Optimization {
42
43  public interface ISolutionSubspace : IItem { }
44}
45
46/*************************************************
47   * ********************************************* *
48   *                  OPERATORS                    *
49   * ********************************************* *
50   *************************************************/
51
52namespace HeuristicLab.Optimization.SolutionModel {
53
54  public interface ISolutionModelTrainer<TSolution> : IOperator
55      where TSolution : class, IItem {
56    IScopeTreeLookupParameter<TSolution> SolutionParameter { get; }
57    ILookupParameter<ISolutionModel<TSolution>> SamplingModelParameter { get; }
58  }
59
60  public interface ISolutionModelTrainer<TSolution, TContext> : ISolutionModelTrainer<TSolution>
61      where TSolution : class, IItem
62      where TContext : ISolutionModelContext<TSolution> {
63
64    void TrainModel(TContext context);
65  }
66
67  public interface IBinarySolutionModelTrainer<TContext> : ISolutionModelTrainer<BinaryVector, TContext>
68      where TContext : ISolutionModelContext<BinaryVector> { }
69}
70
71namespace HeuristicLab.Optimization.LocalSearch {
72
73  public interface ILocalSearch<TSolution> : IOperator
74      where TSolution : class, IItem {
75    ILookupParameter<TSolution> SolutionParameter { get; }
76
77    Func<TSolution, double> EvaluateFunc { get; set; }
78  }
79
80  public interface ILocalSearch<TSolution, TContext> : ILocalSearch<TSolution>
81      where TSolution : class, IItem {
82
83    void Optimize(TContext context);
84  }
85
86  public interface IBinaryLocalSearch<TContext> : ILocalSearch<BinaryVector, TContext> {
87   
88  }
89
90}
91
92/*************************************************
93   * ********************************************* *
94   *                  CONTEXTS                     *
95   * ********************************************* *
96   *************************************************/
97
98namespace HeuristicLab.Optimization {
99 
100  public interface IStochasticContext : IExecutionContext {
101    IRandom Random { get; }
102  }
103
104  public interface IMaximizationContext : IExecutionContext {
105    bool Maximization { get; }
106  }
107
108  public interface IEvaluatedSolutionsContext : IExecutionContext {
109    int EvaluatedSolutions { get; set; }
110  }
111
112  public interface IBestQualityContext : IExecutionContext {
113    double BestQuality { get; set; }
114  }
115
116  public interface IBestSolutionContext<TSolution> : IExecutionContext {
117    TSolution BestSolution { get; set; }
118  }
119
120  public interface IIterationsContext : IExecutionContext {
121    int Iterations { get; }
122  }
123
124  public interface IIterationsManipulationContext : IIterationsContext {
125    new int Iterations { get; set; }
126  }
127
128  public interface IPopulationContext : IExecutionContext {
129    IEnumerable<IScope> Population { get; }
130  }
131
132  public interface IPopulationContext<TSolution> : IPopulationContext {
133    new IEnumerable<ISolutionScope<TSolution>> Population { get; }
134  }
135
136  public interface ISingleObjectivePopulationContext<TSolution> : IPopulationContext<TSolution> {
137    new IEnumerable<ISingleObjectiveSolutionScope<TSolution>> Population { get; }
138  }
139
140  public interface ISolutionContext : IExecutionContext {
141    IScope Solution { get; }
142  }
143
144  public interface ISolutionContext<TSolution> : ISolutionContext {
145    new ISolutionScope<TSolution> Solution { get; }
146  }
147
148  public interface ISingleObjectiveSolutionContext<TSolution> : ISolutionContext<TSolution> {
149    new ISingleObjectiveSolutionScope<TSolution> Solution { get; }
150  }
151
152  /* Probably a setter is not needed anyway, since there is Adopt() also
153  public interface ISolutionManipulationContext : ISolutionContext {
154    new IScope Solution { get; set; }
155  }
156
157  public interface ISolutionManipulationContext<TSolution> : ISolutionManipulationContext, ISolutionContext<TSolution> {
158    new ISolutionScope<TSolution> Solution { get; set; }
159  }
160
161  public interface ISingleObjectiveSolutionManipulationContext<TSolution> : ISolutionManipulationContext<TSolution>, ISingleObjectiveSolutionContext<TSolution> {
162    new ISingleObjectiveSolutionScope<TSolution> Solution { get; set; }
163  }
164  */
165
166  public interface ISolutionSubspaceContext : IExecutionContext {
167    ISolutionSubspace Subspace { get; }
168  }
169  public interface IBinarySolutionSubspaceContext : ISolutionSubspaceContext {
170    new BinarySolutionSubspace Subspace { get; }
171  }
172}
173
174namespace HeuristicLab.Optimization.SolutionModel {
175  public interface ISolutionModelContext<TSolution> : IExecutionContext {
176    ISolutionModel<TSolution> Model { get; set; }
177  }
178}
179
180
181/*************************************************
182   * ********************************************* *
183   *                   SCOPES                      *
184   * ********************************************* *
185   *************************************************/
186 
187namespace HeuristicLab.Core {
188  public interface ISolutionScope<TSolution> : IScope {
189    TSolution Solution { get; set; }
190
191    void Adopt(ISolutionScope<TSolution> orphan);
192  }
193
194  public interface ISingleObjectiveSolutionScope<TSolution> : ISolutionScope<TSolution> {
195    double Fitness { get; set; }
196
197    void Adopt(ISingleObjectiveSolutionScope<TSolution> orphan);
198  }
199}
Note: See TracBrowser for help on using the repository browser.