saealib.CrossoverIntegerSBX#
- class saealib.CrossoverIntegerSBX(prob, eta, *, prob_var=0.5)[ソース]#
ベースクラス:
CrossoverSimulated Binary Crossover (SBX) for integer-valued dimensions.
Applies SBX then rounds offspring to the nearest integer.
- パラメータ:
prob (float)
eta (float)
prob_var (float)
- prob#
Individual-level crossover probability.
- Type:
float
- eta#
Distribution index. Larger values produce offspring closer to parents.
- Type:
float
- prob_var#
Per-variable crossover probability. Default is 0.5.
- Type:
float
参照
[11]: Deb, K., & Agrawal, R. B. (1995). Simulated binary crossover for continuous search space. Complex Systems, 9(2), 115-148.
Methods
Initialize integer SBX crossover operator. |
|
Return the integer crossover contract. |
|
Execute crossover for one parent group. |
|
Execute integer SBX crossover on a batch of parent pairs at once. |
|
Post-crossover lifecycle hook; override to inject custom processing. |
|
Run the post-crossover lifecycle hook for a batch. |
|
Return a copy of this operator with |
Method Details
- CrossoverIntegerSBX.__init__(prob, eta, *, prob_var=0.5)[ソース]#
Initialize integer SBX crossover operator.
- パラメータ:
prob (float) -- Individual-level crossover probability.
eta (float) -- Distribution index.
prob_var (float, optional) -- Per-variable crossover probability, by default 0.5.
- CrossoverIntegerSBX.crossover(parent, bounds=None, rng=Generator(PCG64) at 0x7FE0F4773140)#
Execute crossover for one parent group.
This method is derived from
crossover_batch()by passing a single-pair batch.メモ
Overriding only this method (not
crossover_batch()) has no effect under GA's defaultvariation_execution="batch": the batch path callscrossover_batch()directly and never callscrossover(). Such an override only takes effect undervariation_execution="sequential". To customize behavior under both modes, overridecrossover_batch().- パラメータ:
parent (np.ndarray) -- Parent individuals. shape = (n_parents, dim)
bounds (tuple of (np.ndarray, np.ndarray) or None) -- Lower and upper bounds for each variable.
Nonemeans unbounded.rng (np.random.Generator, optional) -- Random number generator, by default np.random.default_rng()
- 戻り値:
Offspring individuals. shape = (n_offspring, dim)
- 戻り値の型:
np.ndarray
- CrossoverIntegerSBX.crossover_batch(parents_batch, bounds=None, rng=Generator(PCG64) at 0x7FE0F47AA260)[ソース]#
Execute integer SBX crossover on a batch of parent pairs at once.
This is the primary integer SBX implementation, vectorized over the leading
n_pairaxis.- パラメータ:
parents_batch (np.ndarray) -- Batch of parent pairs. shape = (n_pair, 2, dim)
bounds (tuple of (np.ndarray, np.ndarray) or None) -- Lower and upper bounds. When provided and finite, the bounded SBX variant is applied before rounding.
rng (np.random.Generator, optional) -- Random number generator, by default np.random.default_rng()
- 戻り値:
Offspring individuals with integer values. shape = (n_pair, 2, dim)
- 戻り値の型:
np.ndarray
メモ
For
n_pair > 1, a loop of separate single-paircrossover_batchcalls (equivalently, separatecrossover()calls) does not reproduce the same per-row results as one batched call with the same seededrng. Drawing each random phase for the whole batch has a different draw order from interleaving those phases one pair at a time.
- CrossoverIntegerSBX.post_crossover(offspring, parents, rng, ctx=None)#
Post-crossover lifecycle hook; override to inject custom processing.
- パラメータ:
offspring (np.ndarray) -- Offspring produced by crossover. shape = (n_children, dim)
parents (np.ndarray) -- Parent individuals. shape = (n_parents, dim)
rng (np.random.Generator) -- Random number generator.
ctx (ExecutionContext or None, optional) -- Current optimization context.
- 戻り値:
Processed offspring. shape = (n_children, dim)
- 戻り値の型:
np.ndarray
- CrossoverIntegerSBX.post_crossover_batch(offspring_batch, parents_batch, rng, ctx=None)#
Run the post-crossover lifecycle hook for a batch.
The default implementation calls
post_crossover()once per parent group, in order. Override this method to provide genuinely vectorized post-processing.- パラメータ:
offspring_batch (np.ndarray) -- Offspring produced by crossover. shape = (n_pair, n_children, dim)
parents_batch (np.ndarray) -- Batch of parent groups. shape = (n_pair, n_parents, dim)
rng (np.random.Generator) -- Random number generator.
ctx (ExecutionContext or None, optional) -- Current optimization context.
- 戻り値:
Processed offspring. shape = (n_pair, n_children, dim)
- 戻り値の型:
np.ndarray
メモ
with_post()reassigns only the instance'spost_crossover()hook. A subclass override of this method is responsible for composing that hook itself. If the override does not callself.post_crossover, a hook installed withwith_post()will not run in GA batch mode. It still runs in GA sequential mode, which callspost_crossover()directly.