View Source Backfish (Backfish v0.1.0)

Backfish is a flexible and powerful backtracking library for Elixir, designed to solve combinatorial and constraint satisfaction problems.

Summary

Functions

Finds all solutions to the given problem.

Finds the first valid solution to the given problem.

Functions

Link to this function

find_all_solutions(problem_module, opts \\ [])

View Source

Finds all solutions to the given problem.

Parameters

  • problem_module: The module implementing the problem definition using Backfish.ProblemDefinition.
  • opts: Optional keyword list of options. Supports:
    • :args: Arguments to pass to the initial_state/1 function of the problem module.
    • :depth_limit: Optional limit on the depth of the search.

Examples

iex> opts = [args: [size: 8]]
iex> Backfish.find_all_solutions(Backfish.Examples.NQueens, opts)
[solution1, solution2, ...]
Link to this function

find_first_solution(problem_module, opts \\ [])

View Source

Finds the first valid solution to the given problem.

Parameters

  • problem_module: The module implementing the problem definition using Backfish.ProblemDefinition.
  • opts: Optional keyword list of options. Supports:
    • :args: Arguments to pass to the initial_state/1 function of the problem module.
    • :depth_limit: Optional limit on the depth of the search.

Examples

iex> opts = [args: [size: 8]]
iex> {:ok, solution} = Backfish.find_first_solution(Backfish.Examples.NQueens, opts)
{:ok, solution}