Ignore:
Timestamp:
05/23/16 13:52:53 (8 years ago)
Author:
Maciej Komosinski
Message:

checkValidity() and validate() are now aware of genotype name

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/genetics/genman.cpp

    r467 r513  
    203203        int check1;
    204204        if (!gf) { canvalidate = false; return GENOPER_NOOPER; }
    205         else check1 = gf->checkValidity(gg);
     205        else check1 = gf->checkValidity(gg,g.getName().c_str());
    206206        if (!canvalidate) return check1; //just checking
    207207        if (check1 == GENOPER_OK) { canvalidate = false; return check1; }
    208208        char *g2 = strdup(gg);
    209         if (gf->validate(g2) == GENOPER_NOOPER) { free(g2); canvalidate = false; return check1; }
     209        if (gf->validate(g2,g.getName().c_str()) == GENOPER_NOOPER) { free(g2); canvalidate = false; return check1; }
    210210        if (check1 == GENOPER_NOOPER) //disaster: cannot check because there is no check operator
    211211        {
    212212                g.setGene(g2); free(g2); canvalidate = false; return GENOPER_NOOPER;
    213213        }
    214         int check2 = gf->checkValidity(g2);
     214        int check2 = gf->checkValidity(g2, "validated");
    215215        if (check2 == GENOPER_OK) g.setGene(g2);
    216216        free(g2);
     
    238238                return Geno(SString::empty(), -1, SString::empty(), SString::sprintf("GENOPER_NOOPER: Validate(): don't know how to handle genetic format %c", format));
    239239        char *g2 = strdup(geny.getGene().c_str()); //copy for validation
    240         int res = gf->validate(g2);
     240        int res = gf->validate(g2, geny.getName().c_str());
    241241        SString sg2 = g2;
    242242        free(g2);
     
    537537        {
    538538                string l;
    539                 if (oper_fx_list[i]->checkValidity("") != GENOPER_NOOPER) l += " checkValidity";
     539                if (oper_fx_list[i]->checkValidity("","") != GENOPER_NOOPER) l += " checkValidity";
    540540                if (oper_fx_list[i]->getSimplest())
    541541                {
    542542                        g = strdup(oper_fx_list[i]->getSimplest());
    543543                        g2 = strdup(g);
    544                         if (oper_fx_list[i]->validate(g) != GENOPER_NOOPER) l += " validate";
     544                        if (oper_fx_list[i]->validate(g,"") != GENOPER_NOOPER) l += " validate";
    545545                        if (oper_fx_list[i]->mutate(g, f1, m) != GENOPER_NOOPER) l += " mutate";
    546546                        if (oper_fx_list[i]->crossOver(g, g2, f1, f2) != GENOPER_NOOPER) l += " crossover";
Note: See TracChangeset for help on using the changeset viewer.