Changeset 1232
- Timestamp:
- 05/02/23 17:12:24 (19 months ago)
- Location:
- cpp/frams/genetics/f4
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/f4/f4_general.cpp
r1231 r1232 795 795 } 796 796 797 void f4_Cells::setRepairRemove(int nerrpos, f4_Node *rem) 798 { 797 void f4_Cells::setRepairRemove(int nerrpos, f4_Node *to_remove) 798 { 799 errorcode = GENOPER_REPAIR; 800 errorpos = nerrpos; 799 801 if (!repair) 800 802 { 801 803 // not in repair mode, treat as repairable error 802 errorcode = GENOPER_REPAIR;803 errorpos = nerrpos;804 804 } 805 805 else 806 806 { 807 errorcode = GENOPER_REPAIR;808 errorpos = nerrpos;809 repair_remove = rem; 810 } 811 } 812 813 int f4_Cells::setRepairInsert(int nerrpos, f4_Node *parent, f4_Node *insert) 814 { 807 repair_remove = to_remove; 808 } 809 } 810 811 int f4_Cells::setRepairInsert(int nerrpos, f4_Node *parent, f4_Node *to_insert) 812 { 813 errorcode = GENOPER_REPAIR; 814 errorpos = nerrpos; 815 815 if (!repair) 816 816 { 817 817 // not in repair mode, treat as repairable error 818 errorcode = GENOPER_REPAIR;819 errorpos = nerrpos;820 818 return -1; 821 819 } 822 820 else 823 821 { 824 errorcode = GENOPER_REPAIR;825 errorpos = nerrpos;826 822 repair_parent = parent; 827 repair_insert = insert;823 repair_insert = to_insert; 828 824 return 0; 829 825 } … … 1423 1419 int res = f4_processRecur(genot, pos, root); 1424 1420 if (res > 0) 1425 return res; //error 1426 else if (genot[pos] == 0) //parsed until the end - OK! 1427 return 0; 1428 else return pos + 1; //junk, unparsed genes after successful parsing, for example /*4*/<X>N:N>whatever or /*4*/<X>X>>> 1421 return res; //parsing error 1422 else if (genot[pos] != 0) 1423 return pos + 1; //parsing OK but junk, unparsed genes left, for example /*4*/<X>N:N>whatever or /*4*/<X>X>>> 1424 else 1425 return 0; //parsing OK and parsed until the end 1429 1426 } 1430 1427 -
cpp/frams/genetics/f4/f4_general.h
r1231 r1232 303 303 * Sets the element of genotype to be repaired by removal. 304 304 * @param nerrpos position of an error in genotype 305 * @param rem the f4_Node to be removed from thegenotype tree in order to repair306 */ 307 void setRepairRemove(int nerrpos, f4_Node * rem);305 * @param to_remove the f4_Node to be removed from the genotype tree in order to repair 306 */ 307 void setRepairRemove(int nerrpos, f4_Node *to_remove); 308 308 309 309 /** … … 311 311 * @param nerrpos position of an error in genotype 312 312 * @param parent the parent of a new element 313 * @param insert the element to be inserted313 * @param to_insert the element to be inserted 314 314 * @return 0 if repair can be performed, or -1 otherwise because the repair flag wasn't set in the constructor 315 315 */ 316 int setRepairInsert(int nerrpos, f4_Node *parent, f4_Node * insert);316 int setRepairInsert(int nerrpos, f4_Node *parent, f4_Node *to_insert); 317 317 318 318 /** -
cpp/frams/genetics/f4/f4_oper.cpp
r1231 r1232 16 16 // TODO the behavior of neuron input indexes during mutation seems badly implemented (see also TREAT_BAD_CONNECTIONS_AS_INVALID_GENO). Are they kept properly maintained when nodes are added and removed? This could be done well because during mutation we operate on the tree structure with cross-references between nodes (so they should not be affected by local changes in the tree), and then convert the tree back to string. Yet, the f4_Node.conn_from is an integer and these fields in nodes do not seem to be maintained on tree node adding/removal... change these integer offsets to references to node objects? But actually, do the offsets that constitute relative connection references concern the f4_Node tree structure (and all these sophisticated calculations of offsets during mutation are useful) or rather they concern the f4_Cells development? verify all situations in f4_Cell::oneStep(), case '['. 17 17 // TODO add simplifying sequences of modifiers (so capital and small letter cancel out, like in f1) - but seems like each single modifier is a separate f4_Node? and perhaps we don't want to use the repair mechanism for this... maybe mutations, when they add/modify/remove a modifier node, should be "cleaning" the tree by removing nodes when they encounter contradictory modifiers on the same subpath, and also limit the number of modifiers of each type just like in f1? To avoid sequences like ...<X>llmlIilImmimiimmimifmfl<fifmmimilimmmiimiliffmfliIfififlliflimfliffififmiffmfliflifmIlimimiflimfiffmllliflmimifllifliliflifmIlimimiflimfiffmllliflmimifllfmIlimimiflimfiffmllliflmimiflliflimimmiflimfliffmiflifmfiffllIlififliffififmiffmfliflifIliflimimflimflfflimimifllfflifllfflimlififfiiffifIr<r<... 18 // TODO in mutation, adding the '#' gene does not seem to be effective. The gene is added and genotypes are valid, but hardly ever #n is effective, i.e., it hardly ever multiplicates body or brain parts... investigate! 18 19 // TODO add support for properties of (any class of) neurons - not just sigmoid/force/intertia (':' syntax) for N 19 20 // TODO add mapping genotype character ranges for neural [connections] … … 123 124 f4_Node root; 124 125 int res = f4_process(geno, &root); 125 if (r es == 0 || root.childCount() != 1) return GENOPER_OK; // either parsing says the genotype is OK or the resulting tree will not be repairable (fatal flaw; root must have exactly one child) - do notattempt repair126 127 // here we have a genotype with r es>0 (for sure has some error) and root.childCount()==1 (still something was parsed into a tree)126 if (root.childCount() != 1) return GENOPER_OK; // the resulting tree will not be repairable (fatal flaw; root must have exactly one child) - do not even attempt repair 127 128 // here we have a genotype with root.childCount()==1 (meaning some part was successfully parsed into a tree) and either res==0 (syntax was correct, semantics we don't know) or res>0 (for sure has some error) 128 129 const int VALIDATE_TRIALS = 20; 129 130 res = ValidateRecur(&root, VALIDATE_TRIALS);
Note: See TracChangeset
for help on using the changeset viewer.