Ignore:
Timestamp:
03/25/14 03:22:37 (6 years ago)
Author:
Maciej Komosinski
Message:

Updated f4 sources and made f4 available for GDK demo apps

Location:
cpp/frams/genetics/f4
Files:
1 added
1 moved

Legend:

Unmodified
Added
Removed
  • cpp/frams/genetics/f4/oper_f4.h

    r193 r196  
    1 /*
    2  *  geno_f4.h - f4 genetic operators.
    3  *
    4  *  f4genotype - f4 format genotype conversions for FramSticks
    5  *
    6  *  Copyright (C) 1999,2000  Adam Rotaru-Varga (adam_rotaru@yahoo.com)
    7  *  Copyright (C) 2001-2004  Maciej Komosinski
    8  *
    9  *  This library is free software; you can redistribute it and/or
    10  *  modify it under the terms of the GNU Lesser General Public
    11  *  License as published by the Free Software Foundation; either
    12  *  version 2.1 of the License, or (at your option) any later version.
    13  *
    14  *  This library is distributed in the hope that it will be useful,
    15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    17  *  Lesser General Public License for more details.
    18  *
    19  *  You should have received a copy of the GNU Lesser General Public
    20  *  License along with this library; if not, write to the Free Software
    21  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    22  *
    23  */
     1// This file is a part of the Framsticks GDK.
     2// Copyright (C) 2002-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
     3// Refer to http://www.framsticks.com/ for further information.
     4
     5// Copyright (C) 1999,2000  Adam Rotaru-Varga (adam_rotaru@yahoo.com), GNU LGPL
     6// Copyright (C) since 2001 Maciej Komosinski
    247
    258#ifndef _GENO_F4_H_
    269#define _GENO_F4_H_
    2710
     11#include <stdio.h>
    2812#include "f4_general.h"
    29 #include "nonstd.h"
    30 #include <stdio.h>
    31 #include "geno_fx.h"
    32 #include "param.h"
     13#include "common/nonstd.h"
     14#include "../oper_fx.h"
     15#include <frams/param/param.h>
    3316
    3417
     
    4629
    4730
    48 class Geno_f4: public Geno_fx
     31class Geno_f4 : public GenoOperators
    4932{
    5033public:
    51   Geno_f4();
    52   int validate(char *&);
    53   int checkValidity(const char *);
    54   int mutate(char *& g, float & chg,int &method);
    55   int crossOver(char *&g1, char *&g2, float& chg1, float& chg2);
    56   char* getSimplest() {return "X";};
    57   unsigned long style(const char *g, int pos);
     34        Geno_f4();
     35        int validate(char *&);
     36        int checkValidity(const char *);
     37        int mutate(char *& g, float & chg, int &method);
     38        int crossOver(char *&g1, char *&g2, float& chg1, float& chg2);
     39        const char* getSimplest() { return "X"; }
     40        unsigned long style(const char *g, int pos);
    5841
    59   // mutation probabilities
    60   double prob[F4_COUNT],probadd[F4_ADD_COUNT];
     42        // mutation probabilities
     43        double prob[F4_COUNT], probadd[F4_ADD_COUNT];
    6144
    6245protected:
    63   /* int MutateMany(char *& g, float & chg); // not used any more */
    64   int  ValidateRec(f4_node * geno, int retrycount) const;
    65   int  MutateOne(f4_node *& g,int &method) const;
    66   void linkNodeMakeRandom(f4_node * nn) const;
    67   void linkNodeChangeRandom(f4_node * nn) const;
    68   void nparNodeMakeRandom(f4_node * nn) const;
    69   void repeatNodeChangeRandom(f4_node * nn) const;
    70   int  MutateOneValid(f4_node * &g,int &method) const;
    71   int  CrossOverOne(f4_node *g1, f4_node *g2, float chg) const;
    72     // returns GENOPER_OK or GENOPER_OPFAIL
    73     // chg: fraction of parent1 genes in child (in g1) (parent2 has the rest)
     46        /* int MutateMany(char *& g, float & chg); // not used anymore */
     47        int  ValidateRec(f4_node * geno, int retrycount) const;
     48        int  MutateOne(f4_node *& g, int &method) const;
     49        void linkNodeMakeRandom(f4_node * nn) const;
     50        void linkNodeChangeRandom(f4_node * nn) const;
     51        void nparNodeMakeRandom(f4_node * nn) const;
     52        void repeatNodeChangeRandom(f4_node * nn) const;
     53        int  MutateOneValid(f4_node * &g, int &method) const;
     54        int  CrossOverOne(f4_node *g1, f4_node *g2, float chg) const;
     55        // returns GENOPER_OK or GENOPER_OPFAIL
     56        // chg: fraction of parent1 genes in child (in g1) (parent2 has the rest)
    7457};
    7558
Note: See TracChangeset for help on using the changeset viewer.