Ignore:
Timestamp:
02/15/18 00:42:07 (6 years ago)
Author:
Maciej Komosinski
Message:

Added support for "checkpoints" (intermediate phases of development of the Model when converting between genetic encodings). See Model.checkpoint() and conv_f1.cpp for an example.

File:
1 edited

Legend:

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

    r534 r732  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2018  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    3232        name = genname;
    3333        txt = comment;
    34         setGenesAndFormat(genstring,genformat);
     34        setGenesAndFormat(genstring, genformat);
    3535}
    3636
     
    5454                                        mapinshift = end + 1;
    5555                                        gencopy = genstring.substr(end + 1);
    56                                         if ((end>0) && (genstring[end-1]=='\r')) end--;
     56                                        if ((end > 0) && (genstring[end - 1] == '\r')) end--;
    5757                                        error_end = end;
    5858                                        if (end != 3) genformat = INVALID_FORMAT;
     
    8282                                break;
    8383                        }
    84                         if (!isalnum(genformat)) genformat=INVALID_FORMAT;
     84                        if (!isalnum(genformat)) genformat = INVALID_FORMAT;
    8585                        if (genformat == INVALID_FORMAT)
    8686                        {
     
    9393                                        cut = genstring.substr(0, error_end);
    9494                                int lf = cut.indexOf('\n');
    95                                 if (lf >= 0) { if ((lf>0)&&(cut[lf-1]=='\r')) lf--; cut = cut.substr(0, lf); }
     95                                if (lf >= 0) { if ((lf > 0) && (cut[lf - 1] == '\r')) lf--; cut = cut.substr(0, lf); }
    9696                                sstringQuote(cut);
    9797                                logPrintf("Geno", "init", LOG_ERROR, "Invalid genotype format declaration: '%s'%s", cut.c_str(), name.len() ? SString::sprintf(" in '%s'", name.c_str()).c_str() : "");
     
    226226        {
    227227                bool converter_missing;
    228                 Geno f0geno = g.getConverted('0', NULL, &converter_missing);
     228                Geno f0geno = g.getConverted('0', NULL, false, &converter_missing);
    229229                if (converter_missing)
    230230                        return -1;//no result
     
    295295}
    296296
    297 Geno Geno::getConverted(char otherformat, MultiMap *m, bool *converter_missing)
     297Geno Geno::getConverted(char otherformat, MultiMap *m, bool using_checkpoints, bool *converter_missing)
    298298{
    299299        if (otherformat == getFormat()) { if (converter_missing) *converter_missing = false; return *this; }
     
    302302        if (converters)
    303303        {
    304                 if ((otherformat == '0') && (!m))
     304                if ((otherformat == '0') && (!m) && (!using_checkpoints))
    305305                {
    306306                        if (!f0gen)
    307                                 f0gen = new Geno(converters->convert(*this, otherformat, NULL, converter_missing));
     307                                f0gen = new Geno(converters->convert(*this, otherformat, NULL, using_checkpoints, converter_missing));
    308308                        else
    309309                        {
     
    313313                }
    314314                else
    315                         return converters->convert(*this, otherformat, m, converter_missing);
     315                        return converters->convert(*this, otherformat, m, using_checkpoints, converter_missing);
    316316        }
    317317#endif
Note: See TracChangeset for help on using the changeset viewer.