Changeset 732 for cpp/frams/vm/classes


Ignore:
Timestamp:
02/15/18 00:42:07 (7 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.

Location:
cpp/frams/vm/classes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/vm/classes/genoobj.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
     
    1111ParamEntry geno_paramtab[] =
    1212{
    13         { "Geno", 1, 15, "Geno", "All information about a single genotype.\nThis is a genetics-only object which does not contain any performance data. See also: Genotype class" },
     13        { "Geno", 1, 16, "Geno", "All information about a single genotype.\nThis is a genetics-only object which does not contain any performance data. See also: Genotype class" },
    1414        { "name", 0, PARAM_NOSTATIC, "Name", "s 0 40", GETSET(name), },
    1515        { "rawgenotype", 0, PARAM_NOSTATIC | PARAM_READONLY, "Raw genotype", "s 1", GETONLY(genotype), "Genotype, excluding the format specifier" },
     
    2323        "-1 = validity is not known. This is a transient state. The value of \"is_valid\" will never be -1 when read. It is safe to treat is_valid as boolean in statements like \"if (g.is_valid) ...\". Setting \"is_valid=-1\" will make it 0 or 1 again. This third state (-1) is only needed for loading Genotype objects from files where the \"is_valid\" field might not be present."
    2424        },
    25         { "getConverted", 0, PARAM_NOSTATIC, "get converted genotype", "p oGeno(s format)", PROCEDURE(p_getconvert), },
     25        { "getConverted", 0, PARAM_NOSTATIC, "Get converted genotype", "p oGeno(s format)", PROCEDURE(p_getconvert), },
     26        { "getConvertedWithCheckpoints", 0, PARAM_NOSTATIC, "Get converted genotype", "p oGeno(s format)", PROCEDURE(p_getconvert_ch), "See also Model.newWithCheckpoints()" },
    2627        { "f0genotype", 0, PARAM_NOSTATIC | PARAM_READONLY, "f0 genotype", "s 1", GETONLY(f0genotype), "converted to f0 genotype", },
    2728        { "new", 0, 0, "create new empty object", "p oGeno()", PROCEDURE(p_new), },
     
    8586void GenoObj::get_format(ExtValue *ret)
    8687{
    87         char format_as_string[2]={getFormat(),0};
     88        char format_as_string[2] = { getFormat(), 0 };
    8889        ret->setString(format_as_string);
    8990}
     
    102103char GenoObj::formatFromExtValue(ExtValue& v)
    103104{
    104 if (v.getType()==TInt)
    105         return v.getInt();
    106 if (v.getType()==TString)
     105        if (v.getType() == TInt)
     106                return v.getInt();
     107        if (v.getType() == TString)
    107108        {
    108         SString s=v.getString();
    109         if (s.len()==1)
    110                 return s.charAt(0);
     109                SString s = v.getString();
     110                if (s.len() == 1)
     111                        return s.charAt(0);
    111112        }
    112 return Geno::INVALID_FORMAT;
     113        return Geno::INVALID_FORMAT;
    113114}
    114115
     
    116117{
    117118        *ret = makeDynamicObjectAndDecRef(new Geno(getConverted(formatFromExtValue(args[0]))));
     119}
     120
     121void GenoObj::p_getconvert_ch(ExtValue *args, ExtValue *ret)
     122{
     123        *ret = makeDynamicObjectAndDecRef(new Geno(getConverted(formatFromExtValue(args[0]), NULL, true)));
    118124}
    119125
  • cpp/frams/vm/classes/genoobj.h

    r516 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
     
    2525        PARAMGETDEF(string);
    2626        PARAMPROCDEF(p_getconvert);
     27        PARAMPROCDEF(p_getconvert_ch);
    2728        PARAMGETDEF(f0genotype);
    2829        PARAMPROCDEF(p_new);
Note: See TracChangeset for help on using the changeset viewer.