Changeset 896 for cpp/frams/genetics/fL/fL_matheval.cpp
- Timestamp:
- 11/30/19 01:30:22 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/fL/fL_matheval.cpp
r821 r896 613 613 void MathEvaluation::mutateValueOrVariable(MathEvaluation::Number *&currval, bool usetime) 614 614 { 615 if (r andomN(2) == 0 && varcount > 0) // use variable615 if (rndUint(2) == 0 && varcount > 0) // use variable 616 616 { 617 617 if (currval && currval->type == TokenType::NUMBER) … … 619 619 delete currval; 620 620 } 621 int var = r andomN(varcount + (usetime ? 1 : 0));621 int var = rndUint(varcount + (usetime ? 1 : 0)); 622 622 if (varcount == var) // time is used 623 623 { … … 633 633 if (!currval || currval->type == TokenType::VARIABLE) 634 634 { 635 currval = new Number(rnd 01);635 currval = new Number(rndDouble(1)); 636 636 } 637 637 else 638 638 { 639 currval->value = rnd 01;639 currval->value = rndDouble(1); 640 640 } 641 641 } … … 654 654 count = operatorstrings.size() - arithmeticoperatorscount; 655 655 } 656 randop += r andomN(count);656 randop += rndUint(count); 657 657 return operators[operatorstrings[randop]]; 658 658 } … … 663 663 { 664 664 int currsize = postfixlist.size(); 665 int varid = r andomN(varcount);665 int varid = rndUint(varcount); 666 666 postfixlist.push_back(vars[varid]); 667 if (r andomN(2) == 0 && varcount > 1)668 { 669 int varid2 = r andomN(varcount - 1);667 if (rndUint(2) == 0 && varcount > 1) 668 { 669 int varid2 = rndUint(varcount - 1); 670 670 if (varid2 >= varid) varid2++; 671 671 postfixlist.push_back(vars[varid2]); … … 673 673 else 674 674 { 675 Number *num = new Number(rnd 01);675 Number *num = new Number(rndDouble(1)); 676 676 postfixlist.push_back(num); 677 677 } 678 int opid = arithmeticoperatorscount + r andomN(comparisonoperatorscount);678 int opid = arithmeticoperatorscount + rndUint(comparisonoperatorscount); 679 679 postfixlist.push_back(operators[operatorstrings[opid]]); 680 680 if (currsize > 0) … … 689 689 if (postfixlist.size() == 0) 690 690 { 691 Number *val = new Number(rnd 01);691 Number *val = new Number(rndDouble(1)); 692 692 postfixlist.push_back(val); 693 693 return -1; 694 694 } 695 int method = r andomN(postfixlist.size() < MAX_MUT_FORMULA_SIZE ? MATH_MUT_COUNT : MATH_MUT_COUNT - 1);695 int method = rndUint(postfixlist.size() < MAX_MUT_FORMULA_SIZE ? MATH_MUT_COUNT : MATH_MUT_COUNT - 1); 696 696 switch (method) 697 697 { … … 704 704 std::list<Token *>::iterator it = postfixlist.begin(); 705 705 // insertion can be applied from 1st occurrence 706 int insertlocation = 1 + r andomN(postfixlist.size() - 1);706 int insertlocation = 1 + rndUint(postfixlist.size() - 1); 707 707 std::advance(it, insertlocation); 708 708 Operator *rndop; … … 732 732 id++; 733 733 } 734 int randid = r andomN(numbersineval.size());734 int randid = rndUint(numbersineval.size()); 735 735 Number *numptr = (Number *)(*numbersineval[randid]); 736 736 mutateValueOrVariable(numptr, usetime); … … 750 750 if (ops.size() > 0) 751 751 { 752 int randid = r andomN(ops.size());752 int randid = rndUint(ops.size()); 753 753 Operator *rndop; 754 754 if (randid == (int)ops.size() - 1) … … 783 783 if (firstofpairs.size() > 0) 784 784 { 785 int rndid = r andomN(firstofpairs.size());785 int rndid = rndUint(firstofpairs.size()); 786 786 if ((*firstofpairs[rndid])->type == TokenType::NUMBER) 787 787 {
Note: See TracChangeset
for help on using the changeset viewer.