<commit_before>package operators

import (
	"math/rand"

	"github.com/aurelien-rainone/evolve/bitstring"
	"github.com/aurelien-rainone/evolve/framework"
	"github.com/aurelien-rainone/evolve/number"
)

// NewBitStringMutation creates an evolutionary operator that mutates individual
// bits in a bitstring.BitString according to some probability.
//
// Possible options:
// - the mutation probability is the (possibly variable) probability of a
// candidate bit string being mutated at all; set it with ConstantProbability or
// VariableProbability. The default is a constant probability of 1.
// - the mutation count is the (possibly variable) number of bits that will be
// flipped on any candidate bit string that is selected for mutation; set it
// with ConstantMutationCount or VariableMutationCount. The default is a
// constant mutation count of exactly 1 bit flipped.
func NewBitStringMutation(options ...Option) (*AbstractMutation, error) {
	// set default mutation count to 1
	mutater := &bitStringMutater{
		mutationCount: number.NewConstantIntegerGenerator(1),
	}
	// set default mutation probability to 1, this option is prepended to the
	// client slice of options, so it will be applied before and remains as
	// default if ever it's not overwritten by subsequent (in the slice)
	// options.
	impl, err := NewAbstractMutation(
		mutater,
		append([]Option{ConstantProbability(number.ProbabilityOne)}, options...)...,
	)
	// in the current case the actual mutater needs the abstract mutation
	// implementation back in order to access the mutation probability.
	mutater.impl = impl
	return impl, err
}

type bitStringMutater struct {<commit_msg>GoDoc: remove code blocks for arguments doc<commit_after>package operators

import (
	"math/rand"

	"github.com/aurelien-rainone/evolve/bitstring"
	"github.com/aurelien-rainone/evolve/framework"
	"github.com/aurelien-rainone/evolve/number"
)

// NewBitStringMutation creates an evolutionary operator that mutates individual
// bits in a bitstring.BitString according to some probability.
//
// Possible options:
// the mutation probability is the (possibly variable) probability of a
// candidate bit string being mutated at all; set it with ConstantProbability or
// VariableProbability. The default is a constant probability of 1.
// the mutation count is the (possibly variable) number of bits that will be
// flipped on any candidate bit string that is selected for mutation; set it
// with ConstantMutationCount or VariableMutationCount. The default is a
// constant mutation count of exactly 1 bit flipped.
func NewBitStringMutation(options ...Option) (*AbstractMutation, error) {
	// set default mutation count to 1
	mutater := &bitStringMutater{
		mutationCount: number.NewConstantIntegerGenerator(1),
	}
	// set default mutation probability to 1, this option is prepended to the
	// client slice of options, so it will be applied before and remains as
	// default if ever it's not overwritten by subsequent (in the slice)
	// options.
	impl, err := NewAbstractMutation(
		mutater,
		append([]Option{ConstantProbability(number.ProbabilityOne)}, options...)...,
	)
	// in the current case the actual mutater needs the abstract mutation
	// implementation back in order to access the mutation probability.
	mutater.impl = impl
	return impl, err
}

type bitStringMutater struct {
{'fraction_non_alphanumeric': 0.08049072411729503, 'fraction_numerical': 0.002992220227408737, 'mean_word_length': 4.297939778129953, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7225549', 'n_tokens_mistral': 949, 'n_tokens_neox': 882, 'n_words': 374}