Changeset 375 for cpp/frams/genetics


Ignore:
Timestamp:
04/26/15 00:59:09 (5 years ago)
Author:
Maciej Komosinski
Message:

Renamed logging functions to more intuitive and simple names

Location:
cpp/frams/genetics
Files:
7 edited

Legend:

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

    r372 r375  
    55#include "conv_f1.h"
    66#include <common/nonstd_stl.h>
    7 #include <common/hmessage.h>
     7#include <common/log.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) Hprintf("GenoConvF1","addInput",HMLV_WARN,
     65                        if (final) logPrintf("GenoConvF1","addInput",LOG_WARN,
    6666                                            "illegal neuron connection %d <- %d (ignored)",n1,n2);
    6767                        return 0;
     
    178178                else
    179179                        {
    180                         Hmessage("GenoConv_F1","grow","Illegal neuron position (ignored)",1);
     180                        logMessage("GenoConv_F1","grow",1,"Illegal neuron position (ignored)");
    181181                        g=skipNeuro(g+1);
    182182                        }
  • cpp/frams/genetics/f4/conv_f4.cpp

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

    r372 r375  
    77#include "f4_general.h"
    88#include <common/nonstd_stl.h>
    9 #include <common/hmessage.h>
     9#include <common/log.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                         Hmessage("f4_Cell", "onestep", buf, 2);
     583                        logMessage("f4_Cell", "onestep", 2, buf);
    584584                        // fix: delete it
    585585                        org->setRepairRemove(gcur->pos, gcur);
  • cpp/frams/genetics/f4/oper_f4.cpp

    r372 r375  
    88#include "oper_f4.h"
    99#include <frams/util/sstring.h>
    10 #include <common/hmessage.h>
     10#include <common/log.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) Hmessage("Geno_f4", "Constructor", "Mutation names init error", 3);
     53        if (index != F4_COUNT + F4_ADD_COUNT - 1) logMessage("Geno_f4", "Constructor", 3, "Mutation names init error");
    5454}
    5555
  • cpp/frams/genetics/genman.cpp

    r372 r375  
    66#include <frams/vm/classes/genoobj.h>
    77#include GEN_CONFIG_FILE //configuration of active genetic operators
    8 #include "common/hmessage.h"
     8#include "common/log.h"
    99#include "common/nonstd_math.h"
    1010#include "common/stl-util.h"
    11 #include <frams/mhandlers/mhandlers.h>
     11#include <frams/loggers/loggers.h>
    1212
    1313
     
    267267                if (gf->mutate(gn, chg, method) == GENOPER_OK)
    268268                {
    269                         MessageHandlerToMemory eh(MessageHandlerBase::Enable | MessageHandlerToMemory::StoreFirstMessage); //mute testValidity()
     269                        LoggerToMemory eh(LoggerBase::Enable | LoggerToMemory::StoreFirstMessage); //mute testValidity()
    270270                        Geno G(gn, gv.getFormat(), "", "");
    271271                        canvalidate = true;
     
    284284                if (!ok && (count - pcount > 100))
    285285                {
    286                         Hprintf("GenMan", "Mutate", 2, "Tried 100x and failed: %s", g.getGene().c_str());
     286                        logPrintf("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                 MessageHandlerToMemory eh(MessageHandlerBase::Enable | MessageHandlerToMemory::StoreFirstMessage); //mute testValidity()
     310                LoggerToMemory eh(LoggerBase::Enable | LoggerToMemory::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                         MessageHandlerToMemory eh(MessageHandlerBase::Enable | MessageHandlerToMemory::StoreFirstMessage); //mute testValidity()
     335                        LoggerToMemory eh(LoggerBase::Enable | LoggerToMemory::StoreFirstMessage); //mute testValidity()
    336336                        Geno G(gn, g1v.getFormat(), "", "");
    337337                        bool canvalidate = true;
     
    351351                if (!ok && (count - pcount > 100))
    352352                {
    353                         Hprintf("GenMan", "CrossOver", 2, "Tried 100x and failed: %s and %s", g1.getGene().c_str(), g2.getGene().c_str());
     353                        logPrintf("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         //Hprintf("GenMan","saveLink",0,"#%d: [%d] '%s' + '%s' -> '%s'",GenoLinkList.size(),count,parent1.c_str(),parent2.c_str(),child.c_str());
     502        //logPrintf("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         Hmessage("GenMan", "Report", "The following genetic operators are available:", 0);
     535        logMessage("GenMan", "Report", 0, "The following genetic operators are available:");
    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                 Hprintf("GenMan", "Report", 0, "format f%c (%s):%s",
     551                logPrintf("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

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

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