Changeset 960 for cpp/frams/genetics/fH
- Timestamp:
- 06/26/20 01:31:36 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/fH/fH_oper.cpp
r957 r960 426 426 } 427 427 428 void Geno_fH::mutateNeuronProperties(SString &det) 428 void Geno_fH::mutateNeuronProperties(SString &det) //used also by the "fB" and "fL" encodings 429 429 { 430 430 Neuro neu; 431 det = det == "" ? "N" : det;432 431 neu.setDetails(det == "" ? "N" : det); 433 434 SyntParam par = neu.classProperties(); 435 436 if (par.getPropCount() > 0) 437 { 438 int i = rndUint(par.getPropCount()); 439 if (*par.type(i) == 'f') 440 { 441 double change = mutateNeuronProperty(par.getDouble(i), &neu, GenoOperators::NEUROCLASS_PROP_OFFSET + i); 442 par.setDouble(i, change); 443 } 444 SString line; 445 int tmp = 0; 446 par.update(&line); 447 SString props; 448 line.getNextToken(tmp, props, '\n'); // removal of newline character 449 if (props != "") 450 { 451 det = neu.getClass()->name; 452 det += ": "; 453 det += props; 454 } 455 } 432 GenoOperators::mutateRandomNeuronOrNeuroclassProperty(&neu); 433 det = neu.getDetails(); 456 434 } 457 435 458 436 void Geno_fH::mutateNeuronHandleProperties(fH_NeuronHandle *handle, ParamEntry *tab, bool userandomclass) 459 437 { 460 Neuro neu;461 438 Param hpar(tab, handle->obj); 462 SString det = hpar.getStringById("d"); 463 neu.setDetails(det == "" ? "N" : det); 464 NeuroClass *nc = neu.getClass(); 465 439 SString det; 466 440 if (userandomclass) 467 441 { 468 nc = getRandomNeuroClass(Model::SHAPE_BALL_AND_STICK); 469 // checking of neuron class availability should be done before 470 } 471 472 det = nc->getName(); 473 442 NeuroClass *nc = getRandomNeuroClass(Model::SHAPE_BALL_AND_STICK); // checking that neuron classes are available should be done before 443 det = nc->getName(); 444 } 445 else 446 { 447 det = hpar.getStringById("d"); 448 } 474 449 mutateNeuronProperties(det); 475 476 450 hpar.setStringById("d", det); 477 451 }
Note: See TracChangeset
for help on using the changeset viewer.