Mutation
Mutation is a change to an existing value, object, data structure, state, or representation.
Optimization Algorithms: AI techniques for design, planning, and control problems
A genetic operator that randomly modifies one or more elements of a candidate solution to introduce variation into a population.
- How it is used
- Introduces random variation into genetic-algorithm offspring before fitness evaluation and survivor selection.
- How deep it goes
- Works through binary bit flips and permutation operators, including Python implementations and probability parameters, without a formal analysis of convergence.
- Examples
- Uses binary ticket-price candidates, Python bit-flip code, and inversion mutation for an eight-city traveling-salesman route.
- What you can do after
- Build it from scratch as a binary or permutation mutation operator, or apply it via pymoo’s PolynomialMutation.
Advanced Algorithms and Data Structures
Mutation is a genetic-algorithm variation operator that randomly modifies one or more parts of a candidate solution representation.
- How it is used
- Adds local variation to genetic-algorithm candidates when crossover alone cannot restore missing gene values.
- How deep it goes
- Works through bit-flip and vertex-swap implementations, then examines mutation-rate trade-offs and input modification.
- Examples
- Uses knapsack bit flips, traveling-salesperson vertex swaps, and comparisons of tour costs under different operator probabilities.
- What you can do after
- Build it from scratch with representation-specific mutations, then evaluate operator probabilities against convergence results.
Read how Advanced Algorithms and Data Structures explains mutation →
Classic Computer Science Problems in Swift: Essential techniques for practicing programmers
- How it is used
- Introduces variation among chromosome candidates in a genetic algorithm.
- How deep it goes
- Defines mutation and applies it probabilistically per individual, while leaving the specific mutation strategy to each chromosome.
- Examples
- Shows bacterial antibiotic resistance and mutations that swap genes or insert a random letter in SEND+MORE=MONEY.
- What you can do after
- Apply mutation through a chromosome’s mutate() operation, with a configurable chance for each individual per generation.
Spring Security in Action, Second Edition
A mutating operation is an application operation that changes stored data or other server-side state.
- How it is used
- Protects browser applications whose authenticated users perform operations that change server-side data.
- How deep it goes
- Explains token generation, filter enforcement, form integration, and 403 failures, while deferring broader CSRF theory.
- Examples
- Uses GET and POST hello endpoints, default form login, a product form, curl requests, and a custom token-logging filter.
- What you can do after
- Operate/configure Spring Security to protect POST forms and diagnose missing-token failures through HTTP 403 responses.
Read how Spring Security in Action, Second Edition explains mutation →
Grokking AI Algorithms, Second Edition
Mutation is an evolutionary algorithm operation that introduces small random changes into a candidate solution to create variation.
- How it is used
- Uses mutation during reproduction to vary offspring in a genetic algorithm's search.
- How deep it goes
- Defines mutation and its rate, demonstrates a binary bit flip in Python, and defers nonbinary mechanisms.
- Examples
- Demonstrates a single-gene bit flip and situates alternative approaches in Knapsack Problem variations.
- What you can do after
- Build it from scratch by flipping a randomly selected bit in a binary offspring chromosome while keeping solutions valid.
Read how Grokking AI Algorithms, Second Edition explains mutation →
Inside AI
Mutation is a genetic-algorithm operation that introduces a random modification into a candidate solution.
- How it is used
- Introduces random variation into candidate solutions during genetic-algorithm optimization.
- How deep it goes
- Defines mutation and places it in the repeated crossover-and-evaluation cycle without detailing implementation mechanics.
- Examples
- Uses delivery routes, resource allocations, scheduling methods, and school bus routing to illustrate genetic-algorithm search.
- What you can do after
- Apply it via genetic algorithms to search for new strategies among candidate solutions.
Data-Oriented Programming: Reduce software complexity
A mutation is an operation that changes the state of a system or data structure.
- How it is used
- Manages state-changing operations through immutable data versions and a controlled state-reference update.
- How deep it goes
- Explains phases, structural sharing, validation, and history, while deferring concurrent mutations.
- Examples
- Uses Git version history, hash-map updates, version diagrams, and Lodash FP's set function.
- What you can do after
- Apply it via Lodash FP to calculate immutable versions and commit validated state transitions.
Read how Data-Oriented Programming: Reduce software complexity explains mutation →
Deep Learning with Python, Third Edition
Updating an existing tensor or array object directly rather than constructing a new one.
- How it is used
- Clarifies why JAX replaces direct tensor assignment with functional updates.
- How deep it goes
- Defines in-place modification and demonstrates one indexed replacement, stopping short of broader mutation patterns.
- Examples
- Uses a three-element JAX array and replaces its first value with `at[0].set(10)`.
- What you can do after
- Apply it via JAX’s `at()` and `set()` APIs to express updates without direct assignment.
Read how Deep Learning with Python, Third Edition explains mutation →
Deep Learning with PyTorch, Second Edition
A method call that modifies an existing tensor directly rather than creating a separate result tensor.
- How it is used
- Uses mutation to modify tensors directly and clear accumulated gradients during tensor manipulation and training.
- How deep it goes
- Defines trailing-underscore notation, demonstrates zero_, and explains autograd constraints without developing mutation internals beyond training updates.
- Examples
- Demonstrates zeroing a tensor, clearing params.grad, and updating parameters in place during linear-model training.
- What you can do after
- Apply it via PyTorch tensor methods to modify values directly and reset gradients safely in a training loop.
Read how Deep Learning with PyTorch, Second Edition explains mutation →
Clojure: The Essential Reference
Mutation is the alteration of a value or variable's state after it has been established.
- How it is used
- Frames mutation as the imperative mechanism for advancing loop state and contrasts it with Clojure’s functional iteration techniques.
- How deep it goes
- Contrasts mutable counters with recur, list comprehension, and regulated side effects without developing a general mutation API.
- Examples
- Uses Java and Clojure counter loops, accumulated results, sequence iteration, and a stream-reading hash computation.
- What you can do after
- Evaluate/understand when Clojure replaces mutable loop state with recur, accumulated values, or sequence processing.
Read how Clojure: The Essential Reference explains mutation →
Get Programming: Learn to code with Python
- How it is used
- Explains how list operations change existing data without creating a replacement list.
- How deep it goes
- Works through append, insert, and extend, and notes shared changes through aliases.
- Examples
- Uses grocery lists and code that appends, inserts, and extends list elements.
- What you can do after
- Apply append, insert, and extend to change lists, and recognize changes shared through aliases.
Read how Get Programming: Learn to code with Python explains mutation →
Fast Python: High performance techniques for large datasets
- How it is used
- Reduces array-processing memory use and allocation time by modifying an existing NumPy array.
- How deep it goes
- Compares new-array and in-place multiplication, explaining temporary memory and garbage-collection costs.
- Examples
- Uses doubling an image array to contrast reassignment with in-place multiplication.
- What you can do after
- Apply in-place multiplication with NumPy to avoid creating a separate result array.
Read how Fast Python: High performance techniques for large datasets explains mutation →
Related concepts
- genetic algorithmused by · A genetic algorithm is an evolutionary optimization method that improves a population of candidate solutions through fitness-based selection and variation, often including recombination and mutation.
- crossovercontrasts with · Crossover is an evolutionary recombination technique that combines material from parent candidate solutions to produce one or more offspring.
- commithas part · A commit is an operation or record that finalizes changes or a proposed state, making it part of a system’s accepted state or history.
- data explorationequivalent to · Data exploration is the systematic examination and summarization of data to understand its structure, quality, distributions, relationships, patterns, and anomalies.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.











