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