dased.optimisation

This module provides optimization tools for DAS layouts using evolutionary algorithms. It includes population-based optimization with parallel evaluation, constraint handling, and multi-objective support.

Classes

DASOptimizationProblem

PyGMO-compatible optimization problem for DAS layout design.

DASArchipelago

Multi-island evolutionary optimization framework for DAS layout problems.

InitialPopulation

Intelligent initial population generator for DAS layout optimization.

joblib_island

Custom PyGMO island using joblib for parallel evolution.

Descriptions

class dased.optimisation.DASOptimizationProblem(design_criterion, bounds, N_knots, cable_length, spacing, fixed_points=None, spatial_constraints=None, verbose=1, n_jobs=1, **kwargs)

PyGMO-compatible optimization problem for DAS layout design.

This class defines the optimization problem for designing DAS layouts, including objective functions, constraints, and decision variable handling. It supports both single and multi-objective optimization with flexible constraint handling for spatial boundaries and cable length limits.

The problem follows PyGMO conventions, providing the necessary interface methods for integration with PyGMO’s optimization algorithms. Design parameters (decision variables in PyGMO nomeclature) represent the coordinates of variable knot points along the DAS cable path.

Parameters:
  • design_criterion

    Objective function(s) for optimization. Can be:

    • Callable: Single objective function f(layout) -> float

    • Dict: Multiple objectives {name: function} for multi-objective optimization

    Functions should accept a DASLayout object and return a scalar. Higher values indicate better solutions (maximization convention).

  • bounds – Rectangular search area as [[x_min, x_max], [y_min, y_max]]. All variable knot points must lie within these bounds. Should be a 2×2 array-like structure.

  • N_knots – Number of variable knot points along the cable path. Total design parameters = 2 × N_knots (x and y coordinates). More knots allow more complex cable geometries but increase problem dimensionality.

  • cable_length – Maximum allowed cable length in the same units as bounds. Layouts exceeding this length receive penalty fitness values.

  • spacing – Spacing between DAS channels along the cable in same units as bounds. Determines the number of measurement channels and affects layout performance calculations results and computational cost.

  • fixed_points

    Fixed knot points that don’t vary during optimization. Total number of knots = N_knots + N_fixed_points Can be:

    • None: No fixed points (all knots are variable)

    • List/Tuple/Array: Points prepended to variable knots

    • Dict: {final_index: (x, y)} for precise placement. Inserted starting at index zero.

    Useful for constraining start/end points or intermediate waypoints. Defaults to None.

  • spatial_constraints – Forbidden areas as Shapely Polygon/MultiPolygon. Cable paths intersecting these areas receive penalty fitness. Useful for avoiding obstacles, protected areas, or infeasible regions. Defaults to None.

  • verbose (int) – Logging verbosity level (0=WARNING, 1=INFO, 2+=DEBUG). Higher values provide more detailed optimization information. Defaults to 1.

  • n_jobs (int) – Number of parallel jobs for batch fitness evaluation (if supported). Only used by fitness_batch method. Defaults to 1.

  • **kwargs – Additional parameters passed to DASLayout constructor. Common options include elevation data, field properties, and signal decay parameters.

design_criterion

Objective function(s)

is_multi_objective

Whether problem has multiple objectives

n_objectives

Number of objective functions

criteria_names

Names of objective functions

bounds

Search space boundaries

N_knots

Number of variable knot points

cable_length

Maximum cable length constraint

spacing

Channel spacing parameter

fixed_points_validated

Processed fixed points

spatial_constraints

Forbidden area geometry

allowed_area

Allowed area geometry (bounds minus constraints)

Examples

Single-objective layout optimization:

>>> def eig_criterion(layout):
...     return calculate_eig(layout)
>>>
>>> problem = DASOptimizationProblem(
...     design_criterion=eig_criterion,
...     bounds=[[0, 1000], [0, 1000]],
...     N_knots=8,
...     cable_length=1200,
...     spacing=10.0
... )

Multi-objective optimization with constraints:

>>> criteria = {
...     "eig": eig_criterion,
...     "sensitivity": sensitivity_criterion
... }
>>> forbidden_area = Polygon([(400, 400), (600, 400), (600, 600), (400, 600)])
>>>
>>> problem = DASOptimizationProblem(
...     design_criterion=criteria,
...     bounds=[[0, 1000], [0, 1000]],
...     N_knots=8,
...     cable_length=1500,
...     spacing=5.0,
...     fixed_points={(0, (100, 100), 9: (900, 900))},  # Fix start and end
...     spatial_constraints=forbidden_area,
...     verbose=2
... )

Note

  • The class implements PyGMO’s problem interface (get_bounds, get_nobj, fitness)

  • Fitness values are minimized by PyGMO, so objectives are negated internally

  • Spatial constraints are handled through penalty methods

get_bounds()

Returns the lower and upper bounds for the design parameters.

Returns:

(lower_bounds, upper_bounds).

Return type:

A tuple containing two lists

get_nobj()

Returns the number of objectives for the optimization problem.

Returns:

An integer representing the number of objectives.

get_name()

Returns the name of the optimization problem.

get_extra_info()

Returns a string with extra information about the problem setup.

get_fixed_points()

Returns the fixed point coordinates (x, y) as a numpy array.

Returns:

A numpy array of shape (N_fixed, 2) containing the coordinates of the fixed points, or None if no fixed points are defined.

fitness(x)

Calculates the fitness (objective function value) for a decision vector.

For single-objective: returns the negative of the design criterion if valid. For multi-objective: returns the negative of each criterion if valid. PyGMO aims to minimize all objectives.

Parameters:

x – The decision vector representing the coordinates of variable knots. Format: [x1, x2, …, xN, y1, y2, …, yN].

Returns:

A tuple containing the fitness values (lower is better).

check_spatial_constraints(layout)

Checks if the layout violates spatial constraints (forbidden areas).

Parameters:

layout – The DASLayout object to check.

Returns:

True if the layout violates spatial constraints, False otherwise.

class dased.optimisation.DASArchipelago(problem, n_islands, population_size, algo=None, migration_topology=None, verbose=1, random_seed=0, island_parallelization='multiprocessing')

Multi-island evolutionary optimization framework for DAS layout problems.

This class provides a high-level interface for running evolutionary optimization of DAS layouts using PyGMO’s archipelago model. It supports both single and multi-objective optimization with configurable parallelization, migration patterns, and algorithm selection.

The archipelago maintains multiple populations (islands) that evolve independently with periodic migration of individuals between islands. This approach often provides better exploration and can escape local optima more effectively than single-population algorithms.

Parameters:
  • problem – DASOptimizationProblem instance defining the optimization problem including design criteria, constraints, and problem dimensions.

  • n_islands – Number of independent islands (populations).

  • population_size – Size of each island’s population. Total population across all islands will be n_islands × population_size.

  • algo

    Algorithm(s) to use for evolution. Can be:

    • None: Uses default algorithms (NSGA-II for multi-objective, SGA for single-objective)

    • Single PyGMO algorithm: Applied to all islands

    • List of algorithms: One per island (cycling if fewer than n_islands)

    Defaults to None.

  • migration_topology

    PyGMO topology defining migration patterns between islands. If None, uses ring topology. Common options:

    • pg.ring(): Ring topology (default). Only neighboring islands exchange migrants

    • pg.fully_connected(): All islands exchange migrants

    • pg.unconnected(): No migration between islands

    Defaults to None (ring topology).

  • verbose

    Verbosity level for logging. Higher values provide more detail:

    • 0: Warnings only

    • 1: Info messages

    • 2+: Debug information

    Defaults to False (equivalent to 0).

  • random_seed – Random seed for reproducible results. If provided, ensures deterministic optimization runs. Defaults to 0.

  • island_parallelization

    Type of parallelization for island evolution: Some types might lead to pickling issues with certain algorithms. Joblib seems to work best. Options:

    • ”joblib”: Custom joblib-based parallelization (recommended)

    • ”multiprocessing”: PyGMO’s multiprocessing island

    • ”ipyparallel”: IPython parallel (for cluster computing)

    • None: No parallelization (sequential evolution)

    Defaults to “multiprocessing”.

problem

The optimization problem instance

n_obj

Number of optimization objectives

is_multi_objective

Whether problem has multiple objectives

n_dim

Number of design parameters

archipelago

PyGMO archipelago instance (after initialization)

Examples

Basic single-objective optimization:

>>> problem = DASOptimizationProblem(criterion, bounds, n_knots, ...)
>>> arch = DASArchipelago(problem, n_islands=8, population_size=100)
>>> arch.initialize(proposal_points)
>>> arch.optimize(n_generations=50)
>>> best_layout = arch.get_best()

Multi-objective optimization with custom algorithms:

>>> criteria = {"eig": eig_criterion, "sensitivity": sens_criterion}
>>> problem = DASOptimizationProblem(criteria, bounds, n_knots, ...)
>>> algorithms = [pg.nsga2(gen=1), pg.moead(gen=1)]
>>> arch = DASArchipelago(
...     problem, n_islands=6, population_size=80,
...     algo=algorithms, verbose=1
... )
>>> arch.initialize(proposal_points)
>>> arch.optimize(n_generations=100, migrate_every=10)
>>> pareto_layouts, pareto_fitness = arch.get_pareto_front()
initialize(proposal_points, perturb_proposal=0.0, perturb_knots=0.0, random_t=True, proposal_weights=None, corr_len=0, corr_str=1.0, min_length=0, max_attempts=100000, n_jobs=None, show_progress=False, filename=None, **kwargs)

Initialize archipelago populations from proposal points with intelligent sampling.

Creates initial populations for all islands using the InitialPopulation class to generate diverse, feasible DAS layouts. Supports loading/saving populations for resuming optimization runs.

Parameters:
  • proposal_points

    Initial layout proposals for population generation. Can be:

    • numpy.ndarray: Single set of points (N×2) or multiple sets (M×N×2)

    • list: List of point arrays for multiple proposal sets

    These points serve as starting points for generating the initial population through perturbation and interpolation.

  • perturb_proposal – Standard deviation for Gaussian noise added to proposal points during population generation. Higher values increase diversity but may violate constraints. Defaults to 0.0.

  • perturb_knots – Standard deviation for Gaussian noise added to knot points after interpolation. Defaults to 0.0.

  • random_t – Whether to use random parameter values when interpolating along proposal point splines. If False, uses evenly spaced parameters. Defaults to True.

  • proposal_weights – Relative weights for sampling from multiple proposal point sets. Must be non-negative and sum to positive value. If None, uses uniform weights. Defaults to None.

  • corr_len – Correlation length for spatially correlated knot perturbations. Larger values create smoother perturbations along cable path. If 0, perturbations are uncorrelated. Defaults to 0.

  • corr_str – Correlation strength (0-1) for knot perturbations. 1.0 means fully correlated, 0.0 means uncorrelated. Defaults to 1.0.

  • min_length – Minimum acceptable cable length for generated layouts. Layouts shorter than this are rejected. Defaults to 0.

  • max_attempts – Maximum attempts to generate each valid individual. Higher values improve success rate but increase computation time. Defaults to 100,000.

  • n_jobs – Number of parallel jobs for population generation and fitness evaluation. If None, uses number of islands. Defaults to None.

  • show_progress – Whether to display progress bars during initialization. Defaults to False.

  • filename – Base filename for saving/loading population data (without extension). If provided and file exists, attempts to load previous population. Always saves final population. Defaults to None.

  • **kwargs – Additional arguments passed to spline interpolation (scipy.interpolate.splprep).

Raises:

ValueError – If not enough valid individuals can be generated or if proposal weights are invalid.

Examples

Basic initialization:

>>> arch.initialize(proposal_points, perturb_proposal=10.0)

Multi-proposal initialization with weights:

>>> proposals = [straight_line, curved_path, complex_geometry]  # list of :class:`~numpy.ndarray` or similar structures
>>> weights = [0.5, 0.3, 0.2]
>>> arch.initialize(proposals, proposal_weights=weights,
...                 perturb_knots=5.0, show_progress=True)

Resume from checkpoint:

>>> arch.initialize(proposal_points, filename="optimization_run")
optimize(n_generations=100, migrate_every=None, filename=None, show_progress=True, track_fitness_history=True, track_param_history=True)

Run evolutionary optimization for the specified number of generations.

Executes the main optimization loop with optional migration between islands, progress tracking, and checkpointing. Supports resuming from saved states and provides comprehensive fitness/parameter history tracking.

Parameters:
  • n_generations – Total number of generations to run. Each generation involves one evolution step per island. Must be positive. Defaults to 100.

  • migrate_every – Frequency of migration events between islands. If None, no migration occurs (islands evolve independently). If positive integer, migration happens every N generations. Migration can improve exploration and solution quality. Defaults to None.

  • filename

    Base filename for checkpoint saving/loading (without extension). If provided:

    • Attempts to load previous state at start

    • Saves state every 10 generations during optimization

    • Saves final state at completion

    Enables resuming interrupted optimizations. Defaults to None.

  • show_progress – Whether to display progress bar with fitness information during optimization. Shows best fitness and migration events. Defaults to True.

  • track_fitness_history – Whether to record fitness values throughout optimization. Required for fitness history analysis and plotting. Stored data can be retrieved with get_fitness_history(). Defaults to True. Might add memory overhead for large runs.

  • track_param_history – Whether to record decision variable values throughout optimization. Required for parameter evolution analysis. Stored data can be retrieved with get_param_history(). Defaults to True. Might add memory overhead for large runs.

Returns:

Total number of generations completed, including any loaded

from checkpoint files.

Return type:

int

Examples

Basic optimization:

>>> total_gens = arch.optimize(n_generations=100)

Optimization with migration and checkpointing:

>>> total_gens = arch.optimize(
...     n_generations=500,
...     migrate_every=25,
...     filename="das_optimization",
...     show_progress=True
... )

Resume interrupted optimization:

>>> # This will load previous state and continue
>>> total_gens = arch.optimize(
...     n_generations=1000,
...     filename="das_optimization"  # Same filename as before
... )
Raises:

ValueError – If archipelago not initialized (call initialize() first)

get_current_layouts(flatten=True)

Return current layouts (decoded decision vectors) from the archipelago.

get_current_fitness(flatten=True)

Return current fitness values (maximized) from the archipelago.

get_current_decision_vectors_and_fitness(flatten=True)

Return current decision vectors and fitness values from the archipelago. Fitness values are always maximized (user-facing).

Returns:

Decision vectors (2D array if flatten=True, else list of 2D arrays) fs: Fitness values (2D array if flatten=True, else list of 2D arrays)

Return type:

dvs

get_history_decision_vectors_and_fitness()

Return all decision vectors and fitness values from the optimization history. Fitness values are always maximized (user-facing).

Returns:

Decision vectors (2D array) fs: Fitness values (2D array)

Return type:

dvs

get_best(**kwargs)

Get the best solution(s) from the archipelago. For single-objective problems, returns the best solution. For multi-objective problems, returns the Pareto front.

Parameters:

**kwargs – Additional arguments passed to get_best_single or get_pareto_front.

Returns:

(layout, fitness) or layout or fitness based on kwargs. For multi-objective: (layouts, fitnesses) or layouts or fitnesses based on kwargs.

Return type:

For single-objective

get_best_single(from_history=False, return_layout=True, return_fitness=True)

Get the best solution (maximized fitness) for single-objective problems.

Parameters:
  • from_history – Whether to consider all historical solutions (True) or only current population (False). Defaults to False.

  • return_layout – Whether to return the decoded layout. Defaults to True.

  • return_fitness – Whether to return the fitness value. Defaults to True.

Returns:

  • (layout, fitness) if both True

  • layout if return_layout is True

  • fitness if return_fitness is True

  • None if both are False

Return type:

Depending on return_layout and return_fitness

get_n_best_single(N=1, similarity_tol=None, from_history=False, return_layout=True, return_fitness=True)

Get N best (maximized) solutions for single-objective problems, optionally filtering by similarity.

Parameters:
  • N – Number of top solutions to return. Defaults to 1.

  • similarity_tol – Minimum Euclidean distance between decision vectors to be considered unique. If None, no similarity filtering is applied. Defaults to None.

  • from_history – Whether to consider all historical solutions (True) or only current population (False). Defaults to False.

  • return_layout – Whether to return decoded layouts. Defaults to True.

  • return_fitness – Whether to return fitness values. Defaults to True.

Returns:

  • (layouts, fitnesses) if both True

  • layouts if return_layout is True

  • fitnesses if return_fitness is True

  • None if both are False

Return type:

Depending on return_layout and return_fitness

get_n_spread_single(N=5, from_history=False, return_layout=True, return_fitness=True)

Get N solutions spread as much as possible across the fitness range (single-objective). Uses linear spacing between min and max fitness.

Parameters:
  • N – Number of solutions to return. Defaults to 5.

  • from_history – Whether to consider all historical solutions (True) or only current population (False). Defaults to False.

  • return_layout – Whether to return decoded layouts. Defaults to True.

  • return_fitness – Whether to return fitness values. Defaults to True.

Returns:

  • (layouts, fitnesses) if both True

  • layouts if return_layout is True

  • fitnesses if return_fitness is True

  • None if both are False

Return type:

Depending on return_layout and return_fitness

get_pareto_front(from_history=False, return_layout=True, return_fitness=True)

Get the non-dominated (Pareto) front for multi-objective problems. Fitness values are always maximized (user-facing).

Parameters:
  • from_history – Whether to consider all historical solutions (True) or only current population (False). Defaults to False.

  • return_layout – Whether to return decoded layouts. Defaults to True.

  • return_fitness – Whether to return fitness values. Defaults to True.

Returns:

  • (layouts, fitnesses) if both True

  • layouts if return_layout is True

  • fitnesses if return_fitness is True

  • None if both are False

Return type:

Depending on return_layout and return_fitness

get_best_multi(from_history=False, return_layout=True, return_fitness=True, method='halfway')

Get the best solution on the Pareto front according to an aggregate function.

Fitness values are always maximized (user-facing).

Parameters:
  • from_history – Whether to use historical data instead of current population

  • return_layout – Whether to return layout objects

  • return_fitness – Whether to return fitness values

  • method

    Aggregation method for selecting best solution:

    • ”sum”: maximizes sum of objectives

    • ”minmax”: maximizes the maximum objective

    • ”compromise”: maximally distant from line between endpoints

    • ”halfway”: closest to midpoint between best and worst for each objective

Returns:

  • (layouts, fitnesses) if both True

  • layouts if return_layout is True

  • fitnesses if return_fitness is True

  • None if both are False

Return type:

Depending on return_layout and return_fitness

get_n_best_multi(N=5, similarity_tol=None, from_history=False, return_layout=True, return_fitness=True)

Get N best (maximized aggregate) solutions from the Pareto front, optionally filtering by similarity. Fitness values are always maximized (user-facing).

Parameters:
  • N – Number of top solutions to return. Defaults to 5.

  • similarity_tol – Minimum Euclidean distance between decision vectors to be considered unique. If None, no similarity filtering is applied. Defaults to None.

  • from_history – Whether to consider all historical solutions (True) or only current population (False). Defaults to False.

  • return_layout – Whether to return decoded layouts. Defaults to True.

  • return_fitness – Whether to return fitness values. Defaults to True.

Returns:

  • (layouts, fitnesses) if both True

  • layouts if return_layout is True

  • fitnesses if return_fitness is True

  • None if both are False

Return type:

Depending on return_layout and return_fitness

get_n_spread_multi(N=5, from_history=False, return_layout=True, return_fitness=True)

Get N solutions spread as much as possible across the Pareto front (multi-objective). Always includes endmembers (solutions that maximize each objective) and fills the rest using a greedy max-min approach in fitness space. Fitness values are always maximized (user-facing).

Parameters:
  • N – Number of solutions to return. Defaults to 5.

  • from_history – Whether to consider all historical solutions (True) or only current population (False). Defaults to False.

  • return_layout – Whether to return decoded layouts. Defaults to True.

  • return_fitness – Whether to return fitness values. Defaults to True.

Returns:

  • (layouts, fitnesses) if both True

  • layouts if return_layout is True

  • fitnesses if return_fitness is True

  • None if both are False

Return type:

Depending on return_layout and return_fitness

get_endmembers(method='halfway', from_history=False, return_layout=True, return_fitness=True)

Get the endmembers of the Pareto front according to an aggregate function.

Fitness values are always maximized (user-facing).

Parameters:
  • method

    Aggregation method for selecting endmembers:

    • ”sum”: maximizes sum of objectives

    • ”minmax”: maximizes the maximum objective

    • ”compromise”: maximally distant from line between endpoints

    • ”halfway”: closest to midpoint between best and worst for each objective

  • from_history – Whether to use historical data instead of current population

  • return_layout – Whether to return layout objects

  • return_fitness – Whether to return fitness values

Returns:

Dictionary of endmember solutions with objective names as keys

get_fitness_history()

Return the fitness history (maximized) as a numpy array.

Returns:

Numpy array of fitness history. Each entry corresponds to a generation. For single-objective: shape (n_generations, n_islands) For multi-objective: shape (n_generations,), each entry is an array of ND solutions. Empty generations are represented as empty arrays.

get_param_history()

Return the parameter (decision vector) history as a numpy array.

Returns:

Numpy array of parameter history. Each entry corresponds to a generation. Each entry is an array of decision vectors for the best individuals per island. Empty generations are represented as empty arrays.

plot_fitness_history()

Plot the fitness history for all generations. For multi-objective: plots all ND solutions and best per objective. For single-objective: plots best per island and overall.

get_file_info(filename)

Returns a nicely formatted string with the number of islands, population size, and number of objectives.

class dased.optimisation.InitialPopulation(problem, proposal_points, perturb_proposal=0.0, perturb_knots=0.0, random_t=True, proposal_weights=None, corr_len=0, corr_str=1.0, min_length=0, max_attempts=100000, max_emergency_attempts=1000, random_seed=None, n_jobs=1, show_progress=False, **kwargs)

Intelligent initial population generator for DAS layout optimization.

This class can generate diverse, feasible initial populations for evolutionary optimization by starting from user-provided proposal points and applying controlled perturbations. It ensures all generated layouts satisfy constraints while trying to maintaining diversity for effective optimization.

The generator supports multiple proposal point sets with weighted sampling, spatial correlations in perturbations, and parallel generation for efficiency. Failed generations trigger emergency procedures to ensure population completeness.

Parameters:
  • problem – DASOptimizationProblem instance defining constraints and feasibility criteria for generated layouts.

  • proposal_points

    Base layouts for population generation. Can be:

    • numpy.ndarray: Single set of points (N×2) or multiple sets (M×N×2)

    • list: List of point arrays for different layout types

    These serve as seeds that are perturbed and interpolated to create the initial population. More diverse proposals lead to better exploration.

  • perturb_proposal – Standard deviation for Gaussian perturbation of proposal points before spline interpolation. Higher values increase diversity but may violate constraints. Defaults to 0.0.

  • perturb_knots – Standard deviation for Gaussian perturbation of final knot points after interpolation. Applied after constraint satisfaction. Defaults to 0.0.

  • random_t – Whether to use random parameterization when sampling along proposal splines. If False, uses evenly spaced parameter values. Random sampling increases layout diversity. Defaults to True.

  • proposal_weights – Relative sampling weights for multiple proposal sets. Must be non-negative and sum to positive value. If None, uses uniform weights. Allows biasing toward preferred layout types. Defaults to None.

  • corr_len – Correlation length for spatially correlated knot perturbations. Controls smoothness of perturbations along cable path. Larger values create smoother deformations. If 0, perturbations are uncorrelated. Defaults to 0.

  • corr_str – Correlation strength (0-1) for knot perturbations. 1.0 means fully correlated perturbations, 0.0 means independent. Controls balance between smooth and random deformations. Defaults to 1.0.

  • min_length – Minimum acceptable cable length for generated layouts. Layouts shorter than this are rejected during generation. Defaults to 0.

  • max_attempts – Maximum attempts to generate each valid individual. Higher values improve success rate but increase computation time. Should be large enough to handle constraint complexity. Defaults to 100,000.

  • max_emergency_attempts – Maximum emergency attempts using randomized proposals when normal generation fails. Provides fallback to ensure population completeness. Defaults to 1,000.

  • random_seed – Random seed for reproducible population generation. If None, uses random initialization. Defaults to None.

  • n_jobs – Number of parallel workers for population generation. Higher values speed up generation but require more memory. Defaults to 1.

  • show_progress – Whether to display progress bars during generation. Useful for monitoring long generation processes. Defaults to False.

  • **kwargs – Additional arguments passed to scipy.interpolate.splprep for spline interpolation. Common options include smoothing parameters.

Examples

Basic population generation:

>>> pop_gen = InitialPopulation(
...     problem=problem,
...     proposal_points=proposal_layouts,
...     perturb_proposal=10.0,
...     max_attempts=50000
... )
>>> layouts = pop_gen.get_layouts(200)

Multi-proposal generation with correlation:

>>> proposals = [straight_line, curved_path, spiral_layout]
>>> weights = [0.5, 0.3, 0.2]
>>> pop_gen = InitialPopulation(
...     problem=problem,
...     proposal_points=proposals,
...     proposal_weights=weights,
...     perturb_knots=5.0,
...     corr_len=50.0,
...     corr_str=0.8,
...     n_jobs=4,
...     show_progress=True
... )
>>> decision_vectors = pop_gen.get_layouts(500)
Raises:
  • ValueError – If proposal points are invalid, weights don’t sum to positive value, or not enough valid individuals can be generated.

  • RuntimeError – If population generation fails after all attempts.

get_layouts(n_samples)

Generate a set of diverse, feasible DAS layouts.

Parameters:

n_samples – Number of layouts to generate.

Returns:

List of generated DASLayout objects.

get_decision_vectors(n_samples)

Generate a set of diverse, feasible decision vectors for DAS layouts. :param n_samples: Number of decision vectors to generate.

Returns:

List of generated decision vectors (numpy arrays).

class dased.optimisation.joblib_island(n_jobs=None, backend=None)

Custom PyGMO island using joblib for parallel evolution.

This user-defined island (UDI) dispatches evolution tasks using joblib’s parallel processing capabilities. It provides efficient parallelism for Python functions with automatic handling of NumPy arrays and efficient serialization through cloudpickle.

The island manages a shared joblib.Parallel pool across all instances for resource efficiency, automatically handling initialization and cleanup of the parallel backend.

Parameters:
  • n_jobs – Number of parallel jobs to use. If None, uses all available CPU cores. Defaults to None.

  • backend – Joblib backend for parallel execution. Options include ‘loky’, ‘multiprocessing’, ‘threading’. If None, uses joblib’s default backend. Defaults to None.

Examples

>>> # Create a joblib island (:class:`~dased.optimisation.joblib_island`)
>>> island = joblib_island(n_jobs=4, backend='loky')  # :class:`~dased.optimisation.joblib_island`
>>> # Use in PyGMO archipelago
>>> arch = pg.archipelago()
>>> arch.push_back(pg.island(algo=pg.sga(), pop=pop, udi=island))  # uses :mod:`pygmo`

Note

The joblib pool is shared across all joblib_island instances and persists until explicitly shut down with shutdown_pool().

static init_pool(n_jobs=None, backend=None)

Initialize the shared joblib parallel backend.

This method initializes the joblib Parallel object used by all joblib_island instances. If the pool is already initialized or was previously shut down, this will create a new pool.

Parameters:
  • n_jobs – Number of jobs to run in parallel. If None, uses all available CPU cores. Must be an integer or None.

  • backend – Joblib backend to use. Options include ‘loky’, ‘multiprocessing’, ‘threading’. If None, uses default. Must be a string or None.

static shutdown_pool()

Shutdown the shared joblib parallel backend.

This method shuts down the joblib Parallel object used by all joblib_island instances. After shutdown, the next evolution will automatically create a new Parallel object.

This is useful for cleaning up resources or changing parallel backend settings.

run_evolve(algo, pop)

Evolve population using the specified algorithm in parallel.

This method evolves the input population using the input algorithm and returns both the algorithm and evolved population. Evolution runs in a separate process using joblib’s parallel processing.

If the algorithm or population contains non-picklable objects, this method automatically uses joblib’s wrap_non_picklable_objects to handle them properly.

Parameters:
  • algo – PyGMO algorithm instance to use for evolution

  • pop – PyGMO population instance to evolve

Returns:

(algorithm, evolved_population) after one evolution step

Return type:

tuple

Raises:

Exception – Any exception thrown by evolution or parallel processing

get_name()

Get the name of this island type.

Returns:

Always returns “Joblib island”

Return type:

str

get_extra_info()

Get additional information about the island’s configuration.

Returns:

String containing information about the parallel backend

configuration including backend type and number of jobs

Return type:

str