1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2015 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 System;
|
---|
23 | using System.Threading;
|
---|
24 | using System.Threading.Tasks;
|
---|
25 | using HeuristicLab.Common;
|
---|
26 | using HeuristicLab.Core;
|
---|
27 | using HeuristicLab.Optimization;
|
---|
28 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
29 | using HeuristicLab.PluginInfrastructure;
|
---|
30 |
|
---|
31 | namespace HeuristicLab.Clients.OKB.RunCreation {
|
---|
32 | [Item("Empty Algorithm", "A dummy algorithm which serves as a placeholder and cannot be executed.")]
|
---|
33 | [StorableClass]
|
---|
34 | [NonDiscoverableType]
|
---|
35 | public sealed class EmptyAlgorithm : HeuristicLab.Optimization.Algorithm {
|
---|
36 | private string exceptionMessage;
|
---|
37 |
|
---|
38 | public override bool CanChangeName {
|
---|
39 | get { return false; }
|
---|
40 | }
|
---|
41 | public override bool CanChangeDescription {
|
---|
42 | get { return false; }
|
---|
43 | }
|
---|
44 |
|
---|
45 | private ResultCollection results;
|
---|
46 | public override Optimization.ResultCollection Results {
|
---|
47 | get { return results; }
|
---|
48 | }
|
---|
49 |
|
---|
50 | #region Persistence Properties
|
---|
51 | [Storable(Name = "ExceptionMessage")]
|
---|
52 | private string ExceptionMessage {
|
---|
53 | get { return exceptionMessage; }
|
---|
54 | set { exceptionMessage = value; }
|
---|
55 | }
|
---|
56 | #endregion
|
---|
57 |
|
---|
58 | [StorableConstructor]
|
---|
59 | private EmptyAlgorithm(bool deserializing)
|
---|
60 | : base(deserializing) {
|
---|
61 | this.results = new ResultCollection();
|
---|
62 | }
|
---|
63 | private EmptyAlgorithm(EmptyAlgorithm original, Cloner cloner)
|
---|
64 | : base(original, cloner) {
|
---|
65 | this.exceptionMessage = original.exceptionMessage;
|
---|
66 | this.results = new ResultCollection();
|
---|
67 | }
|
---|
68 | public EmptyAlgorithm()
|
---|
69 | : base() {
|
---|
70 | results = new ResultCollection();
|
---|
71 | }
|
---|
72 | public EmptyAlgorithm(string exceptionMessage)
|
---|
73 | : this() {
|
---|
74 | this.exceptionMessage = exceptionMessage;
|
---|
75 | }
|
---|
76 |
|
---|
77 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
78 | return new EmptyAlgorithm(this, cloner);
|
---|
79 | }
|
---|
80 |
|
---|
81 | public override void Prepare() {
|
---|
82 | throw new InvalidOperationException(string.IsNullOrEmpty(exceptionMessage) ? "Cannot prepare an EmptyAlgorithm." : exceptionMessage);
|
---|
83 | }
|
---|
84 | public override async Task StartAsync(CancellationToken cancellationToken) {
|
---|
85 | throw new InvalidOperationException(string.IsNullOrEmpty(exceptionMessage) ? "Cannot start an EmptyAlgorithm." : exceptionMessage);
|
---|
86 | }
|
---|
87 | public override void Pause() {
|
---|
88 | throw new InvalidOperationException(string.IsNullOrEmpty(exceptionMessage) ? "Cannot pause an EmptyAlgorithm." : exceptionMessage);
|
---|
89 | }
|
---|
90 | public override void Stop() {
|
---|
91 | throw new InvalidOperationException(string.IsNullOrEmpty(exceptionMessage) ? "Cannot stop an EmptyAlgorithm." : exceptionMessage);
|
---|
92 | }
|
---|
93 | }
|
---|
94 | }
|
---|