123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- /*
- * Copyright (C) 2020,2023 Weber Yann
- *
- * This file is part of pyrpn.
- *
- * pyrpn is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * pyrpn is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with pyrpn. If not, see <http://www.gnu.org/licenses/>.
- */
-
- #include "rpn_if_mutate.h"
-
-
- int if_mutation(rpn_if_t *rif, rnd_t *weights, size_t n_mut,
- rpn_mutation_params_t *mut_params)
- {
- for(size_t i=0; i<n_mut; i++)
- {
- size_t rpn_num;
- if(_rpn_random_choice(rif->params->rpn_sz, weights,
- &rpn_num) < 0)
- {
- return -1;
- }
- if(rpn_mutation(&(rif->rpn[rpn_num].toks),
- mut_params) < 0)
- {
- return -1;
- }
- }
- for(size_t i=0; i<rif->params->rpn_sz; i++)
- {
- rpn_expr_tokens_updated(&(rif->rpn[i]));
- }
- return 0;
- }
|