5 #ifndef ROCKY_ZAGROS_DENA_GUARD
6 #define ROCKY_ZAGROS_DENA_GUARD
15 #include<rocky/zagros/strategies/log.h>
72 std::string memory_id;
73 std::string main_cnt_id;
76 std::string memory_id;
77 std::string main_cnt_id;
98 float differential_weight;
124 enum bcd_mask_generator { uniform };
126 bcd_mask_generator generator;
130 std::vector<int> sub_procedure;
174 static std::vector<flow_node_variant>& nodes(){
175 static std::vector<flow_node_variant> nodes_;
178 static std::map<int, int>& next_node(){
179 static std::map<int, int> next_node_;
182 template<
typename T_n>
189 static void register_link(
int s,
int e){
190 node::next_node()[s] = e;
192 static int next(
int tag){
193 return node::next_node()[tag];
199 std::vector<int> procedure;
204 auto last_node = procedure.back();
205 auto first_node = f.procedure.front();
206 node::register_link(last_node, first_node);
207 this->procedure.insert(this->procedure.end(), f.procedure.begin(), f.procedure.end());
226 static flow create(std::string
id,
int n_particles,
int group_size){
230 node.n_particles = n_particles;
231 node.group_size = group_size;
232 auto node_tag = node::register_node<>(
node);
233 f.procedure.push_back(node_tag);
236 static flow create(std::string
id,
int n_particles){
237 return create(
id, n_particles, n_particles);
239 static flow
create(std::string
id){
255 auto node_tag = node::register_node<>(
node);
256 f.procedure.push_back(node_tag);
269 auto node_tag = node::register_node<>(
node);
270 f.procedure.push_back(node_tag);
286 return fmt::format(
"__temp__T[{}]__", tag);
292 static std::string
temp_name(
int tag, std::string desc){
293 return fmt::format(
"__temp__{}__{}__", tag, desc);
312 auto node_tag = node::register_node<>(
node);
313 f.procedure.push_back(node_tag);
330 node.handler = &handler;
331 auto node_tag = node::register_node<>(
node);
332 f.procedure.push_back(node_tag);
337 return best(
"__best__", handler);
352 node.handler = &handler;
353 auto node_tag = node::register_node<>(
node);
354 f.procedure.push_back(node_tag);
359 return best(std::string(
"__best__"), handler);
371 static flow select(){
374 node.generator = bcd_mask_generator::uniform;
375 auto node_tag = node::register_node<>(
node);
376 f.procedure.push_back(node_tag);
396 auto node_tag = node::register_node<>(
node);
397 f.procedure.push_back(node_tag);
419 node.n_iters = iters;
420 node.sub_procedure.insert(
node.sub_procedure.end(), wrapped_flow.procedure.begin(), wrapped_flow.procedure.end());
421 auto node_tag = node::register_node<>(
node);
422 f.procedure.push_back(node_tag);
436 node.sub_procedure.insert(
node.sub_procedure.end(), wrapped_flow.procedure.begin(), wrapped_flow.procedure.end());
437 auto node_tag = node::register_node<>(
node);
438 f.procedure.push_back(node_tag);
452 node.sub_procedure.insert(
node.sub_procedure.end(), wrapped_flow.procedure.begin(), wrapped_flow.procedure.end());
453 auto node_tag = node::register_node<>(
node);
454 f.procedure.push_back(node_tag);
470 node.sub_procedure.insert(
node.sub_procedure.end(), wrapped_flow.procedure.begin(), wrapped_flow.procedure.end());
471 auto node_tag = node::register_node<>(
node);
472 f.procedure.push_back(node_tag);
483 return while_improve(std::string(
"__best__"), n, wrapped_flow);
492 return while_improve(std::string(
"__best__"), 20, wrapped_flow);
515 node.memory_id = mem_id;
516 node.main_cnt_id = main_id;
517 auto node_tag = node::register_node<>(
node);
518 f.procedure.push_back(node_tag);
528 return base + std::string(
"__pvel__");
537 return base + std::string(
"__pmem__");
546 return base + std::string(
"__gmem__");
555 return base + std::string(
"__nmem__");
564 return base + std::string(
"__cmem__");
581 static flow step(std::string mem_id, std::string main_id){
584 node.memory_id = mem_id;
585 node.main_cnt_id = main_id;
586 auto node_tag = node::register_node<>(
node);
587 f.procedure.push_back(node_tag);
605 static flow step(std::string mem_id, std::string main_id){
608 node.memory_id = mem_id;
609 node.main_cnt_id = main_id;
610 auto node_tag = node::register_node<>(
node);
611 f.procedure.push_back(node_tag);
629 static flow gaussian(std::string
id,
int dims=1,
float mu=0.0,
float sigma=1.0){
636 auto node_tag = node::register_node<>(
node);
637 f.procedure.push_back(node_tag);
657 auto node_tag = node::register_node<>(
node);
658 f.procedure.push_back(node_tag);
673 node.crossover_prob = cr;
674 node.differential_weight = dw;
675 auto node_tag = node::register_node<>(
node);
676 f.procedure.push_back(node_tag);
679 static flow segment(std::string
id,
int segment_length){
683 node.segment_length = segment_length;
684 auto node_tag = node::register_node<>(
node);
685 f.procedure.push_back(node_tag);
713 auto node_tag = node::register_node<>(
node);
714 f.procedure.push_back(node_tag);
745 node.height = height;
746 auto node_tag = node::register_node<>(
node);
747 f.procedure.push_back(node_tag);
750 static flow heatmap(std::string label,
int width){
751 return heatmap(label, width, width);
753 static flow heatmap(std::string label){
754 return heatmap(label, 500);
756 static flow heatmap(){
757 return heatmap(std::string(
"heatmap"));
770 node.handler = &handler;
771 auto node_tag = node::register_node<>(
node);
772 f.procedure.push_back(node_tag);