Changeset 1240 for cpp/frams/genetics/f4
- Timestamp:
- 05/10/23 01:28:06 (20 months ago)
- Location:
- cpp/frams/genetics/f4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/f4/f4_conv.cpp
r1236 r1240 39 39 SString out = model->getF0Geno().getGenes(); 40 40 delete model; 41 42 /* quick debugging test - print an approximate f1 conversion of every genotype converted to f0: 43 GenoConv_F41_TestOnly conv41; 44 SString f1 = conv41.convert(in, NULL, false); 45 printf("f1 = %s\n", f1.c_str()); 46 */ 47 41 48 return out; 42 49 } … … 45 52 GenoConv_F41_TestOnly::GenoConv_F41_TestOnly() 46 53 { 47 name = "Only for testing, approximate f4->f1 converter"; //Do not use in production! (adam) 54 name = "Only for testing, approximate f4->f1 converter"; 55 // Why approximate? for example, f1 does not allow to continue after branching: X(X,X)X <-- the last X 56 // Some modifier genes are also not perfectly converted. 57 // And neuron properties are ignored... 48 58 in_format = '4'; 49 59 out_format = '1'; -
cpp/frams/genetics/f4/f4_general.cpp
r1239 r1240 679 679 return true; //so continue development! 680 680 681 if (development_stagnation) 682 return false; //the same number of cells, no progress in development in any cell -> stagnation, end development 681 //the same number of cells, no progress in development in any cell -> stagnation! 682 683 if (development_stagnation) // stagnation was already detected in the previous step, so end development! 684 { 685 for (int i = 0; i < cell_count; i++) 686 if (C[i]->gcur != NULL) // genotype execution pointer did not reach the end 687 logPrintf("f4_Cells", "oneStep", LOG_WARN, "Finishing the development of cells due to stagnation, but cell %d did not reach the end of development", i); //let's see an example of such a genotype and investigate... 688 return false; //end development 689 } 683 690 else 684 691 { 685 692 development_stagnation = true; //signal (force) f4_Cell's that wait for neural connection development to make a step, because all cells stagnated and waiting cells cannot hope for new neurons to be created 686 return true; 693 return true; //one grace step. If there are some waiting cells, they must move on in the next step and set development_stagnation=false or set error. If development_stagnation is not set to false, we will finish development in the next step. This grace step may be unnecessary if there are no waiting cells, but we have no easy way to check this from here (although we could check if all cells' gcur==NULL... would this be always equivalent? Maybe some cells may stagnate with gcur!=NULL and they are not waiting for neural connections to develop and this does not mean an error? Added LOG_WARN above to detect such cases. Anyway, for gcur==NULL, f4_Cell.oneStep() exits immediately, so one grace step is not a big overhead.) 687 694 } 688 695 } … … 879 886 void f4_Cells::toF1GenoRec(int curc, SString &out) 880 887 { 881 int i, j, ccount;882 f4_Cell *thisti;883 f4_Cell *thneu;884 char buf[200];885 886 888 if (curc >= cell_count) return; 887 889 888 890 if (C[curc]->type != CELL_STICK) return; 889 891 890 thisti = C[curc];892 f4_Cell *thisti = C[curc]; 891 893 if (thisti->dadlink != NULL) 892 894 *tmpcel = *(thisti->dadlink); … … 929 931 930 932 // neurons attached to it 931 for (i = 0; i < cell_count; i++)933 for (int i = 0; i < cell_count; i++) 932 934 { 933 935 if (C[i]->type == CELL_NEURON) … … 935 937 if (C[i]->dadlink == thisti) 936 938 { 937 thneu = C[i];939 f4_Cell *thneu = C[i]; 938 940 out += "["; 939 // ctrl 940 //if (1 == thneu->ctrl) out += "@"; // old code; this can be easily generalized to any neuroclass if ever needed 941 //if (2 == thneu->ctrl) out += "|"; 942 out += thneu->neuclass->name.c_str(); // not tested, but something like that 941 out += thneu->neuclass->name.c_str(); 942 if (thneu->conns_count > 0) 943 out += ", "; 943 944 // connections 944 for (j = 0; j < thneu->conns_count; j++) 945 { 946 if (j) out += ","; 945 for (int j = 0; j < thneu->conns_count; j++) 946 { 947 if (j > 0) out += ", "; 948 char buf[100]; 947 949 sprintf(buf, "%d", thneu->conns[j]->from->nr - thneu->nr); 948 950 out += buf; … … 961 963 out += "("; 962 964 963 ccount = 1;964 for (i = 0; i < cell_count; i++)965 int ccount = 1; 966 for (int i = 0; i < cell_count; i++) 965 967 { 966 968 if (C[i]->type == CELL_STICK) … … 1397 1399 { 1398 1400 //printf("any regular character '%c'\n", genot[pos_inout]); 1399 #define F4_SIMPLIFY_MODIFIERS //avoid long sequences like ...<X>llmlIilImmimiimmimifmfl<fifmmimilimmmiimiliffmfliIfififlliflimfliffififmiffmflllfflimlififfiiffifIr<r<... - another option, instead of simplifying while parsing here, would be mutations: when they add/modify/remove a modifier node, they could "clean" the tree by removing nodes when they encounter contradictory modifiers on the same subpath, and also limit the number of modifiers just as GenoOperators::simplifiedModifiers() does.1401 #define F4_SIMPLIFY_MODIFIERS //avoid long, redundant sequences like ...<X>llmlIilImmimiimmimifmfl<fifmmimilimmmiimiliffmfliIfififlliflimfliffififmiffmflllfflimlififfiiffifIr<r<... 1400 1402 #ifdef F4_SIMPLIFY_MODIFIERS 1401 1403 char *ptr = (char*)(genot + pos_inout);
Note: See TracChangeset
for help on using the changeset viewer.