Free cookie consent management tool by TermsFeed Policy Generator

source: branches/SimulationCore/SimulationSolution/HeuristicLab.Simulation/Model.cs @ 13757

Last change on this file since 13757 was 10525, checked in by abeham, 11 years ago

#1610: added visual model

File size: 4.7 KB
RevLine 
[10525]1using System;
2using System.Collections.Generic;
3using System.Linq;
4using HeuristicLab.Common;
5using HeuristicLab.SimulationCore;
6using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
7
8namespace HeuristicLab.Simulation {
9  [StorableClass]
10  partial class Model1 : IModel {
11    [Storable]
12    public double CurrentTime { get; set; }
13
14    private Model1(Model1 original, Cloner cloner) {
15      cloner.RegisterClonedObject(original, this);
16      CurrentTime = original.CurrentTime;
17    }
18    public Model1() { }
19
20    public object Clone() { return Clone(new Cloner()); }
21    public IDeepCloneable Clone(Cloner cloner) {
22      return new Model1(this, cloner);
23    }
24  }
25
26  [StorableClass]
27  partial class Activity1 : HeuristicLab.SimulationCore.Activity<Model1> {
28    public override IEnumerable<Type> MonitoredActions {
29      get { return new[] { typeof(Action4) }; }
30    }
31
32    [StorableConstructor]
33    private Activity1(bool deserializing) : base(deserializing) { }
34    private Activity1(Activity1 original, Cloner cloner) : base(original, cloner) { }
35    public Activity1() : base(new SortedListEventQueue<Model1>()) { }
36
37    public override void ManageEvents(Model1 model, IAction<Model1> lastAction) {
38      if (lastAction is Action4) ProcessAction4(model, (Action4)lastAction);
39    }
40
41    private void EnqueueAction1(double time, Action1 action) {
42      EventQueue.Push(time, action);
43    }
44
45    public override IDeepCloneable Clone(Cloner cloner) {
46      return new Activity1(this, cloner);
47    }
48  }
49
50  [StorableClass]
51  partial class Activity2 : HeuristicLab.SimulationCore.Activity<Model1> {
52    public override IEnumerable<Type> MonitoredActions {
53      get { return new[] { typeof(Action1) }; }
54    }
55
56    [StorableConstructor]
57    private Activity2(bool deserializing) : base(deserializing) { }
58    private Activity2(Activity2 original, Cloner cloner) : base(original, cloner) { }
59    public Activity2() : base(new SortedListEventQueue<Model1>()) { }
60
61    public override void ManageEvents(Model1 model, IAction<Model1> lastAction) {
62      if (lastAction is Action1) ProcessAction1(model, (Action1)lastAction);
63    }
64
65    private void EnqueueAction2(double time, Action2 action) {
66      EventQueue.Push(time, action);
67    }
68    private void EnqueueAction3(double time, Action3 action) {
69      EventQueue.Push(time, action);
70    }
71
72    public override IDeepCloneable Clone(Cloner cloner) {
73      return new Activity2(this, cloner);
74    }
75  }
76
77  [StorableClass]
78  partial class Activity3 : HeuristicLab.SimulationCore.Activity<Model1> {
79    public override IEnumerable<Type> MonitoredActions {
80      get { return new[] { typeof(Action1), typeof(Action2) }; }
81    }
82
83    [StorableConstructor]
84    private Activity3(bool deserializing) : base(deserializing) { }
85    private Activity3(Activity3 original, Cloner cloner) : base(original, cloner) { }
86    public Activity3() : base(new SortedListEventQueue<Model1>()) { }
87
88    public override void ManageEvents(Model1 model, IAction<Model1> lastAction) {
89      if (lastAction is Action1) ProcessAction1(model, (Action1)lastAction);
90      if (lastAction is Action2) ProcessAction2(model, (Action2)lastAction);
91    }
92
93    private void EnqueueAction4(double time, Action4 action) {
94      EventQueue.Push(time, action);
95    }
96
97    public override IDeepCloneable Clone(Cloner cloner) {
98      return new Activity3(this, cloner);
99    }
100  }
101
102  [StorableClass]
103  partial class Action1 : HeuristicLab.SimulationCore.Action<Model1> {
104
105    private Action1(Action1 original, Cloner cloner) : base(original, cloner) { }
106    public Action1() { }
107
108    public override IDeepCloneable Clone(Cloner cloner) {
109      return new Action1(this, cloner);
110    }
111  }
112  [StorableClass]
113  partial class Action2 : HeuristicLab.SimulationCore.Action<Model1> {
114
115    private Action2(Action2 original, Cloner cloner) : base(original, cloner) { }
116    public Action2() { }
117
118    public override IDeepCloneable Clone(Cloner cloner) {
119      return new Action2(this, cloner);
120    }
121  }
122  [StorableClass]
123  partial class Action3 : HeuristicLab.SimulationCore.Action<Model1> {
124
125    private Action3(Action3 original, Cloner cloner) : base(original, cloner) { }
126    public Action3() { }
127
128    public override IDeepCloneable Clone(Cloner cloner) {
129      return new Action3(this, cloner);
130    }
131  }
132  [StorableClass]
133  partial class Action4 : HeuristicLab.SimulationCore.Action<Model1> {
134
135    private Action4(Action4 original, Cloner cloner) : base(original, cloner) { }
136    public Action4() { }
137
138    public override IDeepCloneable Clone(Cloner cloner) {
139      return new Action4(this, cloner);
140    }
141  }
142}
Note: See TracBrowser for help on using the repository browser.