summaryrefslogtreecommitdiff
path: root/core/pla_init_default.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/pla_init_default.hpp')
-rw-r--r--core/pla_init_default.hpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/core/pla_init_default.hpp b/core/pla_init_default.hpp
new file mode 100644
index 0000000..a0e0808
--- /dev/null
+++ b/core/pla_init_default.hpp
@@ -0,0 +1,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