@@ -310,6 +310,102 @@ Eventually, the optimization for a desired `fid_err_targ` can be started by call
310310 },
311311 )
312312
313+ The Genetic Algorithm (GA)
314+ ==========================
315+
316+ The Genetic Algorithm (GA) is a global optimization technique inspired by natural selection.
317+ Unlike gradient-based methods like GRAPE or CRAB, GA explores the solution space stochastically,
318+ making it robust against local minima and suitable for problems with non-differentiable or noisy objectives.
319+
320+ In QuTiP, the GA-based optimizer evolves a population of candidate control pulses across multiple
321+ generations to minimize the infidelity between the system' s final and target states.
322+
323+ The GA optimization consists of the following components:
324+
325+ **Population**:
326+ A collection of candidate solutions (chromosomes), where each chromosome encodes a full set
327+ of control amplitudes over time for the given control Hamiltonians.
328+
329+ **Fitness Function**:
330+ The fitness of each candidate is evaluated using a fidelity-based measure, such as:
331+
332+ - **PSU (Projective State Overlap)**:
333+ :math:`1 - |\langle \psi_{\text{target}} | \psi_{\text{final}} \rangle|`
334+ - **TRACEDIFF**:
335+ Trace distance between final and target density matrices.
336+
337+ **Genetic Operations**:
338+
339+ - **Selection**:
340+ A subset of the best-performing candidates (based on fitness) are chosen to survive.
341+
342+ - **Crossover (Mating)**:
343+ New candidates are generated by combining genes from selected parents using arithmetic crossover.
344+
345+ - **Mutation**:
346+ Random perturbations are added to the new candidates' genes to maintain diversity and escape local minima.
347+
348+ This process continues until either a target fidelity error is reached or a fixed number of generations
349+ have passed without improvement (stagnation criterion).
350+
351+ Each generation represents a full evaluation of the population, making the method inherently parallelizable
352+ and effective in high-dimensional control landscapes.
353+
354+ In QuTiP, the GA optimization is implemented via the ` ` _GENETIC` ` class, and can be invoked using the
355+ standard ` ` optimize_pulses` ` interface by setting the algorithm to ` ` " GENETIC" ` ` .
356+
357+ Optimal Quantum Control in QuTiP (Genetic Algorithm)
358+ ====================================================
359+
360+ Defining a control problem in QuTiP using the Genetic Algorithm follows the same pattern as with other algorithms.
361+
362+ .. code-block:: python
363+
364+ import qutip as qt
365+ import qutip_qoc as qoc
366+ import numpy as np
367+
368+ # state to state transfer
369+ initial = qt.basis(2, 0)
370+ target = qt.basis(2, 1)
371+
372+ # define the drift and control Hamiltonians
373+ drift = qt.sigmaz ()
374+ controls = [qt.sigmax(), qt.sigmay ()]
375+
376+ H = [drift] + controls
377+
378+ # define the objective
379+ objective = qoc.Objective(initial, H, target)
380+
381+ # discretized time grid (e.g., 100 steps over 10 units of time)
382+ tlist = np.linspace(0, 10, 100)
383+
384+ # define control parameter bounds (same for all controls in GA)
385+ control_parameters = {
386+ " p" : {" bounds" : [(-1.0, 1.0)]}
387+ }
388+
389+ # set genetic algorithm hyperparameters
390+ algorithm_kwargs = {
391+ " alg" : " GENETIC" ,
392+ " population_size" : 50,
393+ " generations" : 100,
394+ " mutation_rate" : 0.2,
395+ " fid_err_targ" : 1e-3,
396+ }
397+
398+ # run the optimization
399+ result = qoc.optimize_pulses(
400+ objectives=[objective],
401+ control_parameters=control_parameters,
402+ tlist=tlist,
403+ algorithm_kwargs=algorithm_kwargs,
404+ )
405+
406+ print(" Final infidelity:" , result.infidelity)
407+ print(" Best control parameters:" , result.optimized_params)
408+
313409.. TODO: add examples
314410
315411Examples for Liouvillian dynamics and multi-objective optimization will follow soon.
0 commit comments