Skip to content

GIVPConfig

givp.GIVPConfig dataclass

Hyper-parameters for the GRASP-ILS-VND-PR algorithm.

The optimization sense is controlled by minimize (boolean, preferred) or direction (string, SciPy/Optuna-style). Pass one of the two; if both are given, minimize wins and direction is rewritten to match. Internally the library always minimizes: when the user wants maximization the objective is wrapped with a sign flip and the returned value is restored to the original sign.

Attributes:

Name Type Description
max_iterations int

Maximum number of GRASP outer iterations.

alpha float

Initial randomization parameter for greedy construction (RCL).

vnd_iterations int

Maximum iterations of the VND local search.

ils_iterations int

Maximum iterations of the ILS loop.

perturbation_strength int

Magnitude of the ILS perturbation.

use_elite_pool bool

Whether to maintain an elite pool for path relinking.

elite_size int

Maximum size of the elite pool.

path_relink_frequency int

GRASP iteration period at which to run PR.

path_relink_strategy PathRelinkStrategy

Explicit path-relinking direction control.

adaptive_alpha bool

If True, alpha varies between alpha_min and alpha_max.

alpha_min float

Lower bound used by adaptive alpha.

alpha_max float

Upper bound used by adaptive alpha.

num_candidates_per_step int

Candidates evaluated per construction step.

use_cache bool

If True, evaluations are memoized via an LRU cache.

cache_size int

Maximum entries kept by the LRU cache.

early_stop_threshold int

Iterations without improvement to early-stop.

use_convergence_monitor bool

Enable diversification/restart heuristics.

n_workers int

Number of worker processes (or threads) used to evaluate candidates in parallel during the GRASP construction phase. Default is 1 (serial).

Parallelism strategy (applied when n_workers > 1 and the evaluation cache is disabled):

  1. ProcessPoolExecutor — used when the objective is picklable (module-level functions, classes defined at import time). Runs in separate processes, completely bypassing the GIL and providing true multi-core speedup for any objective, including pure-Python ones.
  2. cloudpickle ProcessPoolExecutor — if the objective is a closure, lambda, or locally-defined function (not picklable with pickle), a second attempt uses cloudpickle to serialise it. Install the optional extra to enable this path::

    pip install "givp[parallel]"

  3. ThreadPoolExecutor fallback — used only when both serialisation strategies fail (i.e. cloudpickle is not installed). Thread-based execution benefits objectives that release the GIL (NumPy-heavy, Cython, Numba-compiled code) but provides no speedup for pure-Python objectives due to the GIL.

time_limit float

Wall-clock budget in seconds (0 = unlimited).

minimize bool | None

Boolean convenience flag. True (default) means minimization, False means maximization. When set, it overrides direction.

direction Direction

'minimize' (default) or 'maximize'. Kept for SciPy/Optuna-style API compatibility.

integer_split int | None

Index where integer variables begin in the decision vector. None preserves the legacy SOG2 behavior of splitting in half. Set to num_vars for fully continuous problems or to 0 for fully integer problems.

as_core_config

as_core_config() -> GIVPConfig

Return self.

GIVPConfig structurally satisfies the internal _CoreConfigProto used by givp.core functions, so it can be passed directly without copying field values into a separate dataclass. The minimize and direction fields are ignored by core code.