@File : _solver.py @Time : 2026/05/15 11:03:12 @Author : Alejandro Marrero (amarrerd@ull.edu.es) @Version : 1.0 @Contact : amarrerd@ull.edu.es @License : (C)Copyright 2026, Alejandro Marrero @Desc : None

Solver

Bases: Protocol

Protocol that defines any Solver in digneapy.

A Solver, is any callable type that receives a Problem (P) as argument and returns a list of Solution objects.

Source code in digneapy/core/_solver.py
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
@runtime_checkable
class Solver(Protocol):
    """Protocol that defines any Solver in digneapy.

    A Solver, is any callable type that receives a Problem (P)
    as argument and returns a list of Solution objects.
    """

    @abstractmethod
    def __call__(self, problem: Problem, *args, **kwargs) -> list[Solution]:
        """Solves a optimisation problem

        Args:
            problem (Problem): Any optimisation problem or callablle that receives a Sequence and returns a Tuple[float].

        Raises:
            NotImplementedError: Must be implemented by subclasses

        Returns:
            List[Solution]: Returns a sequence of olutions
        """
        msg = "__call__ method not implemented in Solver"
        raise NotImplementedError(msg)

__call__(problem, *args, **kwargs) abstractmethod

Solves a optimisation problem

Parameters:
  • problem (Problem) –

    Any optimisation problem or callablle that receives a Sequence and returns a Tuple[float].

Raises:
  • NotImplementedError

    Must be implemented by subclasses

Returns:
  • list[Solution]

    List[Solution]: Returns a sequence of olutions

Source code in digneapy/core/_solver.py
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
@abstractmethod
def __call__(self, problem: Problem, *args, **kwargs) -> list[Solution]:
    """Solves a optimisation problem

    Args:
        problem (Problem): Any optimisation problem or callablle that receives a Sequence and returns a Tuple[float].

    Raises:
        NotImplementedError: Must be implemented by subclasses

    Returns:
        List[Solution]: Returns a sequence of olutions
    """
    msg = "__call__ method not implemented in Solver"
    raise NotImplementedError(msg)