Changeset 372 for cpp/frams/genetics


Ignore:
Timestamp:
04/22/15 04:14:59 (10 years ago)
Author:
sz
Message:

Renamed some classes and functions to make their purpose more obvious:

All MessageHandlers? must now be given the explicit "Enable" argument if you want them to automatically become active. This makes side effects clearly visible.

Location:
cpp/frams/genetics
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/genetics/f1/conv_f1.cpp

    r348 r372  
    55#include "conv_f1.h"
    66#include <common/nonstd_stl.h>
    7 #include <common/framsg.h>
     7#include <common/hmessage.h>
    88#include <frams/util/multirange.h>
    99#include <frams/util/multimap.h>
     
    6363                if ((n1<0) || (n2<0) || (n1>=neuro_f1_to_f0.size()) || (n2>=neuro_f1_to_f0.size()))
    6464                        {
    65                         if (final) FMprintf("GenoConvF1","addInput",FMLV_WARN,
     65                        if (final) Hprintf("GenoConvF1","addInput",HMLV_WARN,
    6666                                            "illegal neuron connection %d <- %d (ignored)",n1,n2);
    6767                        return 0;
     
    178178                else
    179179                        {
    180                         FramMessage("GenoConv_F1","grow","Illegal neuron position (ignored)",1);
     180                        Hmessage("GenoConv_F1","grow","Illegal neuron position (ignored)",1);
    181181                        g=skipNeuro(g+1);
    182182                        }
  • cpp/frams/genetics/f4/conv_f4.cpp

    r287 r372  
    66
    77#include "conv_f4.h"
    8 #include <common/framsg.h>
     8#include <common/hmessage.h>
    99#include "../oper_fx.h" //for GENOPER_OK constant
    1010
     
    110110                if (res)
    111111                {
    112                         FramMessage("f4_Model", "buildModelRec", "Error in building Model", 2);
     112                        Hmessage("f4_Model", "buildModelRec", "Error in building Model", 2);
    113113                        error = res;
    114114                        break;
     
    134134                        return cells->C[i];
    135135        // none!
    136         FramMessage("f4_Model", "getStick", "Not a single stick", 2);
     136        Hmessage("f4_Model", "getStick", "Not a single stick", 2);
    137137        return NULL;
    138138}
  • cpp/frams/genetics/f4/f4_general.cpp

    r348 r372  
    77#include "f4_general.h"
    88#include <common/nonstd_stl.h>
    9 #include <common/framsg.h>
     9#include <common/hmessage.h>
    1010#include <frams/model/model.h> // for min and max attributes
    1111#include "../oper_fx.h" //for GENOPER_ constants
     
    581581                        char buf[40];
    582582                        sprintf(buf, "unknown code '%c'", gcur->name);
    583                         FramMessage("f4_Cell", "onestep", buf, 2);
     583                        Hmessage("f4_Cell", "onestep", buf, 2);
    584584                        // fix: delete it
    585585                        org->setRepairRemove(gcur->pos, gcur);
  • cpp/frams/genetics/f4/oper_f4.cpp

    r286 r372  
    88#include "oper_f4.h"
    99#include <frams/util/sstring.h>
    10 #include <common/framsg.h>
     10#include <common/hmessage.h>
    1111
    1212#include <stdio.h>
     
    5151        mutation_method_names[index++] = "deleted a node";
    5252        mutation_method_names[index++] = "modified a node";
    53         if (index != F4_COUNT + F4_ADD_COUNT - 1) FramMessage("Geno_f4", "Constructor", "Mutation names init error", 3);
     53        if (index != F4_COUNT + F4_ADD_COUNT - 1) Hmessage("Geno_f4", "Constructor", "Mutation names init error", 3);
    5454}
    5555
  • cpp/frams/genetics/genman.cpp

    r348 r372  
    66#include <frams/vm/classes/genoobj.h>
    77#include GEN_CONFIG_FILE //configuration of active genetic operators
    8 #include "common/framsg.h"
     8#include "common/hmessage.h"
    99#include "common/nonstd_math.h"
    1010#include "common/stl-util.h"
    11 #include <frams/errmgr/errmanager.h>
     11#include <frams/mhandlers/mhandlers.h>
    1212
    1313
     
    267267                if (gf->mutate(gn, chg, method) == GENOPER_OK)
    268268                {
    269                         ErrorHandler eh(ErrorHandler::StoreFirstMessage); //mute testValidity()
     269                        MessageHandlerToMemory eh(MessageHandlerBase::Enable | MessageHandlerToMemory::StoreFirstMessage); //mute testValidity()
    270270                        Geno G(gn, gv.getFormat(), "", "");
    271271                        canvalidate = true;
     
    284284                if (!ok && (count - pcount > 100))
    285285                {
    286                         FMprintf("GenMan", "Mutate", 2, "Tried 100x and failed: %s", g.getGene().c_str());
     286                        Hprintf("GenMan", "Mutate", 2, "Tried 100x and failed: %s", g.getGene().c_str());
    287287                        return Geno("", -1, "", "GENOPER_OPFAIL: Mutate() tried 100x and failed");
    288288                }
     
    308308
    309309        {
    310                 ErrorHandler eh(ErrorHandler::StoreFirstMessage); //mute testValidity()
     310                MessageHandlerToMemory eh(MessageHandlerBase::Enable | MessageHandlerToMemory::StoreFirstMessage); //mute testValidity()
    311311                bool canvalidate = true;
    312312                if (testValidity(g1v, canvalidate) > 0 && canvalidate == false)
     
    333333                        if (g1n[0]) { gn = g1n; chg = chg1; }
    334334                        else { gn = g2n; chg = chg2; }
    335                         ErrorHandler eh(ErrorHandler::StoreFirstMessage); //mute testValidity()
     335                        MessageHandlerToMemory eh(MessageHandlerBase::Enable | MessageHandlerToMemory::StoreFirstMessage); //mute testValidity()
    336336                        Geno G(gn, g1v.getFormat(), "", "");
    337337                        bool canvalidate = true;
     
    351351                if (!ok && (count - pcount > 100))
    352352                {
    353                         FMprintf("GenMan", "CrossOver", 2, "Tried 100x and failed: %s and %s", g1.getGene().c_str(), g2.getGene().c_str());
     353                        Hprintf("GenMan", "CrossOver", 2, "Tried 100x and failed: %s and %s", g1.getGene().c_str(), g2.getGene().c_str());
    354354                        return Geno("", -1, "", "GENOPER_OPFAIL: CrossOver() tried 100x and failed");
    355355                }
     
    500500        l.chg = chg;
    501501        l.fit = 0; //temporarily. Will be set when the genotype dies
    502         //FMprintf("GenMan","saveLink",0,"#%d: [%d] '%s' + '%s' -> '%s'",GenoLinkList.size(),count,parent1.c_str(),parent2.c_str(),child.c_str());
     502        //Hprintf("GenMan","saveLink",0,"#%d: [%d] '%s' + '%s' -> '%s'",GenoLinkList.size(),count,parent1.c_str(),parent2.c_str(),child.c_str());
    503503        GenoLinkList.push_back(l);
    504504}
     
    533533        float f1, f2;
    534534        int m;
    535         FramMessage("GenMan", "Report", "The following genetic operators are available:", 0);
     535        Hmessage("GenMan", "Report", "The following genetic operators are available:", 0);
    536536        for (unsigned int i = 0; i < oper_fx_list.size(); i++)
    537537        {
     
    549549                }
    550550                //      if (oper_fx_list[i]->similarity("","")!=GENOPER_NOOPER) l+=" similarity";
    551                 FMprintf("GenMan", "Report", 0, "format f%c (%s):%s",
     551                Hprintf("GenMan", "Report", 0, "format f%c (%s):%s",
    552552                        oper_fx_list[i]->supported_format, oper_fx_list[i]->name.c_str(), l.c_str());
    553553        }
  • cpp/frams/genetics/geno.cpp

    r348 r372  
    250250                }
    251251        isvalid = 0;
    252         FMprintf("Geno", "validate", FMLV_WARN, "Wrong configuration? No genotype validators defined for genetic format f%c.", format);
     252        Hprintf("Geno", "validate", HMLV_WARN, "Wrong configuration? No genotype validators defined for genetic format f%c.", format);
    253253}
    254254
  • cpp/frams/genetics/oper_fx.cpp

    r348 r372  
    55#include <ctype.h>  //isupper()
    66#include "oper_fx.h"
    7 #include <common/framsg.h>
     7#include <common/hmessage.h>
    88#include <common/nonstd_math.h>
    99#include <frams/util/rndutil.h>
     
    173173                }
    174174                else
    175                         FMprintf("GenoOperators", "linearMix", FMLV_WARN, "Cannot mix values of types '%c' and '%c'", type1, type2);
     175                        Hprintf("GenoOperators", "linearMix", HMLV_WARN, "Cannot mix values of types '%c' and '%c'", type1, type2);
    176176}
    177177
     
    250250{
    251251        if (s == NULL)
    252                 FramMessage("GenoOperators", "skipWS", "NULL reference!", FMLV_WARN);
     252                Hmessage("GenoOperators", "skipWS", "NULL reference!", HMLV_WARN);
    253253        else
    254254        while (isWS(*s)) s++;
Note: See TracChangeset for help on using the changeset viewer.