1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2017 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 |
|
---|
22 | using HEAL.Attic;
|
---|
23 | using HeuristicLab.Common;
|
---|
24 | using HeuristicLab.Core;
|
---|
25 | using HeuristicLab.Parameters;
|
---|
26 |
|
---|
27 | namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms {
|
---|
28 | [Item("Stochastic Context", "A base class for stochastic algorithms' contexts.")]
|
---|
29 | [StorableType("9A9B3147-4D77-45E7-9A79-B6393666AB2E")]
|
---|
30 | public class StochasticContext : BasicContext, IStochasticContext {
|
---|
31 |
|
---|
32 | [Storable]
|
---|
33 | private IValueParameter<IRandom> random;
|
---|
34 | public IRandom Random {
|
---|
35 | get { return random.Value; }
|
---|
36 | set { random.Value = value; }
|
---|
37 | }
|
---|
38 |
|
---|
39 | [StorableConstructor]
|
---|
40 | protected StochasticContext(StorableConstructorFlag _) : base(_) { }
|
---|
41 | protected StochasticContext(StochasticContext original, Cloner cloner)
|
---|
42 | : base(original, cloner) {
|
---|
43 | random = cloner.Clone(original.random);
|
---|
44 | }
|
---|
45 | protected StochasticContext() : base() {
|
---|
46 | Parameters.Add(random = new ValueParameter<IRandom>("Random"));
|
---|
47 | }
|
---|
48 | protected StochasticContext(string name) : base(name) {
|
---|
49 | Parameters.Add(random = new ValueParameter<IRandom>("Random"));
|
---|
50 | }
|
---|
51 | protected StochasticContext(string name, ParameterCollection parameters) : base(name, parameters) {
|
---|
52 | Parameters.Add(random = new ValueParameter<IRandom>("Random"));
|
---|
53 | }
|
---|
54 | protected StochasticContext(string name, string description) : base(name, description) {
|
---|
55 | Parameters.Add(random = new ValueParameter<IRandom>("Random"));
|
---|
56 | }
|
---|
57 | protected StochasticContext(string name, string description, ParameterCollection parameters) : base(name, description, parameters) {
|
---|
58 | Parameters.Add(random = new ValueParameter<IRandom>("Random"));
|
---|
59 | }
|
---|
60 |
|
---|
61 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
62 | return new StochasticContext(this, cloner);
|
---|
63 | }
|
---|
64 | }
|
---|
65 | }
|
---|