opt.+opt.+de

class opt.de.NumpyRandomState

Bases: handle

NumpyRandomState Bit-exact port of the subset of numpy.random.RandomState consumed by scipy’s differential_evolution. Backed by opt.de.MT19937.

Implements random_sample, uniform, the default-dtype randint (32-bit masked rejection), and shuffle/permutation (Fisher-Yates driven by random_interval), each reproducing numpy’s exact draw sequence and word consumption, so the optimizer follows the identical trajectory to the native-Python line-opt for a given integer seed.

Constructor Summary
NumpyRandomState(seed)
Property Summary
gen

opt.de.MT19937 handle

Method Summary
fillMask(~, v)
permutation(n)
randint(low, high)
randomInterval(maxv)
randomSample()
randomSampleN(n)
shuffle(arr)
uniformN(low, high, n)
uniformScalar(low, high)
class opt.de.MT19937

Bases: handle

MT19937 Bit-exact reimplementation of numpy’s legacy MT19937 core, matching the generator underlying numpy.random.RandomState.

Reproduces numpy’s exact 32-bit output stream so that NumpyRandomState and the differential-evolution optimizer generate identical draws to the native-Python line-opt for a given seed. Seeding follows numpy’s _legacy_seeding: a scalar seed that fits in 32 bits uses init_genrand; otherwise the seed words are fed to init_by_array.

Constructor Summary
MT19937(seed)
Property Summary
mt

1x624 uint32 state

mti

scalar position (numpy get_state pos)

Method Summary
getStateKey()
initByArray(initKey)
initGenrand(s)
nextUint32()
seed(s)
class opt.de.DifferentialEvolution

Bases: handle

DifferentialEvolution Self-contained port of scipy’s differential_evolution that reproduces its trajectory bit-for-bit for a given integer seed, using opt.de.NumpyRandomState for all draws.

Covers the configuration used by line-opt: binomial strategies (default best1bin), updating=’immediate’, dithered mutation, latinhypercube initialization, polish=false, and penalty-based constraints handled inside the objective. The exact numpy draw order is preserved: LHS init (uniform grid then per-column permutation), a per-generation dither uniform, and per candidate randint (fill point), shuffle (sample selection) and uniform (crossover), plus a data-dependent uniform in the bound-repair step.

Constructor Summary
DifferentialEvolution(objective, low, high, strategy, popsizeMult, maxiter, ditherLow, ditherHigh, recombination, tol, seed)
Property Summary
atol
bestPerGen

cell array of 1xd vectors

callback

function handle (bestX, nit) -> logical stop, or []

ditherHigh
ditherLow
energies

1 x numMembers

high

1xd upper bounds

low

1xd lower bounds

maxiter
nfev
numMembers
objective

energy = f(x)

Type:

function handle

paramCount
popsizeMult
population

numMembers x d, scaled to [0,1]

randomIndex

persistent shuffle buffer (0-based values)

recombination
rng

opt.de.NumpyRandomState

scale
strategy
tol
Method Summary
best()
bprime(candidate, s)

candidate and s are 0-based member indices; convert to 1-based rows

calculateInitialEnergies()
converged()
ensureConstraint(trial)
initPopulationLhs()
mutate(candidate)

candidate is 0-based member index

next()
promoteLowestEnergy()
scaleArg1(j)
scaleArg2(j)
scaleParameters(trial)
selectSamples(candidate, numberSamples)

candidate is 0-based member index

solve()