Ignore:
Timestamp:
06/06/18 01:45:18 (6 years ago)
Author:
Maciej Komosinski
Message:

A more complete implementation of fB, fH, fL

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/genetics/fL/fL_matheval.h

    r780 r797  
     1// This file is a part of Framsticks SDK.  http://www.framsticks.com/
     2// Copyright (C) 1999-2018  Maciej Komosinski and Szymon Ulatowski.
     3// See LICENSE.txt for details.
     4
    15#ifndef _FL_MATHEVAL_H_
    26#define _FL_MATHEVAL_H_
     
    812
    913#define VARIABLEPREFIX '$'
     14
     15#define MATH_MUT_DELETION   0
     16#define MATH_MUT_CHANGEVAL  1
     17#define MATH_MUT_CHANGEOPER 2
     18#define MATH_MUT_INSERTION  3
     19#define MATH_MUT_COUNT      4
     20
     21#define MAX_MUT_FORMULA_SIZE 7
     22#define XOVER_MAX_MIGRATED_RULES 3
    1023
    1124/** @name Available operators for MathEvaluation */
     
    171184        void registerOperators();
    172185
     186        std::string originalexpression;
    173187        std::unordered_map<std::string, Operator *> operators; ///<map containing available operators for MathEvaluation
    174188        std::list<Token *> postfixlist; ///<list with tokens ordered as postfix (RPN) notation of the given string
     
    176190        std::vector<Variable *> vars; ///<vector of variables, default values are 0
    177191        Variable *t; ///<additional t variable, that can act as time for evaluation
     192        std::vector<std::string> operatorstrings; ///<list of registered operators
     193        int arithmeticoperatorscount; ///<count of arithmetic operators
     194        int comparisonoperatorscount;
    178195public:
    179196
     
    226243
    227244        /**
     245         * Registers new operator for MathEvaluation object.
     246         * @param operation function that needs to be called during evaluation
     247         * @param precedence precedence of operator
     248         * @param assoc associativity of the operator
     249         * @param opsymbol symbol of the operator
     250         */
     251        void registerOperator(double(*operation)(double left, double right), int precedence, MathEvaluation::Associativity assoc, std::string opsymbol);
     252
     253        /**
    228254         * Converts stored RPN list to infix string.
    229255         * @param result reference to variable that will hold the result
     
    231257         */
    232258        int RPNToInfix(std::string &result);
     259
     260        /**
     261         * Mutates formula.
     262         * @param logical if true, method uses logical operators only
     263         * @param usetime if true, method may use time variable during mutation
     264         * @param 0 if mutation could be performed, -1 if postfixlist is empty
     265         */
     266        int mutate(bool logical, bool usetime);
     267
     268        /**
     269         * Mutates formula so it creates conjuctive of comparisons.
     270         */
     271        void mutateConditional();
     272
     273        /**
     274         * Mutates number by using random value or one of variables.
     275         * @param currval current value of number
     276         * @param usetime if true, then time variable may be used
     277         */
     278        void mutateValueOrVariable(Number *&currval, bool usetime);
     279
     280        /**
     281         * Returns formula in RPN notation
     282         * @param RPN notation string
     283         */
     284        std::string getStringifiedRPN();
     285
     286        /**
     287         * Returns random operator available in object.
     288         * @param type 0 for all operators, 1 for arithmetic only, 2 for logical only
     289         * @return pointer to random operator
     290         */
     291        Operator* getRandomOperator(int type);
    233292};
    234293
Note: See TracChangeset for help on using the changeset viewer.