Changeset 797 for cpp/frams/genetics/fL/fL_matheval.h
- Timestamp:
- 06/06/18 01:45:18 (7 years ago)
- 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 1 5 #ifndef _FL_MATHEVAL_H_ 2 6 #define _FL_MATHEVAL_H_ … … 8 12 9 13 #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 10 23 11 24 /** @name Available operators for MathEvaluation */ … … 171 184 void registerOperators(); 172 185 186 std::string originalexpression; 173 187 std::unordered_map<std::string, Operator *> operators; ///<map containing available operators for MathEvaluation 174 188 std::list<Token *> postfixlist; ///<list with tokens ordered as postfix (RPN) notation of the given string … … 176 190 std::vector<Variable *> vars; ///<vector of variables, default values are 0 177 191 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; 178 195 public: 179 196 … … 226 243 227 244 /** 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 /** 228 254 * Converts stored RPN list to infix string. 229 255 * @param result reference to variable that will hold the result … … 231 257 */ 232 258 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); 233 292 }; 234 293
Note: See TracChangeset
for help on using the changeset viewer.