Ignore:
Timestamp:
07/09/20 00:13:20 (4 years ago)
Author:
Maciej Komosinski
Message:

Building a Model from Geno now fails when Model.shape is incompatible with Geno.format; renamed enum constants for genetic formats: xxx_FORMAT => FORMAT_xxx

File:
1 edited

Legend:

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

    r977 r988  
    289289        GenoOperators *gf = getOper_f(format);
    290290        if (gf == NULL)
    291                 return Geno("", Geno::INVALID_FORMAT, "", SString::sprintf("GENOPER_NOOPER: Validate(): don't know how to handle genetic format %s", format.c_str()));
     291                return Geno("", Geno::FORMAT_INVALID, "", SString::sprintf("GENOPER_NOOPER: Validate(): don't know how to handle genetic format %s", format.c_str()));
    292292        char *g2 = strdup(geny.getGenes().c_str()); //copy for validation
    293293        int res = gf->validate(g2, geny.getName().c_str());
     
    297297                return Geno(sg2, format, geny.getName(), geny.getComment());
    298298        else
    299                 return Geno("", Geno::INVALID_FORMAT, "", SString::sprintf("GENOPER_NOOPER: validate() for format %s returned invalid value", format.c_str()));
     299                return Geno("", Geno::FORMAT_INVALID, "", SString::sprintf("GENOPER_NOOPER: validate() for format %s returned invalid value", format.c_str()));
    300300}
    301301
     
    307307        GenoOperators *gf = getOper_f(format);
    308308        if (gf == NULL)
    309                 return Geno("", Geno::INVALID_FORMAT, "", SString::sprintf("GENOPER_NOOPER: Mutate(): don't know how to handle genetic format %s", format.c_str()));
     309                return Geno("", Geno::FORMAT_INVALID, "", SString::sprintf("GENOPER_NOOPER: Mutate(): don't know how to handle genetic format %s", format.c_str()));
    310310        Geno gv = g;
    311311        bool canvalidate = true;
    312312        if (testValidity(gv, canvalidate) > 0 && canvalidate == false)
    313                 return Geno("", Geno::INVALID_FORMAT, "", "GENOPER_OPFAIL: Mutate(): cannot validate invalid source genotype");
     313                return Geno("", Geno::FORMAT_INVALID, "", "GENOPER_OPFAIL: Mutate(): cannot validate invalid source genotype");
    314314        bool ok = false;
    315315        int pcount = count;
     
    354354{
    355355        SString format = g1.getFormat();
    356         if (format != g2.getFormat()) return Geno("", Geno::INVALID_FORMAT, "", SString::sprintf("GENOPER_NOOPER: CrossOver(): does not work for parents with differing genetic formats (%s and %s)", format.c_str(), g2.getFormat().c_str()));
     356        if (format != g2.getFormat()) return Geno("", Geno::FORMAT_INVALID, "", SString::sprintf("GENOPER_NOOPER: CrossOver(): does not work for parents with differing genetic formats (%s and %s)", format.c_str(), g2.getFormat().c_str()));
    357357        GenoOperators *gf = getOper_f(format);
    358358        if (gf == NULL)
    359                 return Geno("", Geno::INVALID_FORMAT, "", SString::sprintf("GENOPER_NOOPER: CrossOver(): no operators found for genetic format %s", format.c_str()));
     359                return Geno("", Geno::FORMAT_INVALID, "", SString::sprintf("GENOPER_NOOPER: CrossOver(): no operators found for genetic format %s", format.c_str()));
    360360        Geno g1v = g1, g2v = g2;
    361361
     
    364364                bool canvalidate = true;
    365365                if (testValidity(g1v, canvalidate) > 0 && canvalidate == false)
    366                         return Geno("", Geno::INVALID_FORMAT, "", "GENOPER_OPFAIL: CrossOver(): cannot validate invalid source genotype #1");
     366                        return Geno("", Geno::FORMAT_INVALID, "", "GENOPER_OPFAIL: CrossOver(): cannot validate invalid source genotype #1");
    367367                canvalidate = true;
    368368                if (testValidity(g2v, canvalidate) > 0 && canvalidate == false)
    369                         return Geno("", Geno::INVALID_FORMAT, "", "GENOPER_OPFAIL: CrossOver(): cannot validate invalid source genotype #2");
     369                        return Geno("", Geno::FORMAT_INVALID, "", "GENOPER_OPFAIL: CrossOver(): cannot validate invalid source genotype #2");
    370370        }
    371371
     
    405405                {
    406406                        logPrintf("GenMan", "CrossOver", LOG_WARN, "Tried " GENMAN_REPEAT_FAILED_STR "x and failed: %s and %s", g1.getGenes().c_str(), g2.getGenes().c_str());
    407                         return Geno("", Geno::INVALID_FORMAT, "", "GENOPER_OPFAIL: CrossOver() tried " GENMAN_REPEAT_FAILED_STR "x and failed");
     407                        return Geno("", Geno::FORMAT_INVALID, "", "GENOPER_OPFAIL: CrossOver() tried " GENMAN_REPEAT_FAILED_STR "x and failed");
    408408                }
    409409        }
     
    428428{
    429429        SString format = G->getFormat();
    430         if (format == Geno::INVALID_FORMAT)
     430        if (format == Geno::FORMAT_INVALID)
    431431                return GENSTYLE_RGBS(64, 64, 64, 0); // gray & "valid" (unknown format so we don't know what is valid and what is not)
    432432        if ((pos = G->mapStringToGen(pos)) == -1) return GENSTYLE_COMMENT;
     
    445445{
    446446        SString format = G->getFormat();
    447         if (format == Geno::INVALID_FORMAT)
     447        if (format == Geno::FORMAT_INVALID)
    448448        {
    449449                for (unsigned int pos = 0; pos < strlen(g); pos++)
Note: See TracChangeset for help on using the changeset viewer.