Ignore:
Timestamp:
10/31/09 00:47:01 (15 years ago)
Author:
Maciej Komosinski
Message:

maximal f1 genotype length published as the f8->f1 converter parameter

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/f8-to-f1/geno_f8.cpp

    r30 r33  
    3232{"f8_mut_chg_cond_sign", 0, 0, "Change condition sign", "f 0 100 7",FIELD(operation[F8_CHANGE_CONDITION_SIGN]),"mutation: probability of changing a condition sign", },
    3333{"f8_mut_add_param", 0, 0, "Add parameter", "f 0 100 8", FIELD(operation[F8_ADD_PARAMETER]),"mutation: probability of adding a parameter to the production", },
    34 {"f8_mut_add_cond", 0, 0, "Add condition", "f 0 100 8", FIELD(operation[F8_ADD_CONDITION]),"mutation: probability of ading a condition to the subproduction", },
     34{"f8_mut_add_cond", 0, 0, "Add condition", "f 0 100 8", FIELD(operation[F8_ADD_CONDITION]),"mutation: probability of adding a condition to the subproduction", },
    3535{"f8_mut_add_subprod", 0, 0, "Add subproduction", "f 0 100 8", FIELD(operation[F8_ADD_SUBPRODUCTION]),"mutation: probability of adding a subproduction", },
    36 {"f8_mut_chg_iter_number", 0, 0, "Change iteration number", "f 0 100 7", FIELD(operation[F8_CHANGE_ITERATIONS_NUMBER]),"mutation: probability of changing an iterations number", },
     36{"f8_mut_chg_iter_number", 0, 0, "Change iteration number", "f 0 100 7", FIELD(operation[F8_CHANGE_ITERATIONS_NUMBER]),"mutation: probability of changing a number of iterations", },
    3737{"f8_mut_del_param", 0, 0, "Delete parameter", "f 0 100 8", FIELD(operation[F8_DELETE_PARAMETER]),"mutation: probability of deleting a parameter", },
    3838{"f8_mut_del_cond", 0, 0, "Delete condition", "f 0 100 8", FIELD(operation[F8_DELETE_CONDITION]),"mutation: probability of deleting a condition", },
    39 {"f8_mut_add_loop", 0, 0, "Add loop", "f 0 100 0", FIELD(operation[F8_ADD_LOOP]),"mutation: probability of ading a loop", },
     39{"f8_mut_add_loop", 0, 0, "Add loop", "f 0 100 0", FIELD(operation[F8_ADD_LOOP]),"mutation: probability of adding a loop", },
    4040{"f8_mut_del_loop", 0, 0, "Delete loop", "f 0 100 0", FIELD(operation[F8_DELETE_LOOP]),"mutation: probability of deleting a loop", },
    4141{"f8_mut_del_prod", 0, 0, "Delete production", "f 0 100 8", FIELD(operation[F8_DELETE_PRODUCTION]),"mutation: probability of deleting a production", },
     
    6363        this->simpleCommandLetters.push_back('^');
    6464        this->converter = new GenoConv_F8ToF1();
    65        
     65
    6666        par.setParamTab(GENO8param_tab);
    6767        par.select(this);
    6868        par.setDefault();
    69        
    70         /*mutation_method_names = new char*[F8_OPERATION_COUNT - 1];
     69
     70        /*mutation_method_names = new char*[F8_OPERATION_COUNT - 1]; //FIXME
    7171        int index = 0;
    7272        mutation_method_names[index++]="changed beginning argument";
     
    511511                                newActions.push_back(subproduction->actions[i]);
    512512                        }
    513                         for (i = firstActionIdx; i <= firstActionIdx + randomN(4) + 1 
     513                        for (i = firstActionIdx; i <= firstActionIdx + randomN(4) + 1
    514514                                 && i < subproduction->actions.size(); i++) { //1..4 actions
    515515                                newSubProd->actions.push_back(subproduction->actions[i]);
     
    551551       
    552552        delete lsystem;
    553        
     553
    554554        chg = (float) len / (float) in.len();
    555555        return mutated;
     
    569569                mutated += in;
    570570                chg = 0.0;
     571                delete lsystem;
    571572                return mutated;
    572573        }
    573        
    574         int counter = 0;
     574
    575575        vector<SString> productionNamesSS = this->converter->readProductionNames(in);
    576576        vector<string> productionNames;
     
    601601        //choose production to which we will append the contents of deleted production
    602602        string prodNameToAppendTo = productionNames[randomN(productionNames.size())];
    603        
     603
    604604        int len = 0;
    605        
     605
    606606        Production* deletedProd = lsystem->productions[prodNameToDelete];
    607607        Production* appendProd = lsystem->productions[prodNameToAppendTo];
     
    613613                }
    614614        }
    615        
     615
    616616        //copy subproductions
    617617        for (vector<SubProduction>::iterator subprodIter = deletedProd->subproductions.begin();
     
    639639        }
    640640        lsystem->productions.erase(string(prodNameToDelete));
    641        
     641
    642642        int paramCount = appendProd->parameters.size();
    643643        for (map<string, Production*>::iterator prodIter = lsystem->productions.begin();
     
    647647                        for (vector<ActionStrP>::iterator actionIter = (*subprodIter).actions.begin();
    648648                                 actionIter != (*subprodIter).actions.end(); actionIter++) {
    649                                 if ((*actionIter).action != NULL && (*actionIter).action->name != NULL) { 
     649                                if ((*actionIter).action != NULL && (*actionIter).action->name != NULL) {
    650650                                        if ((*actionIter).action->name == stringToSString(prodNameToDelete)) {
    651651                                                (*actionIter).action = appendProd;
     
    659659                                                }
    660660                                        }
    661                                        
     661
    662662                                }
    663663                        }
     
    665665        }
    666666        delete deletedProd;
    667                
    668        
     667
     668
    669669        mutated = lsystem->toString();
    670        
     670
    671671        delete lsystem;
    672        
     672
    673673        chg = (float) len / (float) in.len();
    674674        return mutated;
     
    677677SString Geno_f8::mutateChangeConditionSign(SString &in, float& chg) {
    678678        SString mutated;
    679        
     679
    680680        Lsystem *newLsystem = this->converter->createLsystem(in);
    681681        if (newLsystem == NULL) {
     
    684684                return mutated;
    685685        }
    686        
     686
    687687        map<int, SubProduction*> interestingSubproductions;
    688688        int counter = 0;
    689        
     689
    690690        for (map<string, Production*>::iterator prodIter = newLsystem->productions.begin();
    691691                 prodIter != newLsystem->productions.end(); prodIter++) {
     
    698698                }
    699699        }
    700        
     700
    701701        if (interestingSubproductions.size() > 0) {
    702702                int random1 = randomN(interestingSubproductions.size());
     
    707707                chg = 2.0 / (float) in.len();
    708708        }
    709        
     709
    710710        mutated = newLsystem->toString();
    711        
     711
    712712        delete newLsystem;
    713        
     713
    714714        return mutated;
    715715}
     
    717717SString Geno_f8::mutateAddParameter(SString &in, float& chg) {
    718718        SString mutated;
    719        
     719
    720720        Lsystem *lsystem = this->converter->createLsystem(in);
    721721        if (lsystem == NULL || lsystem->productions.size() == 0) {
     
    724724                return mutated;
    725725        }
    726        
     726
    727727        //cout << "addParameter 1" << endl;
    728728        int rnd = randomN(lsystem->productions.size());
    729729        int chglen = 0;
    730        
     730
    731731        SString prodName = "";
    732        
     732
    733733        int counter = 0;
    734734        for (map<string, Production*>::iterator prodIter = lsystem->productions.begin();
     
    746746                                }
    747747                        }
    748                        
     748
    749749                        if (prodName == stringToSString(lsystem->firstProductionName)) {
    750750                                lsystem->startParams[sstringToString(newParam)] = 0.0;
     
    10831083        (method == 13) ? "F8_ADD_LOOP" :
    10841084        (method == 14) ? "F8_DELETE_LOOP" :
    1085         (method == 15) ? "F8_OPERATION_COUNT" : "babol";
     1085        (method == 15) ? "F8_OPERATION_COUNT" : "*invalid*";
    10861086        //cout << "-------------------- " << mutationName << " --------------------" << endl;
    10871087#endif
Note: See TracChangeset for help on using the changeset viewer.