Heuristics API

The Heuristics API provides the optimization strategies for initialization, neighbourhood exploration, and move selection.

Initialization Heuristics

JuLS.SimpleInitializationType
SimpleInitialization <: InitializationHeuristic

A basic initialization strategy that typically assigns default or random values to variables. Must be implemented as (::SimpleInitialization)(e::YourExperiment) and return a vector of values indexed by decision variables.

source
JuLS.GreedyInitializationType
GreedyInitialization <: InitializationHeuristic

An initialization strategy that uses a greedy approach to assign initial values. Must be implemented as (::GreedyInitialization)(e::YourExperiment) and return a vector of values indexed by decision variables.

source
JuLS.ChristofidesInitializationType
function (::ChristofidesInitialization)(e::TSPExperiment)

Initialization strategy using Christofides algorithm for metric TSP. Provides a 1.5-approximation guarantee for metric instances.

source

Neighbourhood Heuristics

JuLS.RandomNeighbourhoodType
RandomNeighbourhood <: NeighbourhoodHeuristic

A neighbourhood generation strategy that randomly samples variables and assigns them random values from their domains.

Fields

  • variable_sampler::VariableSampler: Strategy for selecting variables
  • number_of_variables_to_move::Int: Number of variables to modify in each move
source
JuLS.BinaryRandomNeighbourhoodType
BinaryRandomNeighbourhood <: NeighbourhoodHeuristic

A neighbourhood generation strategy for binary optimization problems that randomly selects and flips variables.

Fields

  • number_of_moves::Int: Number of moves to generate in each neighbourhood
  • number_of_variables_to_move::Int: Number of variables to flip in each move

Description

Generates moves by randomly selecting a specified number of binary variables and flipping their values (0->1 or 1->0) in each move. This creates a neighbourhood of potential solutions around the current solution.

source
JuLS.BinarySingleNeighbourhoodType
BinarySingleNeighbourhood <: NeighbourhoodHeuristic

A neighbourhood generation strategy for binary optimization problems that generates all possible moves where exactly one binary variable is flipped.

source
JuLS.SwapNeighbourhoodType
SwapNeighbourhood <: NeighbourhoodHeuristic

A neighbourhood generation strategy that creates moves by swapping values between selected variables through circular shifting.

Fields

  • variable_sampler::VariableSampler: Strategy for selecting variables to swap
  • number_of_variables_to_move::Int: Number of variables involved in each swap (default: 2)
source
JuLS.KOptNeighbourhoodType
KOptNeighbourhood <: NeighbourhoodHeuristic

A neighbourhood generation strategy that creates k-opt moves by permuting values among k selected variables.

Fields

  • number_of_moves::Int: Number of different k-opt moves to generate
  • k::Int: Number of variables involved in each permutation

Description

Implements a k-opt neighbourhood where k variables are selected and their values are permuted to create new potential solutions. This is particularly useful for problems

source
JuLS.ExhaustiveNeighbourhoodType
ExhaustiveNeighbourhood <: NeighbourhoodHeuristic

A neighbourhood generation strategy that exhaustively explores all possible value combinations for a selected subset of variables. This is equivalent to relax domains for the variables sampled.

Fields

  • number_of_variables_to_move::Int: Number of variables to consider in each move
  • variable_sampler::VariableSampler: Strategy for selecting which variables to consider
source
JuLS.GreedyNeighbourhoodType
GreedyNeighbourhood <: NeighbourhoodHeuristic

A neighbourhood generation strategy that greedily explores variables based on their potential improvement at initialization.

Fields

  • queue::Vector{LazyCartesianMoves}: Ordered queue of moves to explore
  • _is_init::Bool: Flag indicating if the neighbourhood has been initialized

Description

This heuristic evaluates each variable's potential contribution to improvement and orders the exploration based on these evaluations. Variables are explored in order of their potential impact on the objective function.

source

Move Selection Heuristics

JuLS.GreedyMoveSelectionType
GreedyMoveSelection <: MoveSelectionHeuristic

Greedy move selection heuristic. Always pick the most impactful move.

source
JuLS.SimulatedAnnealingType
Metropolis <: MoveSelectionHeuristic

Fields

-T::Float64: Temperature -α::Float64: Cooling factor -T_min::Float64 : Minimal temperature

Of all the moves given, take the best delta, return it if negative or return it with probability exp(-δ/T).

source
JuLS.MetropolisType
Metropolis <: MoveSelectionHeuristic

Fields

  • T::Float64: Temperature for metropolis probability

Of all the moves given, take the best delta, return it if negative or return it with probability exp(-δ/T).

source

Custom Heuristics

To create custom heuristics, implement the appropriate abstract type:

  • InitializationHeuristic: For custom initialization strategies
  • NeighbourhoodHeuristic: For custom neighbourhood exploration
  • MoveSelectionHeuristic: For custom move selection criteria

Example Usage

```julia using JuLS

Initialize with different heuristics

model = initmodel( experiment; init = GreedyInitialization(), neigh = KOptNeighbourhood(5, 2), # nmoves, k pick = SimulatedAnnealing(100.0, 0.95) # T0, α )