summaryrefslogtreecommitdiff
path: root/core/pla_init_default.hpp
blob: a0e0808c42e0ddccf187b6023e309025d2496806 (plain)
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
#ifndef CbSv0r4ZjDkLZr4WCEmSXjjwPA0
#define CbSv0r4ZjDkLZr4WCEmSXjjwPA0

#include <assert.h>

#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>

#include "template_helpers.hpp"
#include "time.hpp"
#include "quant_types.hpp"

#include "model.hpp" // for Weight

namespace PLA_Init_Default_Impl {

template<typename Prop, typename QC = typename Prop::quant::class_t /* == discrete */>
struct Action {
  template<typename Data> void operator() (Data &data) {}
};

template<typename Prop>
struct Action<Prop, ContinuousPropertyClass> {
  template<typename Data>
  void operator() (Data &data) {
    if (boost::is_same<Weight, Prop>::value ||
	boost::is_same<SumWeight, Prop>::value ||
	boost::is_same<TargetSumWeight, Prop>::value)
      return; // do not set weight .. it is done in convert_topology
    for (uint64_t i{0}; 
	 i < Prop::quant::instance_ptr_t::numInstances();
	 i++) {
      data.data.set(0, i, Prop::initialValue);
    }
  }
};

// init default action
struct PLA_Init_Default {
  // action types & consts
  typedef Void result_t;
  template<typename ContextProp, bool doWriteResults> struct local_state_t {
    typedef ContextProp prop;
    static const bool write = doWriteResults;
  };

  // action state
  result_t result;

  // action methods
  template<typename _PropComp, typename ContextData, typename LocalState>
  inline void pre(_PropComp &pc, ContextData &data, LocalState &state) {
    Action<typename LocalState::prop>()(data);
  }

  template<typename _PropComp, typename _Data, typename _LocalState>
  inline void post(_PropComp &pc, _Data &data, _LocalState &state) { }
};

} // ns

using PLA_Init_Default_Impl::PLA_Init_Default;


#endif // CbSv0r4ZjDkLZr4WCEmSXjjwPA0
contact: Jan Huwald // Impressum