Mutation
Mutation is a change to an existing entity, such as a value, state, data structure, or candidate 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 variation into genetic algorithm populations alongside crossover and fitness-based selection.
- How deep it goes
- Explains binary bit flipping and four permutation mutations, with Python implementations and probability controls.
- Examples
- Uses binary ticket prices and traveling-salesman routes to illustrate bit flipping and permutation mutations.
- What you can do after
- Builds binary bit-flip and permutation-inversion mutation operators from scratch and configures polynomial mutation in pymoo.
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 →
Data-Oriented Programming in Java
Mutation is the modification of an existing program value or state in place.
- How it is used
- Frames mutation as a design choice when modeling identity, refactoring legacy state, and expressing data transformations.
- How deep it goes
- Contrasts state timelines, scoped implementation mutation, and algebraic replacements without prescribing mutation’s elimination.
- Examples
- Uses a tossed ball’s state frames, duplicate-record grouping, and a shopping cart balancing routine.
- What you can do after
- Evaluate/understand when mutation is safely scoped and when immutable combination better exposes intended transformations.
Read how Data-Oriented Programming in Java 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
- Introduces variation into offspring during evolutionary search to help prevent stagnation at local best solutions.
- How deep it goes
- Explains mutation rates and a binary bit-flip procedure, while deferring nonbinary mechanisms.
- Examples
- Illustrates mutation by randomly selecting and flipping a gene in a binary chromosome.
- What you can do after
- Apply it by flipping a randomly selected bit in a binary chromosome and considering the mutation rate.
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
- Uses in-place array mutation to reduce memory use and time spent creating temporary arrays.
- How deep it goes
- Compares in-place and allocating multiplication, explaining temporary memory and initialization costs.
- Examples
- Demonstrates doubling an array with `x = x * 2` and `x *= 2`.
- What you can do after
- Apply NumPy in-place multiplication to avoid creating a result array when possible.
Read how Fast Python: High performance techniques for large datasets explains mutation →
Also covered in
- Quantum Programming in Depth
- Tiny Python Projects: Learn coding and testing with puzzles and games
- Machine Learning Algorithms in Depth
- 100 Java Mistakes and How to Avoid Them
- Code Like a Pro in Rust
- Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu
- Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond
- Functional Programming in Scala, Second Edition
- The Art of Code
- The Quick Python Book, Fourth Edition
- Python How-To
What to know first
- functionA function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
- stateState is information describing the condition or configuration of a system or computation at a particular time that may influence its behavior or subsequent transitions.
- arrayAn array is an ordered collection of elements organized in one or more dimensions and accessible by position or index.
- chromosomeA chromosome is an encoded representation of a candidate solution in an evolutionary algorithm, composed of genes or other solution components.
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.
- boundary mutationincludes · Boundary mutation is an evolutionary operation that replaces a selected gene with a value constrained by its permitted lower and upper bounds.
- calculation phasehas part · The calculation phase is the phase of a mutation that computes the next version of system data without advancing the current state.
Questions about mutation
What is mutation?
Mutation is a change to an existing entity, such as a value, state, data structure, or candidate representation.
Which Manning books explain mutation?
Optimization Algorithms: AI techniques for design, planning, and control problems, Advanced Algorithms and Data Structures, Data-Oriented Programming in Java, Classic Computer Science Problems in Swift: Essential techniques for practicing programmers, Spring Security in Action, Second Edition, Grokking AI Algorithms, Second Edition, Inside AI, Data-Oriented Programming: Reduce software complexity and 5 more.
What should I know before learning mutation?
Manning books that teach mutation usually introduce function, state, array and chromosome first.
What kinds of mutation are there?
Kinds of mutation include nonconflicting mutation, tool definition mutation, bit-string mutation and boundary mutation.
What are the parts of mutation?
Mutation includes calculation phase.
What is mutation also called?
Mutation is also called mutate or mutating.
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.












