1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#ifndef IsIx5LlrtRM4hjuaHq11FAgirk
#define IsIx5LlrtRM4hjuaHq11FAgirk
#include <assert.h>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/if.hpp>
#include "template_helpers.hpp"
#include "time.hpp"
#include "quant_types.hpp"
#include "model.hpp" // for Weight
namespace PLA_InitByCopy_Impl {
using namespace boost;
using namespace boost::mpl;
template<typename Prop, typename QuantClass = typename Prop::quant::class_t>
struct Action {
template<typename Data>
void operator() (Data &, Time) {} // NOOP on discrete quants
};
template<typename Prop>
struct Action<Prop, ContinuousPropertyClass> {
typedef typename Prop::quant Quant;
template<typename Data>
void operator() (Data &data, Time time) {
PropertyInstance<Prop, true> src;
typedef typename if_<is_same<Quant, Global>,
uint8_t,
typename Prop::instance_ptr_t::ptr_t
>::type ptr_t;
assert(time <= src.data.timeLimit); // we do not want to cause addCheckpoint()
for (ptr_t i = 0; i < Prop::instance_ptr_t::numInstances(); i++)
data.data.set(src.data.getTime(time, i), i, src.data.getValue(time, i));
}
};
struct PLA_InitByCopy {
// action types & consts
typedef Void result_t;
template<typename ContextProp, bool _doWriteResults> struct local_state_t
: Action<ContextProp> {};
// action state
result_t result;
Time time;
PLA_InitByCopy(Time time) : time(time) {}
// action methods
template<typename _PC, typename ContextData, typename LocalState>
inline void pre(_PC &, ContextData &data, LocalState &action) {
action(data, time);
}
template<typename _PC, typename _Data, typename _LocalState>
inline void post(_PC &, _Data &, _LocalState &) { }
};
} // namespace PLA_InitByCopy_Impl
using PLA_InitByCopy_Impl::PLA_InitByCopy;
#endif // IsIx5LlrtRM4hjuaHq11FAgirk
|