source: cpp/frams/genetics/genman.h @ 408

Last change on this file since 408 was 286, checked in by Maciej Komosinski, 10 years ago

Updated headers

  • Property svn:eol-style set to native
File size: 3.7 KB
1// This file is a part of Framsticks SDK.
2// Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
3// See LICENSE.txt for details.
5#ifndef _GENMAN_H_
6#define _GENMAN_H_
8#include <common/nonstd.h>
9#include <common/nonstd_stl.h>
10#include <frams/param/mutableparam.h>
11#include <frams/param/mutparamlist.h>
12#include <frams/neuro/geneticneuroparam.h>
13#include "geno.h"
14#include "oper_fx.h"
18struct GenoLink
20        int count;
21        string parent1, parent2, child; //parent2 only used in crossover, it is "" in mutation
22        float chg;
23        float fit;
26class GenMan : public GenoValidator
29        GenMan();
30        ~GenMan();
31        void setDefaults();
32        /**
33        if canvalidate==false, returns GENOPER_NOOPER (cannot test), GENOPER_OK (\e g is valid), or 1-based error position.
34        if canvalidate==true, returns
35        - GENOPER_OK and canvalidate==false if \e g was already valid
36        - GENOPER_NOOPER and canvalidate==false if \e g was (probably) validated but couldn't checkValidity
37        - 1-based error position and canvalidate==false if \e g was invalid and couldn't validate
38        - 1-based error position and canvalidate==true if \e g was invalid and was validated successfully
40        Note: 1-based error position is always related to pure genotype (g.GetGene()), without the leading comment
41        */
42        int testValidity(Geno &g, bool &canvalidate);
43        int testGenoValidity(Geno& g); //class GenoValidator (geno.h)
44        Geno Validate(const Geno&); ///<returns validated (if possible) genotype
45        Geno Mutate(const Geno&); //returns mutated genotype or empty if errors
46        Geno CrossOver(const Geno&, const Geno&); //returns xover genotype ("child") or empty if errors
47        float Similarity(const Geno&, const Geno&); //returns GENOPER_NOOPER or normalized similarity (1: identical, 0: different)
48        uint32_t Style(const char* g, int pos); //returns Style (and validity) of a genotype char.
49        void GetFullStyle(const char *g, uint32_t *styletab); //optimized. Fills styletab with styles for all genotype chars. sizeof(*styletab) must be at least strlen(g).
50        SString HTMLize(const char *g); //returns colored genotype in HTML.
51        SString HTMLizeShort(const char *g); //returns colored genotype (abbreviated if needed) in HTML.
52        Geno GetSimplest(char format); ///<returns pointer to the simplest genotype of \e format or empty Geno()
53        const char *GetOpName(char format); ///<returns pointer to the active operator set for \e format
54        const vector<GenoOperators*>& GetOperators() const { return oper_fx_list; } ///<returns the list of available genetic operators
56        vector<GenoOperators*> oper_fx_list;
57        void saveLink(const string parent1, const string parent2, const string child, const float chg);
58        GenoOperators* getOper_f(char format);
59        SString HTMLize(const char *g, bool shorten);
61        vector<GenoLink> GenoLinkList;
62        int history; //remember history?
63        int hilite; //syntax highlighting (Style)
64        int extmutinfo; //extended info: the info field of the genotype will contain the name of the mutation method
65        int count; //# of the last genetic operation
66        int valid_m, valid_xo, validated_m, validated_xo, invalid_m, invalid_xo, failed_m, failed_xo;
67        double mutchg, xochg;
68        SListTempl<char> operformats; //the list of supported_format, in the same order as in seloperpar
69        int* seloper; //fields for seloperpar
70        Param localpar, localstats;
71        MutableParam seloperpar;
72        GeneticNeuroParam neuronsparam;
73        MutableParamList par;
74#define STATRICKCLASS GenMan
75        PARAMPROCDEF(p_clearStats);
76        PARAMPROCDEF(p_report);
77        PARAMPROCDEF(p_htmlize);
78        PARAMPROCDEF(p_htmlizeshort);
79        PARAMPROCDEF(p_validate);
80        PARAMPROCDEF(p_mutate);
81        PARAMPROCDEF(p_crossover);
82        PARAMPROCDEF(p_getsimplest);
84        void clearStats();
85        static void onDelGen(void*, intptr_t);
Note: See TracBrowser for help on using the repository browser.