45 #include "stack_trace.h" 49 #include "instance_info.h" 51 #include "dbg_config.h" 61 #define BRAIN_DBG(prm) DBG(prm) 62 #define BRAIN_CK(prm) DBG_BJ_LIB_CK(prm) 63 #define BRAIN_CK_PRT(prm, comms1) DBG_CK_2(prm, comms1) 64 #define BRAIN_CK_0(prm) DBG_BJ_LIB_CK(prm) 66 #define BRAIN_CK_1(prm) 67 #define BRAIN_CK_2(prm) 69 #define BRAIN_REL_CK(prm) if(! (prm)){ throw brain_exception(0, #prm); } 71 #define BRAIN_REL_CK_PRT(prm, comms1) \ 73 bj_ostream& os = bj_dbg; \ 77 throw brain_exception(0, #prm); \ 85 #define CY_LIB_DIR "draw_cnf_js_lib" 86 #define CY_IC_KIND "_ic_" 87 #define CY_NMP_KIND "_nmp_" 88 #define CY_CIRCLE_LAYOUT "'circle'" 89 #define CY_PRESET_LAYOUT "'preset'" 90 #define MAX_CY_STEPS 1000 94 #define MIN_TRAINABLE_NUM_SUB 3 124 #define k_invalid_order 0 125 #define k_left_order 1 126 #define k_right_order 2 127 #define k_random_order 3 129 #define INVALID_ROUND -1 130 #define INVALID_RECOIL 0 131 #define INVALID_LEVEL -1 132 #define INVALID_TIER -1 133 #define INVALID_BLOCK -1 134 #define INVALID_COLOR -1 135 #define INVALID_NUM_SUB -1 137 #define INVALID_MINSHA "invalid_minsha" 138 #define INVALID_SHA "invalid_sha" 141 #define MAX_LAYERS 1000 146 class brain_exception :
public top_exception {
148 brain_exception(
long the_id = 0, ch_string assrt =
"") : top_exception(the_id, assrt)
155 #define DBG_DIR "./dbg_ic_output/" 156 #define DBG_PREF "brain" 157 #define DBG_SUFI ".myl" 159 #define DEFINE_GET_DBG_SLV(cls_nm) \ 161 cls_nm::get_dbg_slv(){ \ 162 brain* the_brn = get_dbg_brn(); \ 163 if(the_brn == NULL_PT){ return NULL_PT; } \ 164 solver* the_slv = the_brn->br_pt_slvr; \ 178 BRAIN_DBG(
class dbg_inst_info;)
196 typedef row<quanton*> row_quanton_t;
197 typedef row<row_quanton_t> row_row_quanton_t;
199 typedef row<neuron*> row_neuron_t;
200 typedef row<row_neuron_t> row_row_neuron_t;
202 typedef row<neuromap*> row_neuromap_t;
204 typedef bj_big_int_t recoil_counter_t;
205 typedef bj_big_int_t round_counter_t;
207 DECLARE_PRINT_FUNCS(ticket)
208 DECLARE_PRINT_FUNCS(alert_rel)
210 DECLARE_PRINT_FUNCS(
neuron)
211 DECLARE_PRINT_FUNCS(reason)
215 DECLARE_PRINT_FUNCS(qulayers)
216 DECLARE_PRINT_FUNCS(cov_entry)
224 extern
brain* NULL_BRN_PT;
229 comparison cmp_qlevel(
quanton* const & qua1,
quanton* const & qua2);
234 bool dbg_all_consec(row<
long>& rr1);
237 void dbg_run_diff(ch_string fnm1, ch_string fnm2, ch_string dff_fnm);
238 void dbg_prepare_used_dbg_ccl(row_quanton_t& rr_qua, canon_clause& dbg_ccl);
239 void dbg_print_ccls_neus(bj_ostream& os, row<canon_clause*>& dbg_ccls);
240 bool dbg_run_satex_on(
brain& brn, ch_string f_nam,
neuromap* dbg_nmp);
241 void dbg_reset_all_na_creat_flags(row_neuromap_t& all_nmp);
245 bool dbg_equal_positons(
brain& brn, row_quanton_t& quas1, row_quanton_t& quas2,
247 void dbg_get_all_positons(row_quanton_t& all_quas, row_quanton_t& all_pos,
250 bool ck_motives(
brain& brn, row_quanton_t& mots);
252 bool is_tk_equal(ticket& x, ticket& y);
254 charge_t negate_trinary(charge_t val);
256 bool has_neu(row_neuron_t& rr_neus,
neuron* neu);
258 void get_quas_of(
brain& brn, row_neuron_t& all_neus, row_quanton_t& all_quas);
260 void negate_quantons(row_quanton_t& qua_row);
261 void get_ids_of(row_quanton_t& quans, row_long_t& the_ids);
262 long find_max_level(row_quanton_t& tmp_mots);
263 long find_max_tier(row_quanton_t& tmp_mots,
long from_idx = 0);
267 row<canon_clause*>& ccls_in, row<canon_clause*>& ccls_not_in);
272 void append_missing_opps(
brain& brn, row_quanton_t& all_quas);
279 recoil_counter_t tk_recoil;
289 tk_recoil = INVALID_RECOIL;
290 tk_level = INVALID_LEVEL;
293 brain* get_dbg_brn(){
297 solver* get_dbg_slv(){
302 bool c1 = (tk_recoil == INVALID_RECOIL);
303 bool c2 = (tk_level == INVALID_LEVEL);
309 return ((tk_recoil != INVALID_RECOIL) && (tk_level != INVALID_LEVEL));
312 bool is_older_than(ticket& nmp_tk);
317 bj_ostream& print_ticket(bj_ostream& os,
bool from_pt =
false){
319 os <<
"rc:" << tk_recoil;
320 os <<
" lv:" << tk_level;
329 is_tk_equal(ticket& x, ticket& y){
330 if(x.tk_recoil != y.tk_recoil){
return false; }
331 if(x.tk_level != y.tk_level){
return false; }
338 typedef receptor<alert_rel> rece_ar_t;
346 char* get_cls_name(){
347 return alert_rel::CL_NAME;
360 void init_alert_rel(
quanton* alert = NULL_PT,
quanton* ref = NULL_PT);
363 bool c1 = (ar_qu_alert == NULL_PT);
364 bool c2 = (ar_qu_ref == NULL_PT);
365 bool vg = (c1 && c2);
369 bj_ostream& print_alert_rel(bj_ostream& os,
bool from_pt =
false){
370 os <<
"ar={" << ar_qu_alert <<
"," << ar_qu_ref <<
"}";
384 #define DECLARE_NI_FLAG_FUNCS(flag_attr, flag_nam) \ 385 bool has_pos_##flag_nam(){ \ 386 return is_##flag_nam(); \ 389 bool has_neg_##flag_nam(){ \ 390 return opposite().is_##flag_nam(); \ 393 bool is_##flag_nam(){ \ 394 bool resp = get_flag(flag_attr, k_##flag_nam##_flag); \ 398 bool has_##flag_nam(){ \ 399 return (is_##flag_nam() || opposite().is_##flag_nam()); \ 402 void reset_its_##flag_nam(brain& brn); \ 403 void set_##flag_nam(brain& brn); \ 404 void set_bi##flag_nam(brain& brn); \ 405 void reset_##flag_nam(brain& brn); \ 411 #define DEFINE_NI_FLAG_FUNCS(flag_attr, flag_nam, single) \ 412 void quanton::reset_its_##flag_nam(brain& brn){ \ 413 BRAIN_CK(! single || has_##flag_nam()); \ 414 if(has_pos_##flag_nam()){ \ 415 reset_##flag_nam(brn); \ 417 if(has_neg_##flag_nam()){ \ 418 opposite().reset_##flag_nam(brn); \ 422 void quanton::set_##flag_nam(brain& brn){ \ 424 BRAIN_CK_PRT((! has_##flag_nam()), os << "________" << this); \ 425 if(! is_##flag_nam() && ! opposite().is_##flag_nam()){ \ 426 set_flag(flag_attr, k_##flag_nam##_flag); \ 427 brn.br_qu_tot_##flag_nam++; \ 431 void quanton::set_bi##flag_nam(brain& brn){ \ 432 BRAIN_CK(! single); \ 433 BRAIN_CK(! is_##flag_nam()); \ 434 if(! is_##flag_nam()){ \ 435 set_flag(flag_attr, k_##flag_nam##_flag); \ 436 brn.br_qu_tot_##flag_nam++; \ 440 void quanton::reset_##flag_nam(brain& brn){ \ 441 BRAIN_CK(is_##flag_nam()); \ 442 if(is_##flag_nam()){ \ 443 BRAIN_CK(! single || ! opposite().is_##flag_nam()); \ 444 reset_flag(flag_attr, k_##flag_nam##_flag); \ 445 brn.br_qu_tot_##flag_nam--; \ 453 #define DECLARE_NI_FLAG_ALL_FUNCS(flag_nam) \ 454 long set_all_bi##flag_nam(brain& brn, row_quanton_t& rr_all); \ 455 long reset_all_its_##flag_nam(brain& brn, row_quanton_t& rr_all); \ 456 long reset_all_##flag_nam(brain& brn, row_quanton_t& rr_all); \ 457 long set_all_##flag_nam(brain& brn, row_quanton_t& rr_all); \ 458 long append_all_not_##flag_nam(brain& brn, row_quanton_t& rr_src, \ 459 row_quanton_t& rr_dst); \ 460 void append_all_has_##flag_nam(brain& brn, row_quanton_t& rr_src, \ 461 row_quanton_t& rr_dst, bool val_has = true); \ 462 bool same_quantons_##flag_nam(brain& brn, row_quanton_t& sup_ss, \ 463 row_quanton_t& sub_ss, row_quanton_t* all_bad_qua = NULL_PT); \ 464 bool all_qu_have_##flag_nam(brain& brn, row_quanton_t& rr1, bool val = true); \ 469 #define DEFINE_NI_FLAG_ALL_FUNCS(flag_nam) \ 470 long set_all_bi##flag_nam(brain& brn, row_quanton_t& rr_all){ \ 471 long num_qua_mod = 0; \ 472 for(long aa = 0; aa < rr_all.size(); aa++){ \ 473 quanton& qua = *(rr_all[aa]); \ 474 if(! qua.is_##flag_nam()){ \ 475 qua.set_bi##flag_nam(brn); \ 479 return num_qua_mod; \ 482 long reset_all_its_##flag_nam(brain& brn, row_quanton_t& rr_all){ \ 484 for(long aa = 0; aa < rr_all.size(); aa++){ \ 485 BRAIN_CK(rr_all[aa] != NULL_PT); \ 486 quanton& qua = *(rr_all[aa]); \ 487 if(qua.has_##flag_nam()){ \ 488 qua.reset_its_##flag_nam(brn); \ 495 long reset_all_##flag_nam(brain& brn, row_quanton_t& rr_all){ \ 496 long num_qua_mod = 0; \ 497 for(long aa = 0; aa < rr_all.size(); aa++){ \ 498 BRAIN_CK(rr_all[aa] != NULL_PT); \ 499 quanton& qua = *(rr_all[aa]); \ 500 if(qua.has_##flag_nam()){ \ 501 qua.reset_##flag_nam(brn); \ 505 return num_qua_mod; \ 508 long set_all_##flag_nam(brain& brn, row_quanton_t& rr_all){ \ 509 long num_qua_mod = 0; \ 510 for(long aa = 0; aa < rr_all.size(); aa++){ \ 511 quanton& qua = *(rr_all[aa]); \ 512 if(! qua.has_##flag_nam()){ \ 513 qua.set_##flag_nam(brn); \ 517 return num_qua_mod; \ 520 long append_all_not_##flag_nam(brain& brn, row_quanton_t& rr_src, \ 521 row_quanton_t& rr_dst) \ 523 long num_qua_app = 0; \ 524 for(long aa = 0; aa < rr_src.size(); aa++){ \ 525 BRAIN_CK(rr_src[aa] != NULL_PT); \ 526 quanton& qua = *(rr_src[aa]); \ 527 if(! qua.has_##flag_nam()){ \ 528 qua.set_##flag_nam(brn); \ 533 return num_qua_app; \ 536 void append_all_has_##flag_nam(brain& brn, row_quanton_t& rr_src, \ 537 row_quanton_t& rr_dst, bool val_has) \ 539 for(long aa = 0; aa < rr_src.size(); aa++){ \ 540 BRAIN_CK(rr_src[aa] != NULL_PT); \ 541 quanton& qua = *(rr_src[aa]); \ 542 if(qua.has_##flag_nam() == val_has){ \ 548 bool same_quantons_##flag_nam(brain& brn, row_quanton_t& sup_ss, \ 549 row_quanton_t& sub_ss, row_quanton_t* all_bad_qua) \ 551 BRAIN_CK(brn.br_qu_tot_##flag_nam == 0); \ 552 set_all_##flag_nam(brn, sup_ss); \ 553 bool sm_quas = true; \ 554 for(long aa = 0; aa < sub_ss.size(); aa++){ \ 555 quanton& qua = *(sub_ss[aa]); \ 556 if(! qua.has_##flag_nam()){ \ 558 if(all_bad_qua != NULL_PT){ all_bad_qua->push(&qua); } \ 561 reset_all_##flag_nam(brn, sup_ss); \ 562 BRAIN_CK(brn.br_qu_tot_##flag_nam == 0); \ 566 bool all_qu_have_##flag_nam(brain& brn, row_quanton_t& rr_all, bool val){ \ 567 bool all_hv = true; \ 568 for(long aa = 0; aa < rr_all.size(); aa++){ \ 569 quanton& qua = *(rr_all[aa]); \ 570 if(qua.has_##flag_nam() != val){ \ 582 #define k_note0_flag k_flag0 583 #define k_note1_flag k_flag1 584 #define k_note2_flag k_flag2 585 #define k_note3_flag k_flag3 586 #define k_note4_flag k_flag4 587 #define k_note5_flag k_flag5 588 #define k_note6_flag k_flag6 590 DECLARE_NI_FLAG_ALL_FUNCS(note0);
591 DECLARE_NI_FLAG_ALL_FUNCS(note1);
592 DECLARE_NI_FLAG_ALL_FUNCS(note2);
593 DECLARE_NI_FLAG_ALL_FUNCS(note3);
594 DECLARE_NI_FLAG_ALL_FUNCS(note4);
595 DECLARE_NI_FLAG_ALL_FUNCS(note5);
596 DECLARE_NI_FLAG_ALL_FUNCS(note6);
598 typedef receptor<quanton> qu_rece_t;
606 char* get_cls_name(){
607 return quanton::CL_NAME;
614 DBG(
long qu_dbg_ic_trail_idx);
627 bool qu_has_been_cho;
636 row_neuron_t qu_all_cicle_sources;
639 row_neuron_t qu_tunnels;
642 row_neuron_t qu_all_neus;
645 long qu_alert_neu_idx;
656 ticket qu_candidate_tk;
660 ticket qu_upd_to_wrt_tk;
669 long qu_dbg_choice_idx;
670 long qu_dbg_num_fill_by_qua;
676 long qu_dbg_drw_x_pos;
677 long qu_dbg_drw_y_pos;
683 init_quanton(NULL, cg_neutral, INVALID_IDX, NULL);
687 BRAIN_CK_0(qu_source == NULL);
688 BRAIN_CK_0(qu_tunnels.size() == 0);
690 qu_tunnels.clear(
false,
true);
691 init_quanton(NULL, cg_neutral, 0, NULL);
694 DECLARE_NI_FLAG_FUNCS(qu_flags, note0);
695 DECLARE_NI_FLAG_FUNCS(qu_flags, note1);
696 DECLARE_NI_FLAG_FUNCS(qu_flags, note2);
697 DECLARE_NI_FLAG_FUNCS(qu_flags, note3);
698 DECLARE_NI_FLAG_FUNCS(qu_flags, note4);
699 DECLARE_NI_FLAG_FUNCS(qu_flags, note5);
700 DECLARE_NI_FLAG_FUNCS(qu_flags, note6);
702 void qua_tunnel_signals(
brain& brn);
704 brain* get_dbg_brn(){
705 brain* the_brn = NULL;
706 BRAIN_DBG(the_brn = qu_pt_brn);
710 solver* get_dbg_slv();
712 void init_quanton(
brain* brn, charge_t spn,
long ii,
quanton* inv){
713 BRAIN_DBG(qu_pt_brn = brn);
715 DBG(qu_dbg_ic_trail_idx = INVALID_IDX);
717 qu_id = (spn == cg_positive)?(ii + 1):(-(ii + 1));
718 if(spn == cg_neutral){ qu_id = 0; }
724 qu_alert_neu_idx = INVALID_IDX;
725 qu_lv_mono = INVALID_LEVEL;
731 qu_has_been_cho =
false;
733 qu_charge = cg_neutral;
734 qu_charge_tk.init_ticket();
737 qu_tier = INVALID_TIER;
739 qu_cicle_tk.init_ticket();
740 qu_all_cicle_sources.clear();
742 qu_tee.init_sortee(
true);
743 qu_reltee.init_sortrel(
true);
745 qu_tee.so_dbg_me_class = 1;
747 qu_tee.so_cmp_val = &qu_tier;
748 qu_tee.so_related = &qu_reltee;
750 qu_tee.so_dbg_extrn_id = qu_id;
752 if(qu_inverse != NULL_PT){
753 sortee& oppt = qu_inverse->qu_tee;
754 qu_reltee.so_opposite = &(oppt);
757 qu_tmp_col = INVALID_COLOR;
759 qu_candidate_tk.init_ticket();
760 qu_candidate_nmp = NULL_PT;
762 qu_upd_to_wrt_tk.init_ticket();
764 qu_proof_tk.init_ticket();
767 qu_dbg_choice_idx = INVALID_IDX;
768 qu_dbg_num_fill_by_qua = 0;
769 qu_dbg_tee_ti = INVALID_NATURAL;
770 qu_dbg_cy_sig = NULL_PT;
771 qu_dbg_cy_nmp = NULL_PT;
772 qu_dbg_phi_grp = INVALID_NATURAL;
774 qu_dbg_drw_x_pos = 0;
775 qu_dbg_drw_y_pos = 0;
780 void reset_candidate();
781 bool has_candidate(
brain& brn);
784 void reset_cicle_src();
789 BRAIN_CK(qu_inverse != NULL_PT);
790 return (*qu_inverse);
794 if(qu_spin == cg_negative){
795 BRAIN_CK_0(qu_inverse->qu_spin == cg_positive);
798 BRAIN_CK_0(qu_spin == cg_positive);
803 long resp = get_positon()->qu_id;
804 BRAIN_CK_0(resp > 0);
808 bool ck_all_tunnels();
809 void tunnel_swapop(
long idx_pop);
811 long qlevel(){
return qu_charge_tk.tk_level; }
815 return (qlevel() == ROOT_LEVEL);
819 bool is_lv_choice(
brain& brn);
821 bool ck_charge(
brain& brn);
823 bool is_pos(){
return (get_charge() == cg_positive); }
824 bool is_neg(){
return (get_charge() == cg_negative); }
825 bool is_nil(){
return (get_charge() == cg_neutral); }
827 void set_charge(
brain& brn,
neuron* src, charge_t cha,
long max_tier);
828 charge_t get_charge(){
return qu_charge; }
829 bool has_charge(){
return ! is_nil(); }
831 bool has_tier(){
return (qu_tier != INVALID_TIER); }
833 void set_source(
neuron* neu);
837 return (get_source() != NULL_PT);
840 void add_source(
neuron& neu);
842 bool has_learned_source();
845 bool cho = (! has_source() && (qlevel() != ROOT_LEVEL));
849 bool is_cicle_choice(){
850 bool is_clc_cho = is_choice() && ! is_opp_mono();
854 bool ck_biqu(
brain& brn);
856 bool is_qu_end_of_neuromap(
brain& brn);
858 long find_alert_idx(
bool is_init, row_quanton_t& all_pos);
859 void update_alert_neu(
brain& brn,
bool is_init);
861 void set_alert_neu(
brain& brn,
long the_idx);
862 void append_all_to_alert(
brain& brn, row_quanton_t& all_quas);
867 return opposite().is_mono();
871 bool h_mn = is_mono() || is_opp_mono();
876 if(qu_lv_mono != INVALID_LEVEL){
879 long opp_lv_mn = opposite().qu_lv_mono;
883 bool has_lv_alert_neu(
long lv_nmp);
889 bool is_qu_dominated(
brain& brn);
890 void make_qu_dominated(
brain& brn);
892 bool is_smaller_source(
neuron& neu,
long qti);
895 void update_qu_to_wrt_tk();
896 void update_source_wrt_tk(
brain& brn);
898 bool is_qu_to_upd_wrt_tk();
904 bool is_u = ! qu_proof_tk.is_tk_virgin();
908 cy_quk_t get_cy_kind();
910 bj_ostream& dbg_qu_print_col_cy_edge(bj_ostream& os,
long& consec,
long neu_idx);
912 bj_ostream& print_quanton_base(bj_ostream& os,
bool from_pt,
913 long ps_ti,
neuron* ps_src,
bool from_tee);
915 bj_ostream& print_quanton(bj_ostream& os,
bool from_pt =
false);
919 set_all_qu_nemap(row_quanton_t& all_quas,
neuromap* nmp,
long first_idx = 0);
939 row_quanton_t co_quas;
940 row_long_t co_qua_colors;
941 bool co_all_qua_consec;
943 row_neuron_t co_neus;
944 row_long_t co_neu_colors;
945 bool co_all_neu_consec;
948 init_coloring(pt_brn);
955 void init_coloring(
brain* pt_brn = NULL){
959 co_qua_colors.clear();
960 co_all_qua_consec =
false;
963 co_neu_colors.clear();
964 co_all_neu_consec =
false;
968 BRAIN_CK(co_brn != NULL_PT);
972 brain* get_dbg_brn(){
973 brain* the_brn = NULL;
974 BRAIN_DBG(the_brn = co_brn);
978 solver* get_dbg_slv();
981 bool c1 = (co_quas.is_empty());
982 bool c2 = (co_qua_colors.is_empty());
983 bool c3 = (co_all_qua_consec ==
false);
985 bool c4 = (co_neus.is_empty());
986 bool c5 = (co_neu_colors.is_empty());
987 bool c6 = (co_all_neu_consec ==
false);
989 bool is_vg = (c1 && c2 && c3 && c4 && c5 && c6);
994 void dbg_set_brain_coloring();
996 void save_colors_from(
sort_glb& neus_srg,
sort_glb& quas_srg, tee_id_t consec_kk,
1000 dbg_call_id dbg_id,
neuromap* nmp = NULL_PT,
bool calc_phi_id =
false);
1004 void init_with_trace(
brain& brn, row<prop_signal>& trace,
1005 long first_idx = 0,
long last_idx = -1);
1010 void reset_as_simple_col();
1012 bool dbg_equal_nmp_to(
coloring& col2,
bool skip_all_n4);
1013 bool dbg_equal_co_to(
coloring& col2, row_quanton_t* skip);
1015 void dbg_set_tmp_colors(
bool skip_all_n4);
1016 void dbg_reset_tmp_colors(
bool skip_all_n4);
1017 bool dbg_equal_to_tmp_colors(
bool skip_all_n4);
1020 BRAIN_CK(co_quas.size() == co_qua_colors.size());
1021 BRAIN_CK(co_neus.size() == co_neu_colors.size());
1025 bool dbg_ck_consec_col();
1027 bj_ostream& dbg_print_col_cy_graph(bj_ostream& os,
bool is_ic);
1028 void dbg_print_qua_ids(bj_ostream& os);
1030 bj_ostream& print_coloring(bj_ostream& os,
bool from_pt =
false);
1040 #define DECLARE_NE_FLAG_FUNCS(flag_attr, flag_nam) \ 1041 bool has_##flag_nam(){ \ 1042 bool resp = get_flag(flag_attr, k_##flag_nam##_flag); \ 1046 void reset_its_##flag_nam(brain& brn); \ 1047 void reset_##flag_nam(brain& brn); \ 1048 void set_##flag_nam(brain& brn); \ 1054 #define DEFINE_NE_FLAG_FUNCS(flag_attr, flag_nam) \ 1055 void neuron::reset_its_##flag_nam(brain& brn){ \ 1056 BRAIN_CK(has_##flag_nam()); \ 1057 if(has_##flag_nam()){ \ 1058 reset_##flag_nam(brn); \ 1062 void neuron::reset_##flag_nam(brain& brn){ \ 1063 BRAIN_CK(has_##flag_nam()); \ 1064 reset_flag(flag_attr, k_##flag_nam##_flag); \ 1065 brn.br_ne_tot_##flag_nam--; \ 1068 void neuron::set_##flag_nam(brain& brn){ \ 1069 BRAIN_CK(! has_##flag_nam()); \ 1070 set_flag(flag_attr, k_##flag_nam##_flag); \ 1071 brn.br_ne_tot_##flag_nam++; \ 1078 #define DECLARE_NE_FLAG_ALL_FUNCS(flag_nam) \ 1079 long reset_all_its_##flag_nam(brain& brn, row_neuron_t& rr_all); \ 1080 long reset_all_##flag_nam(brain& brn, row_neuron_t& rr_all); \ 1081 long set_all_##flag_nam(brain& brn, row_neuron_t& rr_all); \ 1082 long append_all_not_##flag_nam(brain& brn, row_neuron_t& rr_src, \ 1083 row_neuron_t& rr_dst); \ 1084 void append_all_have_##flag_nam(brain& brn, row_neuron_t& rr_src, \ 1085 row_neuron_t& rr_dst, bool val_has = true); \ 1086 neuron* same_neurons_##flag_nam(brain& brn, row_neuron_t& sup_ss, \ 1087 row_neuron_t& sub_ss); \ 1088 bool all_neurons_have_##flag_nam(row_neuron_t& rr1, bool val = true); \ 1093 #define DEFINE_NE_FLAG_ALL_FUNCS(flag_nam) \ 1094 long reset_all_its_##flag_nam(brain& brn, row_neuron_t& rr_all){ \ 1096 for(long aa = 0; aa < rr_all.size(); aa++){ \ 1097 BRAIN_CK(rr_all[aa] != NULL_PT); \ 1098 neuron& neu = *(rr_all[aa]); \ 1099 if(neu.has_##flag_nam()){ \ 1100 neu.reset_its_##flag_nam(brn); \ 1107 long reset_all_##flag_nam(brain& brn, row_neuron_t& rr_all){ \ 1108 long num_neu_mod = 0; \ 1109 for(long aa = 0; aa < rr_all.size(); aa++){ \ 1110 BRAIN_CK(rr_all[aa] != NULL_PT); \ 1111 neuron& neu = *(rr_all[aa]); \ 1112 if(neu.has_##flag_nam()){ \ 1113 neu.reset_##flag_nam(brn); \ 1117 return num_neu_mod; \ 1120 long set_all_##flag_nam(brain& brn, row_neuron_t& rr_all){ \ 1121 long num_neu_mod = 0; \ 1122 for(long aa = 0; aa < rr_all.size(); aa++){ \ 1123 neuron& neu = *(rr_all[aa]); \ 1124 if(! neu.has_##flag_nam()){ \ 1125 neu.set_##flag_nam(brn); \ 1129 return num_neu_mod; \ 1132 long append_all_not_##flag_nam(brain& brn, row_neuron_t& rr_src, \ 1133 row_neuron_t& rr_dst) \ 1135 long num_neu_app = 0; \ 1136 for(long aa = 0; aa < rr_src.size(); aa++){ \ 1137 neuron& neu = *(rr_src[aa]); \ 1138 if(! neu.has_##flag_nam()){ \ 1139 neu.set_##flag_nam(brn); \ 1140 rr_dst.push(&neu); \ 1144 return num_neu_app; \ 1147 void append_all_have_##flag_nam(brain& brn, row_neuron_t& rr_src, \ 1148 row_neuron_t& rr_dst, bool val_has) \ 1150 for(long aa = 0; aa < rr_src.size(); aa++){ \ 1151 BRAIN_CK(rr_src[aa] != NULL_PT); \ 1152 neuron& neu = *(rr_src[aa]); \ 1153 if(neu.has_##flag_nam() == val_has){ \ 1154 rr_dst.push(&neu); \ 1159 neuron* same_neurons_##flag_nam(brain& brn, row_neuron_t& sup_ss, \ 1160 row_neuron_t& sub_ss) \ 1162 BRAIN_CK(brn.br_ne_tot_##flag_nam == 0); \ 1163 set_all_##flag_nam(brn, sup_ss); \ 1164 neuron* bad_neu = NULL_PT; \ 1165 for(long aa = 0; aa < sub_ss.size(); aa++){ \ 1166 BRAIN_CK(sub_ss[aa] != NULL_PT); \ 1167 neuron& neu = *(sub_ss[aa]); \ 1168 if(! neu.has_##flag_nam()){ \ 1173 reset_all_##flag_nam(brn, sup_ss); \ 1174 BRAIN_CK(brn.br_ne_tot_##flag_nam == 0); \ 1178 bool all_neurons_have_##flag_nam(row_neuron_t& rr1, bool val) \ 1180 bool all_hv = true; \ 1181 for(long aa = 0; aa < rr1.size(); aa++){ \ 1182 neuron& neu = *(rr1[aa]); \ 1183 if(neu.has_##flag_nam() != val){ \ 1195 #define k_tag0_flag k_flag0 1196 #define k_tag1_flag k_flag1 1197 #define k_tag2_flag k_flag2 1198 #define k_tag3_flag k_flag3 1199 #define k_tag4_flag k_flag4 1200 #define k_tag5_flag k_flag5 1202 DECLARE_NE_FLAG_ALL_FUNCS(tag0);
1203 DECLARE_NE_FLAG_ALL_FUNCS(tag1);
1204 DECLARE_NE_FLAG_ALL_FUNCS(tag2);
1205 DECLARE_NE_FLAG_ALL_FUNCS(tag3);
1206 DECLARE_NE_FLAG_ALL_FUNCS(tag4);
1207 DECLARE_NE_FLAG_ALL_FUNCS(tag5);
1209 typedef receptor<neuron> ne_rece_t;
1217 char* get_cls_name(){
1218 return neuron::CL_NAME;
1229 row_quanton_t ne_fibres;
1231 long ne_fibre_0_idx;
1232 long ne_fibre_1_idx;
1237 bool ne_is_conflict;
1244 ticket ne_candidate_tk;
1247 ticket ne_upd_to_wrt_tk;
1248 ticket ne_to_wrt_tk;
1253 canon_clause ne_dbg_ccl;
1254 long ne_dbg_drw_x_pos;
1255 long ne_dbg_drw_y_pos;
1256 recoil_counter_t ne_dbg_wrt_rc;
1262 ne_index = INVALID_IDX;
1267 DBG(ne_dbg_ccl.cc_in_free =
true);
1271 brain* get_dbg_brn(){
1272 brain* the_brn = NULL;
1273 BRAIN_DBG(the_brn = ne_pt_brn);
1277 solver* get_dbg_slv();
1280 BRAIN_DBG(ne_pt_brn = NULL);
1284 row_quanton_t empty;
1285 BRAIN_CK_0(empty.size() == 0);
1286 quanton* forced_qua = update_fibres(empty,
false);
1287 MARK_USED(forced_qua);
1288 BRAIN_CK_0(forced_qua == NULL);
1291 ne_original =
false;
1294 ne_fibre_0_idx = INVALID_IDX;
1295 ne_fibre_1_idx = INVALID_IDX;
1297 ne_edge = INVALID_IDX;
1298 ne_edge_tk.init_ticket();
1300 ne_is_conflict =
false;
1302 ne_tee.init_sortee(
true);
1303 ne_reltee.init_sortrel(
true);
1305 ne_tee.so_dbg_me_class = 2;
1306 ne_tee.so_me =
this;
1307 ne_tee.so_related = &ne_reltee;
1308 ne_tee.so_ccl.cc_me =
this;
1310 ne_tmp_col = INVALID_COLOR;
1312 ne_candidate_tk.init_ticket();
1314 ne_upd_to_wrt_tk.init_ticket();
1315 ne_to_wrt_tk.init_ticket();
1317 ne_proof_tk.init_ticket();
1320 ne_dbg_ccl.cc_me =
this;
1321 ne_dbg_drw_x_pos = 0;
1322 ne_dbg_drw_y_pos = 0;
1328 bool is_ne_virgin(){
1329 bool c1 = (fib_sz() == 0);
1330 bool c2 = (ne_original ==
false);
1331 bool c3 = (ne_fibre_0_idx == INVALID_IDX);
1332 bool c4 = (ne_fibre_1_idx == INVALID_IDX);
1333 bool c5 = (ne_edge == INVALID_IDX);
1334 bool c6 = (! ne_edge_tk.is_valid());
1335 bool c7 = (ne_is_conflict ==
false);
1337 return (c1 && c2 && c3 && c4 && c5 && c6 && c7);
1340 long fib_sz(){
return ne_fibres.size(); }
1343 BRAIN_CK_0( (ne_fibre_0_idx == INVALID_IDX) ||
1344 ((ne_fibres[0]->qu_tunnels)[ne_fibre_0_idx] ==
this));
1345 BRAIN_CK_0( (ne_fibre_1_idx == INVALID_IDX) ||
1346 ((ne_fibres[1]->qu_tunnels)[ne_fibre_1_idx] ==
this));
1351 BRAIN_CK(ne_fibres[0] != NULL_PT);
1352 return *(ne_fibres[0]);
1356 BRAIN_CK(ne_fibres[1] != NULL_PT);
1357 return *(ne_fibres[1]);
1360 long get_min_ti_idx(
long fb_idx1,
long fb_idx2);
1361 long get_max_lv_idx(
long fb_idx1,
long fb_idx2);
1363 DECLARE_NE_FLAG_FUNCS(ne_flags, tag0);
1364 DECLARE_NE_FLAG_FUNCS(ne_flags, tag1);
1365 DECLARE_NE_FLAG_FUNCS(ne_flags, tag2);
1366 DECLARE_NE_FLAG_FUNCS(ne_flags, tag3);
1367 DECLARE_NE_FLAG_FUNCS(ne_flags, tag4);
1368 DECLARE_NE_FLAG_FUNCS(ne_flags, tag5);
1371 return ne_fibres[0];
1374 void dbg_old_set_motives(
brain& brn, notekeeper& dke,
bool is_first);
1376 void swap_fibres_0_1(){
1377 BRAIN_CK(ck_tunnels());
1379 ne_fibres[0] = ne_fibres[1];
1380 ne_fibres[1] = fb_0;
1382 long fb_0_idx = ne_fibre_0_idx;
1383 ne_fibre_0_idx = ne_fibre_1_idx;
1384 ne_fibre_1_idx = fb_0_idx;
1385 BRAIN_CK(ck_tunnels());
1388 void swap_fibres_1(
long idx,
long& max_lv_idx);
1389 void swap_fibres_0(
long idx,
long& max_lv_idx);
1391 void neu_swap_edge(
brain& brn,
long ii,
long& max_lv_idx);
1395 quanton* update_fibres(row_quanton_t& synps,
bool orig);
1397 bool ck_all_neg(
long from,
bool ck_tunn_ord =
false);
1398 bool ck_all_has_charge(
long max_lv_idx);
1399 bool ck_no_source_of_any();
1402 for(
long ii = 0; ii < fib_sz(); ii++){
1404 BRAIN_CK(qua != NULL_PT);
1412 quanton* dbg_find_first_pos();
1413 bool dbg_ck_min_pos_idx(
long min_ti_pos_idx);
1416 bool is_alrt = (find_is_pos() == NULL_PT);
1421 return ! is_ne_alert();
1424 bool dbg_ne_compute_ck_sat();
1426 void fill_mutual_sortees(
brain& brn);
1428 bool has_qua(
quanton& tg_qua);
1431 row_quanton_t& all_biqus);
1434 return ne_tee.so_vessel;
1438 neuromap& creat_cand,
bool dbg_been);
1440 bool is_ne_dominated(
brain& brn);
1441 void make_ne_dominated(
brain& brn);
1442 bool is_ne_source();
1444 void set_cand_tk(ticket& n_tk);
1446 bool ck_wrt_qu0(
bool just_upd);
1448 void update_ne_to_wrt_tk(
brain& brn, ticket& wrt_tk);
1450 bool is_ne_to_wrt();
1452 void dbg_get_charges(row_long_t& chgs);
1454 bj_ostream& dbg_ne_print_col_cy_node(bj_ostream& os);
1455 bj_ostream& dbg_ne_print_col_cy_edge(bj_ostream& os,
long& consec);
1457 bj_ostream& print_tees(bj_ostream& os);
1458 bj_ostream& print_neu_base(bj_ostream& os,
bool from_pt,
bool from_tee,
1461 bj_ostream& print_neuron(bj_ostream& os,
bool from_pt =
false);
1473 #define DECLARE_PS_FLAG_ALL_FUNCS(flag_num) \ 1474 void reset_ps_all_note##flag_num##_n_tag##flag_num(brain& brn, \ 1475 row<prop_signal>& rr_all, bool do_note, bool do_tag); \ 1476 void set_ps_all_note##flag_num##_n_tag##flag_num(brain& brn, \ 1477 row<prop_signal>& rr_all, bool do_note, bool do_tag); \ 1482 #define DEFINE_PS_FLAG_ALL_FUNCS(flag_num) \ 1483 void reset_ps_all_note##flag_num##_n_tag##flag_num(brain& brn, \ 1484 row<prop_signal>& rr_all, bool do_note, bool do_tag) \ 1486 for(long ii = 0; ii < rr_all.size(); ii++){ \ 1487 prop_signal& q_sig = rr_all[ii]; \ 1488 quanton* qua = q_sig.ps_quanton; \ 1489 neuron* neu = q_sig.ps_source; \ 1490 if(do_note && (qua != NULL_PT) && qua->has_note##flag_num()){ \ 1491 qua->reset_note##flag_num(brn); \ 1493 if(do_tag && (neu != NULL_PT) && neu->has_tag##flag_num()){ \ 1494 neu->reset_tag##flag_num(brn); \ 1499 void set_ps_all_note##flag_num##_n_tag##flag_num(brain& brn, \ 1500 row<prop_signal>& rr_all, bool do_note, bool do_tag) \ 1502 for(long ii = 0; ii < rr_all.size(); ii++){ \ 1503 prop_signal& q_sig = rr_all[ii]; \ 1504 quanton* qua = q_sig.ps_quanton; \ 1505 neuron* neu = q_sig.ps_source; \ 1506 if(do_note && (qua != NULL_PT) && ! qua->has_note##flag_num()){ \ 1507 qua->set_note##flag_num(brn); \ 1509 if(do_tag && (neu != NULL_PT) && ! neu->has_tag##flag_num()){ \ 1510 neu->set_tag##flag_num(brn); \ 1518 DECLARE_PS_FLAG_ALL_FUNCS(0);
1519 DECLARE_PS_FLAG_ALL_FUNCS(1);
1520 DECLARE_PS_FLAG_ALL_FUNCS(2);
1521 DECLARE_PS_FLAG_ALL_FUNCS(3);
1522 DECLARE_PS_FLAG_ALL_FUNCS(4);
1523 DECLARE_PS_FLAG_ALL_FUNCS(5);
1536 void init_prop_signal(
quanton* qua = NULL_PT,
neuron* the_src = NULL_PT,
1537 long the_tier = INVALID_TIER)
1540 ps_source = the_src;
1544 void init_qua_signal(
quanton& qua){
1545 init_prop_signal(&qua, qua.qu_source, qua.qu_tier);
1552 bool is_ps_virgin(){
1553 bool c1 = (ps_quanton == NULL_PT);
1554 bool c2 = (ps_source == NULL_PT);
1555 bool c3 = (ps_tier == INVALID_TIER);
1557 return (c1 && c2 && c3);
1560 bool is_ps_uniron(){
1561 if(ps_quanton == NULL_PT){
1564 bool is_u = ps_quanton->is_qu_uniron();
1565 BRAIN_CK(! is_u || (ps_source == NULL_PT));
1569 long get_level()
const {
1570 long lv = INVALID_LEVEL;
1571 if(ps_quanton != NULL_PT){
1572 lv = ps_quanton->qlevel();
1577 void get_ps_cand_to_wrt(
brain& brn, row_neuromap_t& to_wrt,
long trace_idx);
1581 brain* get_dbg_brn(){
1582 brain* the_brn = NULL;
1583 BRAIN_DBG(
if(ps_quanton != NULL){ the_brn = ps_quanton->get_dbg_brn(); });
1588 bool c1 = (ps_quanton == ps2.ps_quanton);
1589 bool c2 = (ps_source == ps2.ps_source);
1590 bool c3 = (ps_tier == ps2.ps_tier);
1592 bool eq = (c1 && c2 && c3);
1596 solver* get_dbg_slv();
1598 bj_ostream& print_prop_signal(bj_ostream& os,
bool from_pt =
false);
1603 append_all_trace_quas(row<prop_signal>& trace, row_quanton_t& all_quas,
1604 long first_idx = 0,
long last_idx = -1)
1606 if(last_idx < 0){ last_idx = trace.size(); }
1608 BRAIN_CK(first_idx <= last_idx);
1609 BRAIN_CK((first_idx == trace.size()) || trace.is_valid_idx(first_idx));
1610 BRAIN_CK((last_idx == trace.size()) || trace.is_valid_idx(last_idx));
1612 for(
long ii = first_idx; ii < last_idx; ii++){
1614 BRAIN_CK(q_sig.ps_quanton != NULL_PT);
1615 all_quas.push(q_sig.ps_quanton);
1621 append_all_trace_neus(row<prop_signal>& trace, row_neuron_t& all_neus)
1623 for(
long ii = 0; ii < trace.size(); ii++){
1625 if((q_sig.ps_source != NULL_PT) && (q_sig.ps_source->ne_original)){
1626 all_neus.push(q_sig.ps_source);
1638 row_quanton_t rs_motives;
1640 long rs_target_level;
1651 rs_tk.init_ticket();
1653 rs_forced = NULL_PT;
1654 rs_target_level = INVALID_LEVEL;
1657 brain* get_dbg_brn(){
1658 brain* the_brn = NULL;
1659 BRAIN_DBG(
if(rs_forced != NULL){ the_brn = rs_forced->get_dbg_brn(); });
1663 solver* get_dbg_slv();
1665 bool is_rs_virgin(){
1666 bool c1 = (rs_motives.is_empty());
1667 bool c2 = (rs_forced == NULL_PT);
1668 bool c3 = (rs_target_level == INVALID_LEVEL);
1670 bool is_vg = (c1 && c2 && c3);
1675 void copy_to_rsn(reason& rsn2){
1676 BRAIN_CK(rsn2.is_rs_virgin());
1677 rs_motives.copy_to(rsn2.rs_motives);
1679 rsn2.rs_forced = rs_forced;
1680 rsn2.rs_target_level = rs_target_level;
1683 bool equal_to_rsn(reason& rsn2);
1685 void dbg_set_with(
brain& brn, notekeeper& dke,
quanton& nxt_qua);
1687 bool is_dt_singleton(){
1688 return rs_motives.is_empty();
1691 bool is_root_confl();
1693 long calc_target_tier(
brain& brn);
1695 bj_ostream& print_reason(bj_ostream& os,
bool from_pt =
false){
1697 os <<
"dt={ mots=" << rs_motives;
1698 os <<
" qu:" << rs_forced;
1699 os <<
" lv:" << rs_target_level;
1722 row_quanton_t dt_first_causes;
1723 row<prop_signal> dt_all_noted;
1728 row_neuromap_t dt_all_to_wrt;
1736 void init_deduction(
brain* the_brn = NULL_PT){
1740 dt_last_found = NULL_PT;
1742 dt_first_causes.clear();
1743 dt_all_noted.clear(
true,
true);
1744 dt_rsn.init_reason();
1746 dt_found_top =
false;
1748 dt_all_to_wrt.clear();
1751 void reset_deduction(){
1752 init_deduction(dt_brn);
1757 void update_all_to_wrt_for_proof();
1759 brain* get_dbg_brn(){
1763 solver* get_dbg_slv();
1766 BRAIN_CK(dt_brn != NULL);
1771 bool c1 = (dt_confl == NULL_PT);
1772 bool c2 = (dt_last_found == NULL_PT);
1776 bool is_dt_virgin(){
1777 bool c1 = (dt_confl == NULL_PT);
1778 bool c2 = (dt_last_found == NULL_PT);
1780 bool c3 = (dt_first_causes.is_empty());
1781 bool c4 = (dt_all_noted.is_empty());
1782 bool c5 = (dt_rsn.is_rs_virgin());
1784 bool c6 = (dt_all_to_wrt.is_empty());
1786 return (c1 && c2 && c3 && c4 && c5 && c6);
1789 bj_ostream& print_deduction(bj_ostream& os,
bool from_pt =
false){
1812 void init_cov_entry(
neuromap* nmp = NULL_PT,
neuron* neu = NULL_PT){
1817 brain* get_dbg_brn(){
1821 solver* get_dbg_slv(){
1825 bool is_ce_virgin(){
1826 bool c1 = (ce_nmp == NULL_PT);
1827 bool c2 = (ce_neu == NULL_PT);
1832 bj_ostream& print_cov_entry(bj_ostream& os,
bool from_pt =
false);
1842 row_row_quanton_t ql_quas_by_layer;
1845 qulayers(
brain* the_brn = NULL_PT)
1847 init_qulayers(the_brn);
1854 void init_qulayers(
brain* the_brn = NULL_PT){
1856 ql_quas_by_layer.clear(
true,
true);
1857 ql_pop_layer = INVALID_IDX;
1860 brain& get_ql_brain();
1862 brain* get_dbg_brn(){
1863 brain* the_brn = NULL;
1864 BRAIN_DBG(the_brn = ql_brain);
1868 solver* get_dbg_slv();
1871 row_row_quanton_t& mots_by_ly = ql_quas_by_layer;
1872 BRAIN_CK(ck_pop_layer());
1873 if(! mots_by_ly.is_valid_idx(ql_pop_layer)){
1876 row_quanton_t& mots = mots_by_ly[ql_pop_layer];
1877 if(mots.is_empty()){
1881 if(mots.is_empty()){
1887 void update_pop_layer(
bool with_restart =
false){
1888 ql_pop_layer = get_nxt_busy_layer(ql_pop_layer, with_restart);
1891 quanton* last_qua_in_layer(
long lyr){
1892 row_row_quanton_t& mots_by_ly = ql_quas_by_layer;
1893 if(! mots_by_ly.is_valid_idx(lyr)){
1896 row_quanton_t& mots = mots_by_ly[lyr];
1897 if(mots.is_empty()){
1905 BRAIN_CK(ck_pop_layer());
1906 quanton* qua = last_qua_in_layer(ql_pop_layer);
1910 bool ck_pop_layer(){
1911 row_row_quanton_t& mots_by_ly = ql_quas_by_layer;
1912 if(mots_by_ly.is_empty()){
1913 BRAIN_CK(ql_pop_layer == INVALID_IDX);
1916 long p_ly = mots_by_ly.last_idx();
1917 while(mots_by_ly.is_valid_idx(p_ly) && (p_ly > ql_pop_layer)){
1918 BRAIN_CK(mots_by_ly[p_ly].is_empty());
1921 BRAIN_CK(p_ly == ql_pop_layer);
1922 if(mots_by_ly.is_valid_idx(ql_pop_layer)){
1923 BRAIN_CK(! mots_by_ly[ql_pop_layer].is_empty());
1930 BRAIN_CK(ck_pop_layer());
1931 if(ql_pop_layer == INVALID_IDX){
1938 quanton* qua = last_quanton();
1942 return qua->qlevel();
1946 quanton* qua = last_quanton();
1950 long qti = qua->qu_tier;
1955 void add_motive(
quanton& qua,
long q_layer){
1956 row_quanton_t& layer_mots = get_qu_layer(q_layer);
1957 layer_mots.push(&qua);
1958 if(q_layer > ql_pop_layer){
1959 ql_pop_layer = q_layer;
1963 long get_nxt_busy_layer(
long lyr,
bool with_restart =
false){
1964 row_row_quanton_t& mots_by_ly = ql_quas_by_layer;
1965 if(mots_by_ly.is_empty()){
1970 nxt_lyr = mots_by_ly.last_idx();
1972 while(mots_by_ly.is_valid_idx(nxt_lyr) && mots_by_ly[nxt_lyr].is_empty()){
1975 BRAIN_CK((nxt_lyr == INVALID_IDX) || mots_by_ly.is_valid_idx(nxt_lyr));
1979 void get_all_ordered_quantons(row_quanton_t& mots){
1981 for(
long aa = 0; aa < ql_quas_by_layer.size(); aa++){
1982 row_quanton_t& lv_mots = ql_quas_by_layer[aa];
1983 lv_mots.append_to(mots);
1987 long get_tot_quantons(){
1989 for(
long aa = 0; aa < ql_quas_by_layer.size(); aa++){
1990 row_quanton_t& lv_mots = ql_quas_by_layer[aa];
1991 nmm += lv_mots.size();
1996 long get_all_sz(row_long_t& all_sz,
long fst_ly){
1999 for(
long aa = fst_ly; aa < ql_quas_by_layer.size(); aa++){
2000 row_quanton_t& lv_mots = ql_quas_by_layer[aa];
2001 long mot_sz = lv_mots.size();
2003 all_sz.push(mot_sz);
2010 return (get_tot_quantons() == 0);
2013 row_quanton_t& get_qu_layer(
long q_layer);
2015 bool ck_empty_layers(
long q_layer){
2016 BRAIN_CK(q_layer >= 0);
2017 BRAIN_CK(! ql_quas_by_layer.is_empty());
2019 long l_idx = ql_quas_by_layer.last_idx();
2020 BRAIN_CK(q_layer <= l_idx);
2021 for(
long ii = l_idx; ii > q_layer; ii--){
2022 BRAIN_CK(get_qu_layer(ii).is_empty());
2027 void dbg_ql_init_all_cy_pos();
2029 bj_ostream& print_qulayers(bj_ostream& os,
bool from_pt =
false);
2042 #define DECLARE_NA_FLAG_FUNCS(flag_attr, flag_nam) \ 2043 bool has_##flag_nam(){ \ 2044 bool resp = get_flag(flag_attr, k_##flag_nam##_flag); \ 2048 void reset_its_##flag_nam(brain& brn); \ 2049 void reset_##flag_nam(brain& brn); \ 2050 void set_##flag_nam(brain& brn); \ 2056 #define DEFINE_NA_FLAG_FUNCS(flag_attr, flag_nam) \ 2057 void neuromap::reset_its_##flag_nam(brain& brn){ \ 2058 BRAIN_CK(has_##flag_nam()); \ 2059 if(has_##flag_nam()){ \ 2060 reset_##flag_nam(brn); \ 2064 void neuromap::reset_##flag_nam(brain& brn){ \ 2065 BRAIN_CK(has_##flag_nam()); \ 2066 reset_flag(flag_attr, k_##flag_nam##_flag); \ 2067 brn.br_na_tot_##flag_nam--; \ 2070 void neuromap::set_##flag_nam(brain& brn){ \ 2071 BRAIN_CK(! has_##flag_nam()); \ 2072 set_flag(flag_attr, k_##flag_nam##_flag); \ 2073 brn.br_na_tot_##flag_nam++; \ 2080 #define DECLARE_NA_FLAG_ALL_FUNCS(flag_nam) \ 2081 long reset_all_its_##flag_nam(brain& brn, row_neuromap_t& rr_all); \ 2082 long reset_all_##flag_nam(brain& brn, row_neuromap_t& rr_all); \ 2083 long set_all_##flag_nam(brain& brn, row_neuromap_t& rr_all); \ 2084 long append_all_not_##flag_nam(brain& brn, row_neuromap_t& rr_src, \ 2085 row_neuromap_t& rr_dst); \ 2086 bool same_neuromaps_##flag_nam(brain& brn, row_neuromap_t& sup_ss, \ 2087 row_neuromap_t& sub_ss); \ 2088 bool all_neuromaps_have_##flag_nam(row_neuromap_t& rr1, bool val = true); \ 2093 #define DEFINE_NA_FLAG_ALL_FUNCS(flag_nam) \ 2094 long reset_all_its_##flag_nam(brain& brn, row_neuromap_t& rr_all){ \ 2096 for(long aa = 0; aa < rr_all.size(); aa++){ \ 2097 BRAIN_CK(rr_all[aa] != NULL_PT); \ 2098 neuromap& nmp = *(rr_all[aa]); \ 2099 if(nmp.has_##flag_nam()){ \ 2100 nmp.reset_its_##flag_nam(brn); \ 2107 long reset_all_##flag_nam(brain& brn, row_neuromap_t& rr_all){ \ 2108 long num_nmp_mod = 0; \ 2109 for(long aa = 0; aa < rr_all.size(); aa++){ \ 2110 BRAIN_CK(rr_all[aa] != NULL_PT); \ 2111 neuromap& nmp = *(rr_all[aa]); \ 2112 if(nmp.has_##flag_nam()){ \ 2113 nmp.reset_##flag_nam(brn); \ 2117 return num_nmp_mod; \ 2120 long set_all_##flag_nam(brain& brn, row_neuromap_t& rr_all){ \ 2121 long num_nmp_mod = 0; \ 2122 for(long aa = 0; aa < rr_all.size(); aa++){ \ 2123 neuromap& nmp = *(rr_all[aa]); \ 2124 if(! nmp.has_##flag_nam()){ \ 2125 nmp.set_##flag_nam(brn); \ 2129 return num_nmp_mod; \ 2132 long append_all_not_##flag_nam(brain& brn, row_neuromap_t& rr_src, \ 2133 row_neuromap_t& rr_dst) \ 2135 long num_nmp_app = 0; \ 2136 for(long aa = 0; aa < rr_src.size(); aa++){ \ 2137 neuromap& nmp = *(rr_src[aa]); \ 2138 if(! nmp.has_##flag_nam()){ \ 2139 nmp.set_##flag_nam(brn); \ 2140 rr_dst.push(&nmp); \ 2144 return num_nmp_app; \ 2147 bool same_neuromaps_##flag_nam(brain& brn, row_neuromap_t& sup_ss, \ 2148 row_neuromap_t& sub_ss) \ 2150 BRAIN_CK(brn.br_na_tot_##flag_nam == 0); \ 2151 set_all_##flag_nam(brn, sup_ss); \ 2152 bool sm_nmps = true; \ 2153 for(long aa = 0; aa < sub_ss.size(); aa++){ \ 2154 neuromap& nmp = *(sub_ss[aa]); \ 2155 if(! nmp.has_##flag_nam()){ \ 2159 reset_all_##flag_nam(brn, sup_ss); \ 2160 BRAIN_CK(brn.br_na_tot_##flag_nam == 0); \ 2164 bool all_neuromaps_have_##flag_nam(row_neuromap_t& rr1, bool val) \ 2166 bool all_hv = true; \ 2167 for(long aa = 0; aa < rr1.size(); aa++){ \ 2168 neuromap& nmp = *(rr1[aa]); \ 2169 if(nmp.has_##flag_nam() != val){ \ 2181 #define k_na0_flag k_flag0 2182 #define k_na1_flag k_flag1 2183 #define k_na2_flag k_flag2 2184 #define k_na3_flag k_flag3 2185 #define k_na4_flag k_flag4 2186 #define k_na5_flag k_flag5 2188 DECLARE_NA_FLAG_ALL_FUNCS(na0);
2189 DECLARE_NA_FLAG_ALL_FUNCS(na1);
2197 char* get_cls_name(){
2198 return neuromap::CL_NAME;
2206 bool na_is_min_simple;
2208 round_counter_t na_orig_rnd;
2213 cy_quk_t na_orig_cy_ki;
2219 row<prop_signal> na_propag;
2220 row<cov_entry> na_all_centry;
2221 row_neuron_t na_all_cov;
2223 bool na_upd_to_write;
2224 row_neuron_t na_to_write;
2225 row_neuron_t na_not_to_write;
2230 long na_guide_tot_vars;
2234 mem_find_t na_found_in_skl;
2237 ticket na_candidate_tk;
2241 long na_to_wrt_trace_idx;
2242 ch_string na_tauto_pth;
2243 bool na_tauto_oper_ok;
2247 ticket na_dbg_candidate_tk;
2248 bool na_dbg_cand_sys;
2249 bool na_dbg_creating;
2251 mem_op_t na_dbg_nmp_mem_op;
2252 ch_string na_dbg_tauto_min_sha_str;
2253 ch_string na_dbg_tauto_sha_str;
2254 ch_string na_dbg_guide_sha_str;
2255 ch_string na_dbg_quick_sha_str;
2256 ch_string na_dbg_diff_min_sha_str;
2258 ch_string na_dbg_is_no_abort_full_wrt_pth;
2259 bool na_dbg_is_no_abort_full_nmp;
2262 row_long_t na_dbg_phi_id;
2268 na_index = INVALID_IDX;
2269 init_neuromap(pt_brn);
2276 void init_neuromap(
brain* pt_brn = NULL){
2280 na_is_min_simple =
false;
2282 na_orig_rnd = INVALID_ROUND;
2284 na_orig_lv = INVALID_LEVEL;
2285 na_orig_ti = INVALID_TIER;
2286 na_orig_cho = NULL_PT;
2287 na_orig_cy_ki = cq_invalid;
2289 na_nxt_no_mono =
this;
2290 na_submap = NULL_PT;
2292 na_num_submap = INVALID_NUM_SUB;
2294 na_propag.clear(
true,
true);
2295 na_all_centry.clear(
true,
true);
2298 na_upd_to_write =
false;
2299 na_to_write.clear();
2300 na_not_to_write.clear();
2303 na_found_col.init_coloring();
2305 na_guide_tot_vars = 0;
2306 na_guide_col.init_coloring();
2307 na_pend_col.init_coloring();
2309 na_found_in_skl = mf_invalid;
2311 na_candidate_tk.init_ticket();
2312 na_candidate_qua = NULL_PT;
2314 na_to_wrt_trace_idx = INVALID_IDX;
2315 na_tauto_pth = INVALID_PATH;
2316 na_tauto_oper_ok =
false;
2317 na_tauto_col.init_coloring();
2320 na_dbg_candidate_tk.init_ticket();
2321 na_dbg_cand_sys =
false;
2322 na_dbg_creating =
false;
2324 na_dbg_nmp_mem_op = mo_invalid;
2325 na_dbg_tauto_min_sha_str = INVALID_MINSHA;
2326 na_dbg_tauto_sha_str = INVALID_SHA;
2327 na_dbg_guide_sha_str = INVALID_SHA;
2328 na_dbg_quick_sha_str = INVALID_SHA;
2330 na_dbg_is_no_abort_full_wrt_pth = INVALID_PATH;
2331 na_dbg_is_no_abort_full_nmp =
false;
2333 na_dbg_tauto_col.init_coloring();
2334 na_dbg_phi_id.clear();
2336 na_dbg_real_cand = NULL_PT;
2340 bool is_na_virgin(){
2341 bool c1 = (na_brn == NULL_PT);
2342 bool c2 = (na_is_head ==
false);
2343 bool c3 = (na_orig_lv == INVALID_LEVEL);
2344 bool c4 = (na_orig_cho == NULL_PT);
2345 bool c5 = (na_submap == NULL_PT);
2347 return (c1 && c2 && c3 && c4 && c5);
2350 void full_release();
2351 void release_candidate();
2354 BRAIN_CK(na_brn != NULL);
2358 brain* get_dbg_brn(){
2359 brain* the_brn = NULL;
2360 BRAIN_DBG(the_brn = na_brn);
2364 solver* get_dbg_slv();
2366 DECLARE_NA_FLAG_FUNCS(na_flags, na0);
2367 DECLARE_NA_FLAG_FUNCS(na_flags, na1);
2368 DECLARE_NA_FLAG_FUNCS(na_flags, na2);
2369 DECLARE_NA_FLAG_FUNCS(na_flags, na3);
2370 DECLARE_NA_FLAG_FUNCS(na_flags, na4);
2371 DECLARE_NA_FLAG_FUNCS(na_flags, na5);
2374 BRAIN_CK(na_nxt_no_mono != NULL_PT);
2375 bool is_mn = (na_nxt_no_mono !=
this);
2381 bool has_stab_guide();
2384 return na_candidate_tk.tk_level;
2387 void map_get_all_propag_ps(row<prop_signal>& all_ps);
2388 void map_rec_get_all_propag_ps(row<prop_signal>& all_ps);
2389 bool map_dbg_ck_ord(row<prop_signal>& all_ps);
2391 void map_get_all_cov_neus(row_neuron_t& all_neus,
bool with_clear,
bool skip_tail,
2394 void map_get_all_quas(row_quanton_t& all_quas);
2395 void map_get_all_neus(row_neuron_t& all_neus,
bool only_found =
false,
2396 mem_op_t mm = mo_invalid);
2398 bool map_ck_all_upper_quas(row_quanton_t& all_upper_quas);
2399 void map_get_all_upper_quas(row_quanton_t& all_upper_quas);
2401 quanton* map_choose_propag_qua();
2402 quanton* map_choose_quanton();
2404 bool map_ck_all_quas();
2405 bool dbg_ck_all_neus();
2408 bool h_s = (na_submap != NULL_PT);
2412 ch_string map_dbg_oper_str(mem_op_t mm){
2413 if(mm == mo_find){
return "FIND"; }
2414 BRAIN_CK(mm == mo_save);
2418 bool map_ck_contained_in(
coloring& colr, dbg_call_id dbg_id);
2419 void map_dbg_print(bj_ostream& os, mem_op_t mm);
2421 ch_string map_dbg_get_phi_ids_str();
2424 bool map_write(
bool force_full =
false);
2428 bool map_oper(mem_op_t mm);
2429 bool map_prepare_mem_oper(mem_op_t mm);
2430 void map_prepare_wrt_cnfs(mem_op_t mm, ch_string quick_find_ref, row_str_t& dbg_shas);
2431 void map_set_stab_guide();
2432 void map_stab_guide_col();
2433 void map_init_stab_guide();
2437 void map_get_initial_guide_coloring(
coloring& clr);
2438 void map_get_initial_tauto_coloring(
coloring& prv_clr,
coloring& tauto_clr,
2441 void map_get_simple_coloring(
coloring& clr, mem_op_t mm = mo_invalid);
2442 void map_get_simple_guide_col(
coloring& clr);
2444 bool nmp_is_min_simple();
2445 void nmp_set_min_simple();
2448 bool nmp_is_cand(
bool ck_chg =
true, dbg_call_id dbg_id = dbg_call_1);
2449 void nmp_fill_upper_covs();
2450 void nmp_fill_all_upper_covs(
long dbg_idx = 0);
2452 void nmp_set_quas_cand_tk();
2453 void nmp_set_neus_cand_tk();
2454 void nmp_set_all_cand_tk();
2456 void nmp_set_all_num_sub();
2458 void nmp_update_to_write(row_neuron_t& upd_from, ticket& nmp_wrt_tk);
2459 void nmp_update_all_to_write(ticket& nmp_wrt_tk);
2460 void nmp_reset_write();
2462 void nmp_add_to_write(row_neuromap_t& to_wrt,
long trace_idx = INVALID_IDX);
2464 bool dbg_has_simple_coloring_quas(
coloring& clr);
2465 void dbg_prt_simple_coloring(bj_ostream& os);
2467 void map_dbg_set_cy_maps();
2468 void map_dbg_reset_cy_maps();
2469 void map_dbg_get_cy_coloring(
coloring& clr);
2470 ch_string map_dbg_html_data_str(ch_string msg);
2471 void map_dbg_update_html_file(ch_string msg);
2472 void map_dbg_all_sub_update_html_file(ch_string msg);
2474 bool dbg_ck_cand(
bool nw_cands);
2475 ch_string dbg_na_id();
2476 bool dbg_is_watched();
2477 long dbg_get_depth_in(
neuromap& hd_nmp);
2479 bj_ostream& print_cand_id(bj_ostream& os);
2480 bj_ostream& print_nmp_hd(bj_ostream& os);
2482 bj_ostream& print_neuromap(bj_ostream& os,
bool from_pt =
false);
2484 bj_ostream& print_all_subnmp(bj_ostream& os,
bool only_pts =
false);
2485 bj_ostream& print_subnmp(bj_ostream& os,
bool only_pts =
false);
2490 as_neuromap(binder* bdr){
2491 BRAIN_CK(bdr != NULL_PT);
2492 neuromap& nmp = rcp_as<neuromap>(bdr);
2501 typedef bool (
quanton::*has_fn_pt_t)();
2503 typedef long (*do_row_fn_pt_t)(
brain& brn, row_quanton_t& quans);
2504 typedef long (*do_append_fn_pt_t)(
brain& brn, row_quanton_t& src,
2505 row_quanton_t& dst);
2506 typedef bool (*do_same_fn_pt_t)(
brain& brn, row_quanton_t& rr1,
2507 row_quanton_t& rr2, row_quanton_t* all_bad_qua);
2511 long* dk_note_counter;
2512 has_fn_pt_t dk_has_note_fn;
2513 do_fn_pt_t dk_set_note_fn;
2514 do_fn_pt_t dk_reset_note_fn;
2515 do_row_fn_pt_t dk_set_all_fn;
2516 do_row_fn_pt_t dk_reset_all_fn;
2517 do_append_fn_pt_t dk_append_not_noted_fn;
2518 do_same_fn_pt_t dk_same_quas_noted_fn;
2522 long dk_num_noted_in_layer;
2524 qulayers dk_quas_lyrs;
2526 notekeeper(
brain* brn = NULL_PT,
long tg_lv = INVALID_LEVEL)
2528 init_notekeeper(brn, tg_lv);
2535 void init_notekeeper(
brain* brn = NULL_PT,
long tg_lv = INVALID_LEVEL)
2539 dk_note_counter = NULL_PT;
2540 dk_has_note_fn = NULL_PT;
2541 dk_set_note_fn = NULL_PT;
2542 dk_reset_note_fn = NULL_PT;
2543 dk_set_all_fn = NULL_PT;
2544 dk_reset_all_fn = NULL_PT;
2545 dk_append_not_noted_fn = NULL_PT;
2546 dk_same_quas_noted_fn = NULL_PT;
2551 long nk_get_counter(){
2552 BRAIN_CK(dk_note_counter != NULL_PT);
2553 return *dk_note_counter;
2556 bool nk_has_note(
quanton& qua){
2557 BRAIN_CK(dk_has_note_fn != NULL_PT);
2558 return (qua.*dk_has_note_fn)();
2561 void nk_set_note(
quanton& qua){
2562 BRAIN_CK(dk_set_note_fn != NULL_PT);
2563 brain& brn = get_dk_brain();
2564 (qua.*dk_set_note_fn)(brn);
2567 void nk_reset_note(
quanton& qua){
2568 BRAIN_CK(dk_reset_note_fn != NULL_PT);
2569 brain& brn = get_dk_brain();
2570 (qua.*dk_reset_note_fn)(brn);
2573 long nk_set_all_notes(row_quanton_t& quans){
2574 BRAIN_CK(dk_set_all_fn != NULL_PT);
2575 brain& brn = get_dk_brain();
2576 return (*dk_set_all_fn)(brn, quans);
2579 long nk_reset_all_notes(row_quanton_t& quans){
2580 BRAIN_CK(dk_reset_all_fn != NULL_PT);
2581 brain& brn = get_dk_brain();
2582 return (*dk_reset_all_fn)(brn, quans);
2585 long nk_append_not_noted(row_quanton_t& src, row_quanton_t& dst){
2586 BRAIN_CK(dk_append_not_noted_fn != NULL_PT);
2587 brain& brn = get_dk_brain();
2588 return (*dk_append_not_noted_fn)(brn, src, dst);
2591 bool nk_same_quas_noted(row_quanton_t& rr1, row_quanton_t& rr2){
2592 BRAIN_CK(dk_same_quas_noted_fn != NULL_PT);
2593 brain& brn = get_dk_brain();
2594 return (*dk_same_quas_noted_fn)(brn, rr1, rr2, NULL_PT);
2597 brain* get_dbg_brn(){
2598 brain* the_brn = NULL;
2599 BRAIN_DBG(the_brn = dk_brain);
2603 solver* get_dbg_slv();
2605 void init_funcs(
long* cnter, has_fn_pt_t has_note, do_fn_pt_t set_note,
2606 do_fn_pt_t reset_note, do_row_fn_pt_t set_all,
2607 do_row_fn_pt_t reset_all_its, do_append_fn_pt_t append_not_noted,
2608 do_same_fn_pt_t same_quas_noted)
2610 dk_note_counter = cnter;
2611 dk_has_note_fn = has_note;
2612 dk_set_note_fn = set_note;
2613 dk_reset_note_fn = reset_note;
2614 dk_set_all_fn = set_all;
2615 dk_reset_all_fn = reset_all_its;
2616 dk_append_not_noted_fn = append_not_noted;
2617 dk_same_quas_noted_fn = same_quas_noted;
2620 void init_notes(
long tg_lv){
2621 dk_note_layer = tg_lv;
2623 dk_num_noted_in_layer = 0;
2625 dk_quas_lyrs.init_qulayers(dk_brain);
2629 bool c0 = (dk_note_counter != NULL_PT);
2630 bool c1 = (dk_has_note_fn != NULL_PT);
2631 bool c2 = (dk_set_note_fn != NULL_PT);
2632 bool c3 = (dk_reset_note_fn != NULL_PT);
2633 bool c4 = (dk_set_all_fn != NULL_PT);
2634 bool c5 = (dk_reset_all_fn != NULL_PT);
2635 return (c0 && c1 && c2 && c3 && c4 && c5);
2638 brain& get_dk_brain();
2640 long clear_all_quantons(
long lim_lv = INVALID_LEVEL,
bool reset_notes =
true);
2642 bool ck_notes(row_quanton_t& mots,
bool val){
2644 BRAIN_CK(ck_funcs());
2645 for(
long ii = 0; ii < mots.size(); ii++){
2649 BRAIN_CK(qua != NULL_PT);
2651 bool c1 = (qua->*dk_has_note_fn)();
2653 BRAIN_CK(c1 == val);
2659 BRAIN_CK(dk_tot_noted > 0);
2660 BRAIN_CK(dk_num_noted_in_layer > 0);
2663 BRAIN_CK(dk_tot_noted >= 0);
2665 dk_num_noted_in_layer--;
2666 if(dk_num_noted_in_layer == 0){
2667 row_quanton_t& mots = dk_quas_lyrs.get_qu_layer(dk_note_layer);
2668 BRAIN_CK(ck_notes(mots,
false));
2672 BRAIN_CK(dk_num_noted_in_layer >= 0);
2675 void update_notes_layer(
long q_layer){
2676 BRAIN_CK(q_layer >= 0);
2677 BRAIN_CK(q_layer <= dk_note_layer);
2678 if(q_layer < dk_note_layer){
2679 row_quanton_t& nxt_mots = dk_quas_lyrs.get_qu_layer(q_layer);
2681 BRAIN_CK(dk_num_noted_in_layer == 0);
2682 BRAIN_CK(q_layer < dk_note_layer);
2683 BRAIN_CK(dk_quas_lyrs.ck_empty_layers(q_layer));
2684 BRAIN_CK(ck_notes(nxt_mots,
true));
2686 dk_note_layer = q_layer;
2687 dk_num_noted_in_layer = nxt_mots.size();
2689 BRAIN_CK(q_layer == dk_note_layer);
2692 void set_motive_notes(row_quanton_t& rr_qua,
long from,
long until);
2701 qulayers* nr_quas_lyrs;
2702 long nr_curr_qua_layer;
2703 long nr_curr_qua_idx;
2705 qlayers_ref(qulayers* the_kpr = NULL_PT){
2706 init_qlayers_ref(the_kpr);
2713 void init_qlayers_ref(qulayers* the_kpr = NULL_PT){
2714 nr_quas_lyrs = the_kpr;
2715 nr_curr_qua_layer = INVALID_IDX;
2716 nr_curr_qua_idx = INVALID_IDX;
2719 bool is_nr_virgin(){
2720 bool c1 = (nr_quas_lyrs == NULL_PT);
2721 bool c2 = (nr_curr_qua_layer == INVALID_IDX);
2722 bool c3 = (nr_curr_qua_idx == INVALID_IDX);
2724 return (c1 && c2 && c3);
2727 qulayers& get_keeper(){
2728 BRAIN_CK(nr_quas_lyrs != NULL_PT);
2729 return *nr_quas_lyrs;
2732 void update_curr_quanton(
bool reset){
2733 if(nr_quas_lyrs == NULL_PT){
2736 BRAIN_CK(nr_quas_lyrs != NULL_PT);
2737 nr_curr_qua_layer = nr_quas_lyrs->get_nxt_busy_layer(nr_curr_qua_layer, reset);
2738 nr_curr_qua_idx = INVALID_IDX;
2740 if(nr_curr_qua_layer != INVALID_IDX){
2741 nr_curr_qua_idx = nr_quas_lyrs->ql_quas_by_layer[nr_curr_qua_layer].last_idx();
2745 void reset_curr_quanton(
long nxt_lyr = INVALID_IDX){
2746 if(nr_quas_lyrs == NULL_PT){
2749 BRAIN_CK(nr_quas_lyrs != NULL_PT);
2750 nr_curr_qua_idx = INVALID_IDX;
2751 nr_curr_qua_layer = nxt_lyr;
2752 bool with_restart = (nr_curr_qua_layer == INVALID_IDX);
2753 update_curr_quanton(with_restart);
2757 if(nr_quas_lyrs == NULL_PT){
2760 BRAIN_CK(nr_quas_lyrs != NULL_PT);
2761 BRAIN_CK(nr_curr_qua_idx >= INVALID_IDX);
2763 if(nr_curr_qua_idx < 0){
2768 if(nr_curr_qua_idx < 0){
2769 BRAIN_CK(nr_curr_qua_layer >= 0);
2770 nr_curr_qua_layer--;
2772 if(nr_curr_qua_layer < 0){
2775 update_curr_quanton(
false);
2778 quanton* qua = get_curr_quanton();
2783 if(nr_quas_lyrs == NULL_PT){
2787 if(nr_curr_qua_idx < 0){
2790 BRAIN_CK(nr_quas_lyrs != NULL_PT);
2791 BRAIN_CK(nr_quas_lyrs->ql_quas_by_layer.is_valid_idx(nr_curr_qua_layer));
2792 row_quanton_t& lv_mots = nr_quas_lyrs->ql_quas_by_layer[nr_curr_qua_layer];
2794 BRAIN_CK(lv_mots.is_valid_idx(nr_curr_qua_idx));
2796 quanton* nxt_qua = lv_mots[nr_curr_qua_idx];
2797 BRAIN_CK(nxt_qua != NULL_PT);
2801 long get_curr_qlevel(){
2802 long lv = INVALID_LEVEL;
2803 quanton* qua = get_curr_quanton();
2810 bool has_curr_quanton(){
2811 return (get_curr_quanton() != NULL_PT);
2830 row<prop_signal> de_all_noted;
2832 row<prop_signal> de_all_confl;
2843 void init_deducer(
brain* brn = NULL_PT);
2847 void init_nk_with_note0(notekeeper& nkpr,
brain& brn);
2850 void init_nk_with_note5(notekeeper& nkpr,
brain& brn);
2852 brain* get_dbg_brn(){
2853 brain* the_brn = NULL;
2854 BRAIN_DBG(the_brn = de_brain);
2858 solver* get_dbg_slv();
2860 brain& get_de_brain();
2862 bool is_end_of_rsn(
bool in_roo);
2866 bool ck_end_of_lrn_nmp();
2868 void fill_rsn(reason& rsn);
2869 void find_all_to_write(row_neuromap_t& to_wrt, reason& dbg_rsn);
2871 bool ck_deduc_init(
long deduc_lv,
bool full_ck, row_quanton_t& causes);
2873 void set_conflicts(row<prop_signal>& all_confl){
2874 de_all_confl.clear(
true,
true);
2875 all_confl.copy_to(de_all_confl);
2876 BRAIN_CK(! de_all_confl.is_empty());
2880 BRAIN_CK(! de_all_confl.is_empty());
2887 long deduce_init(row_quanton_t& causes,
long max_lv = INVALID_LEVEL);
2888 void deduce(
deduction& dct,
long max_lv = INVALID_LEVEL);
2890 void set_nxt_noted(
quanton* nxt_qua);
2892 bool find_next_source();
2893 bool find_next_noted();
2894 void set_notes_of(row_quanton_t& causes,
bool is_first);
2896 bj_ostream& print_deducer(bj_ostream& os,
bool from_pt =
false);
2915 row_neuron_t ld_learned;
2918 long ld_bak_mono_idx;
2921 init_leveldat(pt_brn);
2928 void init_leveldat(
brain* pt_brn = NULL){
2930 ld_idx = INVALID_IDX;
2932 ld_chosen = NULL_PT;
2934 ld_bak_mono_idx = INVALID_IDX;
2937 brain* get_dbg_brn(){
2938 brain* the_brn = NULL;
2939 BRAIN_DBG(the_brn = ld_brn);
2943 solver* get_dbg_slv();
2945 bool ck_maps_active();
2946 void let_maps_go(
brain& brn);
2950 leveldat* lv = tpl_malloc<leveldat>();
2952 lv->ld_brn = pt_brn;
2957 void release_leveldat(
leveldat* lv){
2958 BRAIN_CK(lv != NULL_PT);
2960 tpl_free<leveldat>(lv);
2964 return ! ld_learned.is_empty();
2968 BRAIN_CK(ld_chosen != NULL_PT);
2969 bool is_mn = (ld_chosen->is_opp_mono());
2974 BRAIN_CK(ld_chosen != NULL_PT);
2975 BRAIN_CK(ld_chosen->has_charge());
2976 long qti = ld_chosen->qu_tier;
2981 return ld_learned.size();
2984 void release_learned(
brain& brn);
2986 void reset_monos(
brain& brn);
2988 bj_ostream& print_leveldat(bj_ostream& os,
bool from_pt =
false);
2997 bool ti_never_write;
2998 bool ti_min_trainable;
3010 void init_test_info(){
3011 ti_never_find =
false;
3012 ti_never_write =
false;
3013 ti_min_trainable =
false;
3014 ti_as_release =
false;
3026 class dbg_inst_info {
3028 long dbg_before_retract_lv;
3029 long dbg_last_recoil_lv;
3034 row_neuron_t dbg_simple_neus;
3035 row_neuron_t dbg_used_neus;
3036 row<canon_clause*> dbg_ccls;
3039 bj_big_int_t dbg_find_id;
3040 bj_big_int_t dbg_save_id;
3042 bj_big_int_t dbg_canon_save_id;
3044 row_quanton_t dbg_all_chosen;
3046 bool dbg_clean_code;
3049 bool dbg_periodic_prt;
3051 ch_string dbg_cy_prefix;
3053 ch_string dbg_cy_layout;
3058 long dbg_max_wrt_num_subnmp;
3059 long dbg_max_fnd_num_subnmp;
3061 bj_big_int_t dbg_num_glb_cho;
3062 bj_big_int_t dbg_num_loc_cho;
3065 init_dbg_inst_info();
3068 void init_dbg_inst_info();
3083 void due_periodic_prt(
void* pm,
double curr_secs);
3088 throw instance_exception(inx_bad_eq_op);
3092 throw instance_exception(inx_bad_creat);
3098 dbg_inst_info br_dbg;
3100 bj_ofstream br_dbg_htm_os;
3101 long br_dbg_num_phi_grps;
3102 row_quanton_t br_dbg_phi_id_quas;
3103 str_str_map_t br_dbg_phi_wrt_ids;
3104 bool br_dbg_keeping_learned;
3105 long br_dbg_min_trainable_num_sub;
3107 row<prop_signal> br_dbg_all_ps_upd_wrt;
3108 row_neuron_t br_dbg_all_neu_upd_wrt;
3109 bj_big_int_t br_dbg_num_find_anal;
3111 long br_dbg_watched_nmp_idx;
3112 ticket br_dbg_watched_nmp_tk;
3113 bool br_dbg_is_watched_file;
3114 bool br_dbg_skl_bug;
3115 bool br_dbg_found_top;
3116 bool br_dbg_in_analysis;
3123 double br_start_load_tm;
3124 double br_start_solve_tm;
3126 row<leveldat*> br_data_levels;
3128 bool br_dbg_only_deduc;
3132 reason br_tmp_find_rsn;
3134 row_long_t br_tmp_all_sz_side1;
3135 row_long_t br_tmp_all_sz_side2;
3137 row_quanton_t br_tmp_fixing_quantons;
3138 row_quanton_t br_tmp_load_quantons;
3139 row_quanton_t br_tmp_assig_quantons;
3141 row_quanton_t br_tmp_prt_quas;
3142 row_quanton_t br_tmp_motives;
3143 row_quanton_t br_tmp_choose;
3144 row_quanton_t br_tmp_nmp_quas_for_upper_qu;
3145 row_quanton_t br_tmp_f_analysis;
3146 row_quanton_t br_tmp_ck_col;
3147 row_quanton_t br_tmp_ck_all_orig;
3148 row_quanton_t br_tmp_uncharged_in_alert_neus;
3149 row_quanton_t br_tmp_mono_all_neg;
3150 row_quanton_t br_tmp_eq_nmp_all_pos1;
3151 row_quanton_t br_tmp_eq_nmp_all_pos2;
3152 row_quanton_t br_tmp_prv_biqus;
3153 row_quanton_t br_tmp_nxt_biqus;
3154 row_quanton_t br_tmp_all_cicles;
3155 row_quanton_t br_tmp_cicles_lv_quas;
3156 row_quanton_t br_tmp_biqus_lv1;
3157 row_quanton_t br_tmp_biqus_lv2;
3158 row_quanton_t br_tmp_biqus_lv3;
3159 row_quanton_t br_tmp_all_impl_cho;
3160 row_quanton_t br_tmp_rever_quas;
3161 row_quanton_t br_tmp_trail;
3162 row_quanton_t br_tmp_extra_quas;
3164 row_neuron_t br_tmp_prt_nmp_neus;
3165 row_neuron_t br_tmp_nmp_neus_for_upper_qu;
3166 row_neuron_t br_tmp_upd_wrt_neus;
3168 row_long_t br_tmp_proof_idxs;
3171 ch_string br_file_name;
3172 ch_string br_file_name_in_ic;
3175 recoil_counter_t br_prv_round_last_rc;
3176 ticket br_curr_choice_tk;
3177 round_counter_t br_round;
3178 ticket br_curr_write_tk;
3180 k_row<quanton> br_positons;
3181 k_row<quanton> br_negatons;
3183 qulayers br_charge_trail;
3185 charge_t br_choice_spin;
3186 long br_choice_order;
3188 bool br_last_retract;
3190 row_quanton_t br_choices;
3191 row_quanton_t br_chosen;
3193 row_quanton_t br_monos;
3194 long br_last_monocho_idx;
3196 k_row<neuron> br_neurons;
3197 row_neuron_t br_free_neurons;
3198 long br_num_active_neurons;
3200 row_neuron_t br_unit_neurons;
3201 row_neuron_t br_learned_unit_neurons;
3203 k_row<neuromap> br_neuromaps;
3204 row_neuromap_t br_free_neuromaps;
3205 long br_num_active_neuromaps;
3207 k_row<alert_rel> br_alert_rels;
3208 row<alert_rel*> br_free_alert_rels;
3209 long br_num_active_alert_rels;
3211 long br_first_psignal;
3212 long br_last_psignal;
3213 row<prop_signal> br_psignals;
3214 row<prop_signal> br_delayed_psignals;
3215 row<prop_signal> br_all_conflicts_found;
3218 qlayers_ref br_wrt_ref;
3221 reason br_retract_rsn;
3224 notekeeper br_dbg_retract_nke0;
3226 row_quanton_t br_all_cy_quas;
3227 row_neuron_t br_all_cy_neus;
3229 row_quanton_t br_dbg_quly_cy_quas;
3231 row<sortee*> br_tmp_wrt_tauto_tees;
3232 row<sortee*> br_tmp_wrt_guide_tees;
3234 row<canon_clause*> br_tmp_wrt_tauto_ccls;
3235 row<canon_clause*> br_tmp_wrt_diff_ccls;
3236 row<canon_clause*> br_tmp_wrt_guide_ccls;
3242 row_neuromap_t br_candidate_nmp_lvs;
3243 row_neuromap_t br_candidate_nxt_nmp_lvs;
3245 recoil_counter_t br_candidate_nxt_rc;
3246 long br_candidate_rsn_lv;
3266 long br_tot_cy_sigs;
3267 long br_tot_cy_nmps;
3269 row_neuron_t br_tmp_ck_sat_neus;
3270 row_neuron_t br_tmp_prt_neus;
3271 row_neuron_t br_tmp_all_neus;
3272 row_neuron_t br_tmp_all_confl;
3274 row_neuromap_t br_tmp_wrt_root;
3276 row<prop_signal> br_tmp_prt_ps;
3277 row<prop_signal> br_tmp_nmp_get_all_ps;
3284 long br_qu_tot_note0;
3285 long br_qu_tot_note1;
3286 long br_qu_tot_note2;
3287 long br_qu_tot_note3;
3288 long br_qu_tot_note4;
3289 long br_qu_tot_note5;
3290 long br_qu_tot_note6;
3293 long br_ne_tot_tag0;
3294 long br_ne_tot_tag1;
3295 long br_ne_tot_tag2;
3296 long br_ne_tot_tag3;
3297 long br_ne_tot_tag4;
3298 long br_ne_tot_tag5;
3310 bj_ostr_stream br_final_msg;
3317 void init_brain(solver& ss);
3319 void init_all_dbg_brn();
3321 brain* get_dbg_brn(){
3322 brain* the_brn = NULL;
3323 BRAIN_DBG(the_brn = br_pt_brn);
3327 solver* get_dbg_slv();
3329 void all_mutual_init(){
3330 br_guide_neus_srg.stab_mutual_init();
3331 br_guide_quas_srg.stab_mutual_init();
3336 br_tauto_neus_srg.stab_mutual_init();
3337 br_tauto_quas_srg.stab_mutual_init();
3340 ch_string& get_f_nam(){
3341 return get_my_inst().get_f_nam();
3344 void release_all_sortors();
3345 void release_brain();
3347 solver& get_solver();
3350 bj_output_t& get_out_info();
3352 bool dbg_as_release();
3356 long brn_tunnel_signals(
bool only_orig, row_quanton_t& all_impl_cho);
3360 bool ck_prev_monos();
3362 void fill_mono_rsn(reason& rsn, row_quanton_t& mots,
quanton& mono);
3364 bool dbg_ck_rsns(reason& rsn1, reason& rsn2);
3366 bool ck_mono_propag();
3367 long propagate_signals();
3370 void start_propagation(
quanton& qua);
3371 comparison select_propag_side(
bool cnfl1,
long sz1, row_long_t& all_sz1,
3372 bool cnfl2,
long sz2, row_long_t& all_sz2);
3374 void init_forced_sorter();
3382 BRAIN_CK(br_first_psignal <= br_last_psignal);
3383 BRAIN_CK(br_psignals.is_valid_idx(br_first_psignal));
3384 prop_signal& sgnl = br_psignals[br_first_psignal];
3388 bool has_psignals(){
3389 BRAIN_CK(br_first_psignal <= br_last_psignal);
3390 return (br_first_psignal < br_last_psignal);
3393 long num_psignals(){
3394 BRAIN_CK(br_first_psignal <= br_last_psignal);
3395 return (br_last_psignal - br_first_psignal);
3398 void reset_psignals(){
3399 br_first_psignal = 0;
3400 br_last_psignal = 0;
3403 bool has_reset_psignals(){
3404 return ((br_first_psignal == 0) && (br_last_psignal == 0));
3408 BRAIN_CK((nxt_ti > 0) || (level() == ROOT_LEVEL));
3409 put_psignal(qua, neu, nxt_ti);
3412 void send_row_psignals(row<prop_signal>& to_send){
3413 for(
long aa = 0; aa < to_send.size(); aa++){
3415 BRAIN_CK(psig.ps_quanton != NULL_PT);
3417 send_psignal(*psig.ps_quanton, psig.ps_source, psig.ps_tier);
3421 quanton* receive_psignal(
bool only_orig);
3423 void send_next_mono();
3425 void get_bineu_sources(
quanton& cho,
quanton& qua, row_quanton_t& all_src);
3426 void get_all_bineu_sources(
quanton& cho, row_quanton_t& all_src);
3427 void get_all_cicle_cho(row_quanton_t& all_cicl);
3428 quanton* get_cicles_common_cho(
quanton*& replace_cho, row_quanton_t& all_impl_cho);
3429 void get_last_lv_charges(row_quanton_t& all_lv_pos);
3431 bj_ostream& print_psignals(bj_ostream& os,
bool just_qua =
false){
3433 for(
long aa = br_first_psignal + 1; aa <= br_last_psignal; aa++){
3434 if(br_psignals.is_valid_idx(aa)){
3436 os << br_psignals[aa].ps_quanton <<
", ";
3438 os << br_psignals[aa] << bj_eol;
3449 void pop_all_canditates();
3450 void write_all_canditates();
3456 if(! br_free_neuromaps.is_empty()){
3457 pt_nmp = br_free_neuromaps.pop();
3458 long nmp_idx = pt_nmp->na_index;
3460 BRAIN_CK(br_neuromaps.is_valid_idx(nmp_idx));
3461 BRAIN_CK(&(br_neuromaps[nmp_idx]) == pt_nmp);
3463 pt_nmp = &(br_neuromaps.inc_sz());
3464 pt_nmp->na_index = br_neuromaps.last_idx();
3466 BRAIN_CK(pt_nmp != NULL);
3469 BRAIN_CK(nmp.na_index != INVALID_IDX);
3470 BRAIN_CK(nmp.is_na_virgin());
3474 br_num_active_neuromaps++;
3478 void release_neuromap(
neuromap& nmp){
3479 BRAIN_CK(! br_neuromaps.is_empty());
3480 br_free_neuromaps.push(&nmp);
3481 nmp.init_neuromap();
3483 BRAIN_CK(nmp.is_na_virgin());
3485 br_num_active_neuromaps--;
3490 alert_rel& locate_alert_rel(){
3491 alert_rel* pt_arl = NULL_PT;
3492 if(! br_free_alert_rels.is_empty()){
3493 pt_arl = br_free_alert_rels.pop();
3495 pt_arl = &(br_alert_rels.inc_sz());
3497 BRAIN_CK(pt_arl != NULL);
3499 alert_rel& arl = *pt_arl;
3500 BRAIN_CK(arl.is_ar_virgin());
3502 br_num_active_alert_rels++;
3506 void release_alert_rel(alert_rel& arl){
3507 BRAIN_CK(! br_alert_rels.is_empty());
3508 br_free_alert_rels.push(&arl);
3509 arl.init_alert_rel();
3511 BRAIN_CK(arl.is_ar_virgin());
3513 br_num_active_alert_rels--;
3519 neuron* pt_neu = NULL_PT;
3520 if(! br_free_neurons.is_empty()){
3521 pt_neu = br_free_neurons.pop();
3522 long neu_idx = pt_neu->ne_index;
3524 BRAIN_CK(br_neurons.is_valid_idx(neu_idx));
3525 BRAIN_CK(&(br_neurons[neu_idx]) == pt_neu);
3527 pt_neu = &(br_neurons.inc_sz());
3528 pt_neu->ne_index = br_neurons.last_idx();
3530 BRAIN_CK(pt_neu != NULL);
3533 BRAIN_CK(neu.ne_index != INVALID_IDX);
3534 BRAIN_CK(neu.is_ne_virgin());
3536 BRAIN_DBG(neu.ne_pt_brn =
this);
3538 br_num_active_neurons++;
3542 void release_neuron(
neuron& neu){
3543 BRAIN_CK(! br_neurons.is_empty());
3544 br_free_neurons.push(&neu);
3547 BRAIN_CK(neu.is_ne_virgin());
3549 br_num_active_neurons--;
3554 void reset_conflict(){
3555 br_all_conflicts_found.clear(
true,
true);
3559 BRAIN_CK(! br_all_conflicts_found.is_empty());
3561 BRAIN_CK(fst_cfl.ps_source != NULL_PT);
3562 BRAIN_CK(fst_cfl.ps_source->ne_original);
3563 BRAIN_CK(fst_cfl.ps_tier != INVALID_TIER);
3567 bool found_conflict(){
3568 bool h_cfl = ! br_all_conflicts_found.is_empty();
3569 BRAIN_CK(! h_cfl || ! first_conflict().is_ps_virgin());
3575 void set_file_name_in_ic(ch_string f_nam =
"");
3576 void config_brain(ch_string f_nam =
"");
3577 void init_loading(
long num_qua,
long num_neu);
3579 void init_alert_neus();
3580 void update_monos();
3582 neuron& add_neuron(row_quanton_t& quans,
quanton*& forced_qua,
bool orig);
3583 neuron* learn_mots(reason& rsn);
3585 quanton* get_quanton(
long q_id);
3587 recoil_counter_t recoil(){
3588 return br_curr_choice_tk.tk_recoil;
3592 br_curr_choice_tk.tk_recoil++;
3596 BRAIN_CK(br_data_levels.size() == (br_curr_choice_tk.tk_level + 1));
3597 return br_curr_choice_tk.tk_level;
3601 return (level() == ROOT_LEVEL);
3604 leveldat& get_leveldat(
long lv = INVALID_LEVEL){
3605 row<leveldat*>& all_lv = br_data_levels;
3606 if(! all_lv.is_valid_idx(lv)){
3607 BRAIN_CK(! all_lv.is_empty());
3609 BRAIN_CK(pt_lv != NULL);
3613 BRAIN_CK(all_lv[lv] != NULL_PT);
3616 BRAIN_CK((lv == ROOT_LEVEL) || (lv_dat.ld_chosen != NULL_PT));
3617 BRAIN_CK((lv == ROOT_LEVEL) || (lv_dat.ld_chosen->qlevel() == lv_dat.ld_idx));
3629 leveldat* pt_lv = leveldat::create_leveldat(
this);
3630 BRAIN_CK(pt_lv != NULL);
3631 br_data_levels.push(pt_lv);
3633 dat_lv.ld_idx = br_data_levels.last_idx();
3638 (br_curr_choice_tk.tk_level)++;
3640 leveldat& dat_lv = inc_data_levels();
3641 dat_lv.ld_chosen = &qua;
3647 return br_charge_trail.last_qlevel();
3654 BRAIN_CK(! br_data_levels.is_empty());
3655 leveldat* lv = br_data_levels.last();
3656 BRAIN_CK(lv != NULL);
3663 BRAIN_CK(cho != NULL);
3664 BRAIN_CK(! cho->has_charge() || (cho->qlevel() == level()));
3668 bool is_curr_cho_mono(){
3673 bool is_mn = cho->is_opp_mono();
3677 long get_last_lv_all_trail_sz(row_long_t& all_sz){
3680 long num_prop = br_charge_trail.get_all_sz(all_sz, cho.qu_tier);
3684 void update_tk_charge(ticket& nw_tk);
3685 void update_tk_trail(ticket& nw_tk);
3687 bool lv_has_learned(){
3688 return get_leveldat().has_learned();
3691 long lv_num_learned(){
3692 return get_leveldat().num_learned();
3695 void replace_choice(
quanton& cho,
quanton& nw_cho, dbg_call_id dbg_id = dbg_call_1);
3696 void retract_to(
long tg_lv,
bool full_reco);
3697 bool dbg_in_edge_of_level();
3698 bool dbg_in_edge_of_target_lv(reason& rsn);
3699 void dbg_old_reverse_trail();
3701 bool deduce_and_reverse_trail();
3702 void reverse_with(reason& rsn);
3704 bool ck_cov_flags();
3706 neuromap* pop_cand_lv_in(row_neuromap_t& lvs,
bool free_mem,
bool force_rel);
3710 neuromap* pop_cand_lv(
bool free_mem);
3711 void pop_cand_lvs_until(
quanton& qua);
3712 void pop_all_cand_lvs();
3713 void pop_all_nxt_cand_lvs(
long tg_lv = INVALID_LEVEL);
3715 void use_next_cand(
quanton& qua);
3717 void set_chg_cands_update(
quanton& qua);
3719 void reset_chg_cands_update(
quanton& qua);
3720 void reset_cand_next();
3721 void candidates_before_analyse();
3722 void candidates_before_reverse(reason& rsn);
3723 void candidates_after_reverse();
3727 bool in_current_round(ticket& the_tk){
3728 bool in_rnd = (the_tk.tk_recoil > br_prv_round_last_rc);
3732 long get_lst_cand_lv();
3733 neuromap* get_last_cand(dbg_call_id dbg_id = dbg_call_1);
3737 void add_top_cands(row_neuromap_t& to_wrt);
3739 void analyse_conflicts(row<prop_signal>& all_confl,
deduction& dct);
3741 void write_analysis(row_quanton_t& causes,
long deduc_lv, reason& rsn);
3742 void write_update_all_tk(row_quanton_t& causes);
3743 void write_get_tk(ticket& wrt_tk);
3744 bool ck_write_quas(reason& rsn);
3746 long get_min_trainable_num_sub();
3748 bool dbg_ck_candidates(
bool nw_cands);
3751 long tr = br_charge_trail.last_qtier();
3756 quanton* qua = br_charge_trail.last_quanton();
3757 BRAIN_CK(qua != NULL_PT);
3761 void init_mem_tmps(){
3762 br_tmp_wrt_tauto_ccls.clear();
3763 br_tmp_wrt_guide_ccls.clear();
3764 br_tmp_wrt_diff_ccls.clear();
3766 br_tmp_wrt_tauto_cnf.clear_cnf();
3767 br_tmp_wrt_diff_cnf.clear_cnf();
3768 br_tmp_wrt_guide_cnf.clear_cnf();
3773 void init_all_tots(){
3779 void init_qu_tots(){
3780 br_qu_tot_note0 = 0;
3781 br_qu_tot_note1 = 0;
3782 br_qu_tot_note2 = 0;
3783 br_qu_tot_note3 = 0;
3784 br_qu_tot_note4 = 0;
3785 br_qu_tot_note5 = 0;
3786 br_qu_tot_note6 = 0;
3789 void init_ne_tots(){
3798 void init_na_tots(){
3807 ch_string dbg_prt_margin(bj_ostream& os,
bool is_ck =
false);
3808 void dbg_prt_cand_info(bj_ostream& os,
neuron& neu);
3810 ch_string& dbg_get_file(){
3811 return get_my_inst().ist_file_path;
3815 void print_trail(bj_ostream& os,
bool no_src_only =
false);
3817 bj_ostream& print_all_quantons(bj_ostream& os,
long ln_sz, ch_string ln_fd);
3819 bool dbg_br_compute_binary(row_neuron_t& neus);
3820 bool dbg_br_compute_ck_sat(row_neuron_t& neus);
3821 bool dbg_br_compute_ck_sat_of(row_neuron_t& neus, row_quanton_t& assig);
3823 void read_cnf(dimacs_loader& ldr);
3824 void parse_cnf(dimacs_loader& ldr, row<long>& all_ccls);
3825 neuron& load_neuron(row_quanton_t& neu_quas);
3826 bool load_brain(
long num_neu,
long num_var, row_long_t& load_ccls);
3828 bool load_instance();
3834 void fill_with_origs(row_neuron_t& neus);
3836 void check_timeout();
3837 void dbg_check_sat_assig();
3842 void dbg_add_to_used(
neuron& neu);
3844 void dbg_lv_on(
long lv_idx);
3845 void dbg_lv_off(
long lv_idx);
3847 void dbg_prt_all_nmp(bj_ostream& os, row_neuromap_t& all_cand,
bool just_ids);
3848 void dbg_prt_all_cands(bj_ostream& os,
bool just_ids =
false);
3849 void dbg_prt_all_nxt_cands(bj_ostream& os,
bool just_ids =
false);
3851 void dbg_prt_br_neuromaps(bj_ostream& os);
3853 void dbg_prt_lvs_have_learned(bj_ostream& os);
3854 void dbg_prt_lvs_cho(bj_ostream& os);
3855 void dbg_prt_full_stab();
3857 void dbg_print_cy_nmp_node_plays(bj_ostream& os);
3858 void dbg_print_cy_graph_node_plays(bj_ostream& os);
3859 void dbg_print_cy_graph_node_tiers(bj_ostream& os);
3861 void dbg_init_html();
3862 void dbg_start_html();
3863 void dbg_finish_html();
3864 void dbg_update_html_cy_graph(ch_string cy_kk,
coloring* col, ch_string htm_str);
3865 void dbg_br_init_all_cy_pos();
3867 void print_active_blocks(bj_ostream& os);
3869 bj_ostream& dbg_br_print_col_cy_nodes(bj_ostream& os,
bool is_ic);
3870 bj_ostream& dbg_print_all_qua_rels(bj_ostream& os);
3871 bj_ostream& dbg_print_htm_all_monos(bj_ostream& os);
3873 bj_ostream& print_brain(bj_ostream& os);
3875 bj_ostream& print_all_original(bj_ostream& os);
3883 quanton::tunnel_swapop(
long idx_pop){
3884 long idx_mov = qu_tunnels.size() - 1;
3885 neuron* neu2 = qu_tunnels.last();
3886 BRAIN_CK(neu2->ck_tunnels());
3887 qu_tunnels.swapop(idx_pop);
3888 if(idx_pop != idx_mov){
3889 BRAIN_CK(qu_tunnels[idx_pop] == neu2);
3890 if(neu2->ne_fibres[0] ==
this){
3891 BRAIN_CK(neu2->ne_fibre_0_idx == idx_mov);
3892 neu2->ne_fibre_0_idx = idx_pop;
3894 BRAIN_CK(neu2->ne_fibres[1] ==
this);
3895 BRAIN_CK(neu2->ne_fibre_1_idx == idx_mov);
3896 neu2->ne_fibre_1_idx = idx_pop;
3898 BRAIN_CK(neu2->ck_tunnels());
3904 quanton::get_source(){
3905 if(qu_source == NULL_PT){
3907 return qu_inverse->qu_source;
3910 BRAIN_CK((qu_source == NULL_PT) || ! qu_source->is_ne_virgin());
3916 quanton::has_learned_source(){
3917 bool h_l_src = has_source() && ! get_source()->ne_original;
3923 qulayers::get_qu_layer(
long lv){
3925 BRAIN_CK(lv < MAX_LAYERS);
3926 while(ql_quas_by_layer.size() <= lv){
3927 ql_quas_by_layer.inc_sz();
3930 BRAIN_CK(lv < MAX_LAYERS);
3931 BRAIN_CK(ql_quas_by_layer.is_valid_idx(lv));
3932 row_quanton_t& mots = ql_quas_by_layer[lv];
3938 notekeeper::get_dk_brain(){
3939 BRAIN_CK(dk_brain != NULL_PT);
3945 deducer::get_de_brain(){
3946 BRAIN_CK(de_brain != NULL_PT);
3952 qulayers::get_ql_brain(){
3953 BRAIN_CK(ql_brain != NULL_PT);
3958 comparison cmp_qlevel(
quanton*
const & qua1,
quanton*
const & qua2){
3959 BRAIN_CK(qua1 != NULL_PT);
3960 BRAIN_CK(qua2 != NULL_PT);
3961 long qlev1 = qua1->qlevel();
3962 long qlev2 = qua2->qlevel();
3963 bool inv1 = (qlev1 == INVALID_LEVEL);
3964 bool inv2 = (qlev2 == INVALID_LEVEL);
3966 if(inv1 && inv2){
return 0; }
3968 if(inv1 && !inv2){
return -1; }
3969 if(!inv1 && inv2){
return 1; }
3971 return cmp_long(qua2->get_charge(), qua1->get_charge());
3973 return cmp_long(qlev2, qlev1);
3977 charge_t negate_trinary(charge_t val){
3978 if(val == cg_negative){
3981 if(val == cg_positive){
3988 void negate_quantons(row_quanton_t& qua_row){
3989 for(
long kk = 0; kk < qua_row.size(); kk++){
3990 qua_row[kk] = qua_row[kk]->qu_inverse;
3996 void get_ids_of(row_quanton_t& quans, row_long_t& the_ids){
3998 for(
long kk = 0; kk < quans.size(); kk++){
4000 the_ids.push(qua.qu_id);
4006 long find_max_level(row_quanton_t& tmp_mots){
4007 long max_lev = ROOT_LEVEL;
4009 for(
long aa = 0; aa < tmp_mots.size(); aa++){
4010 BRAIN_CK(tmp_mots[aa] != NULL_PT);
4011 quanton& qua = *(tmp_mots[aa]);
4012 BRAIN_CK(qua.has_charge());
4013 max_lev = max_val(max_lev, qua.qlevel());
4019 long find_max_tier(row_quanton_t& tmp_mots,
long from_idx){
4020 long max_ti = INVALID_TIER;
4022 for(
long aa = from_idx; aa < tmp_mots.size(); aa++){
4023 BRAIN_CK(tmp_mots[aa] != NULL_PT);
4024 quanton& qua = *(tmp_mots[aa]);
4025 max_ti = max_val(max_ti, qua.qu_tier);
4033 DEFINE_PRINT_FUNCS(ticket)
4034 DEFINE_PRINT_FUNCS(alert_rel)
4036 DEFINE_PRINT_FUNCS(
neuron)
4037 DEFINE_PRINT_FUNCS(reason)
4041 DEFINE_PRINT_FUNCS(qulayers)
4042 DEFINE_PRINT_FUNCS(cov_entry)
A canon_cnf is a BCFF. An stabilized sub-formula.
Definition: skeleton.h:386
Class that holds all data used to solve a particular CNF instance.
Definition: brain.h:3085
Class that holds the data used to analyze a conflict.
Definition: brain.h:2823
Class for CNF variables (each variable has a positon and a negaton).
Definition: brain.h:600
Class that holds the result of analyzing (doing resolution) of a conflict.
Definition: brain.h:1715
Class that is an item to be stabilized.
Definition: sortor.h:152
Class that holds an instance data.
Definition: instance_info.h:96
A neuromap is a CNF sub-formula.
Definition: brain.h:2191
ben_jose API declaration.
Class for representing BCP propagation data.
Definition: brain.h:1525
A skeleton_glb is a directory holding a database.
Definition: skeleton.h:761
void write_all_nmps(row_neuromap_t &to_wrt)
Writes all neuromap s (candidates) that need writing.
Definition: macro_ben_jose.cpp:94
bj_satisf_val_t
Posible final results of the solving process.
Definition: ben_jose.h:77
Class for CNF clause behavior. So there is one neuron per clause.
Definition: brain.h:1211
A sorset is a group of sortee s.
Definition: sortor.h:321
Class that holds the data of a level.
Definition: brain.h:2909
The initial and final state for an stabilization is a coloring.
Definition: brain.h:934
Class that holds all global data used to stabilize a group of items.
Definition: sortor.h:579
A sortrel is a relation between two sortee s.
Definition: sortor.h:111