kangaroo  1.0
the cbls library
valueVectorFunction.hpp
Go to the documentation of this file.
1 
12 #ifndef ValueVectorFunctionHppIncluded
13 #define ValueVectorFunctionHppIncluded
14 
15 
16 
17 #include "cbls/frames/index.hpp"
18 
19 
21 
22 
23 
31 template <typename value, typename metric = value, VectorType vectorType = FactorVector>
33 {
34  public:
35 
38 
39  typedef value ValueType;
40  typedef metric MetricType;
41 
42  virtual Wrap ExecWrappedValue() const override final;
43  virtual Wrap SimulWrappedValue() const override final;
44  virtual Dim VectorFieldCount() const override final;
45  virtual Wrap ExecWrappedVectorField(Order const MaxiOrMini,
46  Serial const FieldSerial) const override final;
47 
48  virtual ValueRecord<value> const * ExprValueRecord() const override final;
49  virtual VectorRecord<metric> const * ExprVectorRecord
50  (Order const MaxiOrMini) const override final;
51  virtual VectorType ExprVectorType() const override final;
52  virtual Serial ValueTypeSerial() const override final;
53  virtual Serial MetricTypeSerial() const override final;
54 
55  value ExecValue() const;
56  value SimulValue() const;
57  Order MetricOptiOrder() const;
58  metric ExecVectorField(Order MaxiOrMini, Serial const FieldSerial) const;
59 
61 
62  protected:
63 
66 
67  virtual ~ValueVectorFunction();
68  ValueVectorFunction(System * const pSystem, Order const MaxiOrMini, Dim const ParamCount);
69  ValueVectorFunction(ValueVectorFunction<value,metric,vectorType> && that) noexcept = delete;
70  ValueVectorFunction(ValueVectorFunction<value,metric,vectorType> const & that) = delete;
71  ValueVectorFunction<value,metric,vectorType> & operator =
72  (ValueVectorFunction<value,metric,vectorType> && that) noexcept = delete;
73  ValueVectorFunction<value,metric,vectorType> & operator =
74  (ValueVectorFunction<value,metric,vectorType> const & that) = delete;
75 
77 
80 
84 
85  void defineExprValueRecord();
86  void defineExprVectorRecord(Dim const FieldCount);
87 
89 
92 
93  virtual Wrap ExecWrappedScalar(Order const MaxiOrMini) const;
94 
96 
97  #if ComputeLazy
98 
101  virtual void setupUndoPatrons() override final;
102  virtual void undoVectors(Serial const ParamSerial) override;
103 
105  #endif // ComputeLazy
106 
109 
110  protected:
111 
112  virtual void syncExecClock();
113  virtual void syncSimulClock();
114 
116 };
117 
118 
119 
123 template<typename value, typename metric, VectorType vectorType>
125  Order const MaxiOrMini, Dim const ParamCount) :
126  Function(pSystem, ParamCount), mExprValueRecord(nullptr),
127  mExprVectorRecord(nullptr), mMetricOptiOrder(MaxiOrMini)
128 {
129  WatchError
131  CatchError
132 }
133 
134 
138 template<typename value, typename metric, VectorType vectorType>
140 {
141  WatchError
142  if (mExprValueRecord) delete mExprValueRecord;
143  if (mExprVectorRecord) delete mExprVectorRecord;
144  CatchError
145 }
146 
147 
148 
152 template<typename value, typename metric, VectorType vectorType>
154 {
155  WatchError
156  return Wrap(mExprValueRecord->ExecData());
157  CatchError
158 }
159 
160 
161 
165 template<typename value, typename metric, VectorType vectorType>
167 {
168  WatchError
169  return Wrap(mExprValueRecord->SimulData(SysMaster->SimulClock()));
170  CatchError
171 }
172 
173 
177 template<typename value, typename metric, VectorType vectorType>
179 {
180  WatchError
181  return mExprVectorRecord->FieldCount();
182  CatchError
183 }
184 
185 
189 template<typename value, typename metric, VectorType vectorType>
191  (Order const MaxiOrMini, Serial const FieldSerial) const
192 {
193  WatchError
194  Warn(MaxiOrMini != mMetricOptiOrder, kExprVectorNotDefined);
195  return Wrap(mExprVectorRecord->Field(FieldSerial).ExecData());
196  CatchError
197 }
198 
199 
200 
204 template<typename value, typename metric, VectorType vectorType>
206 {
207  WatchError
208  return mExprValueRecord->ExecData();
209  CatchError
210 }
211 
212 
213 
217 template<typename value, typename metric, VectorType vectorType>
219 {
220  WatchError
221  return mExprValueRecord->SimulData(SysMaster->SimulClock());
222  CatchError
223 }
224 
225 
229 template<typename value, typename metric, VectorType vectorType>
231  (Order MaxiOrMini, Serial const FieldSerial) const
232 {
233  WatchError
234  Warn(MaxiOrMini != mMetricOptiOrder, kExprVectorNotDefined);
235  return mExprVectorRecord->Field(FieldSerial).ExecData();
236  CatchError
237 }
238 
239 
240 
244 template<typename value, typename metric, VectorType vectorType>
246 {
247  WatchError
248  return vectorType;
249  CatchError
250 }
251 
252 
256 template<typename value, typename metric, VectorType vectorType>
258 {
259  WatchError
260  return mMetricOptiOrder;
261  CatchError
262 }
263 
264 
265 
269 template<typename value, typename metric, VectorType vectorType>
271 {
272  WatchError
274  CatchError
275 }
276 
277 
278 
282 template<typename value, typename metric, VectorType vectorType>
284 {
285  WatchError
287  CatchError
288 }
289 
290 
291 
295 template<typename value, typename metric, VectorType vectorType>
297 {
298  WatchError
299  return mExprValueRecord;
300  CatchError
301 }
302 
303 
304 
308 template<typename value, typename metric, VectorType vectorType>
310 {
311  WatchError
312  if (MaxiOrMini == mMetricOptiOrder)
313  return mExprVectorRecord;
314  else
315  return nullptr;
316  CatchError
317 }
318 
319 
320 
324 template<typename value, typename metric, VectorType vectorType>
326 {
327  WatchError
328  mExprValueRecord = new ValueRecord<value>;
329  CatchError
330 }
331 
332 
333 
337 template<typename value, typename metric, VectorType vectorType>
339 {
340  WatchError
341  mExprVectorRecord = new VectorRecord<metric>(FieldCount);
342  CatchError
343 }
344 
345 
346 
350 template<typename value, typename metric, VectorType vectorType>
352 {
353  WatchError
354  if (mExprValueRecord) mExprValueRecord->syncExecClock();
355  if (mExprVectorRecord) mExprVectorRecord->syncExecClock();
357  CatchError
358 }
359 
360 
364 template<typename value, typename metric, VectorType vectorType>
366 {
367  WatchError
368  if (mExprValueRecord) mExprValueRecord->syncSimulClock();
370  CatchError
371 }
372 
373 
374 
378 template<typename value, typename metric, VectorType vectorType>
380 {
381  WatchError
382  Throw(kExprScalarNotDefined);
383  CatchError
384 }
385 
386 
387 
388 #if ComputeLazy
389 
392 template<typename value, typename metric, VectorType vectorType>
394 {
395  WatchError
396  setupScalarUndoPatrons();
397  setupVectorUndoPatrons();
398  CatchError
399 }
400 #endif //ComputeLazy
401 
402 
403 
404 #if ComputeLazy
405 
408 template<typename value, typename metric, VectorType vectorType>
409 inline void ValueVectorFunction<value,metric,vectorType>::undoVectors(Serial const ParamSerial)
410 {
411  WatchError
412  Throw(kVectorUndoNotDefined);
413  CatchError
414 }
415 #endif //ComputeLazy
416 
417 
418 
420 
421 
422 #endif//ValueVectorFunctionHppIncluded
virtual void syncExecClock()
Synchronise the execution clock.
Definition: valueVectorFunction.hpp:351
Order
Orders.
Definition: datatypes.hpp:156
virtual VectorType ExprVectorType() const overridefinal
Expression vector type.
Definition: valueVectorFunction.hpp:245
Clock SimulClock() const
Get the simulation clock.
Definition: system1.hpp:249
Functions that depend on other expressions.
Definition: function0.hpp:31
virtual Wrap ExecWrappedValue() const overridefinal
Execution value wrap.
Definition: valueVectorFunction.hpp:153
void setExprModel(Identifier const pModel)
Set expression model.
Definition: expression1.hpp:592
value ValueType
Value type.
Definition: valueVectorFunction.hpp:39
value ExecValue() const
Execution value.
Definition: valueVectorFunction.hpp:205
ValueRecord< value > * mExprValueRecord
Point to the value record.
Definition: valueVectorFunction.hpp:81
#define openKangarooSpace
Open the project namespace.
Definition: project.hpp:74
virtual Serial ValueTypeSerial() const overridefinal
Value type serial.
Definition: valueVectorFunction.hpp:270
virtual void syncSimulClock()
synchronise the simulation clock.
Definition: valueVectorFunction.hpp:365
Vector record to store expression vector metrics.
Definition: vectorrecord.hpp:50
Order MetricOptiOrder() const
Metric optimisation ordering.
Definition: valueVectorFunction.hpp:257
virtual Wrap ExecWrappedVectorField(Order const MaxiOrMini, Serial const FieldSerial) const overridefinal
Execution value wrap of a vector field.
Definition: valueVectorFunction.hpp:191
virtual VectorRecord< metric > const * ExprVectorRecord(Order const MaxiOrMini) const overridefinal
Expression metric.
Definition: valueVectorFunction.hpp:309
constexpr char const * kVectorUndoNotDefined
Vector undo not defined.
Definition: messages.hpp:32
Index for Library Frames.
value SimulValue() const
Simulation value.
Definition: valueVectorFunction.hpp:218
void defineExprValueRecord()
Define expression value.
Definition: valueVectorFunction.hpp:325
VectorType
Vector type.
Definition: vectorrecord.hpp:31
Unique identifier of a class.
metric MetricType
Metric type.
Definition: valueVectorFunction.hpp:40
void defineExprVectorRecord(Dim const FieldCount)
Define vector record.
Definition: valueVectorFunction.hpp:338
virtual Wrap ExecWrappedScalar(Order const MaxiOrMini) const
Execution scalar wrap of the expression—throws error.
Definition: valueVectorFunction.hpp:379
Constraint-based local search systems.
Definition: system0.hpp:45
Value vector function model.
Definition: valueVectorFunction.hpp:32
Order const mMetricOptiOrder
Maximisation or minimisation?
Definition: valueVectorFunction.hpp:83
System *const SysMaster
The system that contains this expression.
Definition: expression0.hpp:281
ValueVectorFunction(System *const pSystem, Order const MaxiOrMini, Dim const ParamCount)
Param constructor.
Definition: valueVectorFunction.hpp:124
#define closeKangarooSpace
Close the project namespace.
Definition: project.hpp:75
metric ExecVectorField(Order MaxiOrMini, Serial const FieldSerial) const
Execution metric of a vector field.
Definition: valueVectorFunction.hpp:231
virtual ValueRecord< value > const * ExprValueRecord() const overridefinal
Expression value.
Definition: valueVectorFunction.hpp:296
virtual ~ValueVectorFunction()
Destructor.
Definition: valueVectorFunction.hpp:139
VectorRecord< metric > * mExprVectorRecord
Point to the vector record.
Definition: valueVectorFunction.hpp:82
constexpr char const * kExprVectorNotDefined
Vector not defined for the expression.
Definition: messages.hpp:140
Wrappers for values.
Definition: wrapper.hpp:68
Wrapper Wrap
Shortcut for Wrapper.
Definition: wrapper.hpp:321
virtual void syncExecClock() override
Synchronize the execution clock.
Definition: function1.hpp:304
Represents data type meta.
Definition: datatypes.hpp:73
Value records store expression values.
Definition: valuerecord.hpp:32
virtual Serial MetricTypeSerial() const overridefinal
Metric type serial.
Definition: valueVectorFunction.hpp:283
constexpr char const * kExprScalarNotDefined
Scalar not defined for the expression.
Definition: messages.hpp:139
virtual Dim VectorFieldCount() const overridefinal
Number of fields in the vectors.
Definition: valueVectorFunction.hpp:178
virtual void syncSimulClock()
Synchronize the simulation clock.
Definition: expression1.hpp:771
virtual Wrap SimulWrappedValue() const overridefinal
Simulation value wrap.
Definition: valueVectorFunction.hpp:166