neurop.Problem.TSPProblem

class neurop.Problem.TSPProblem(graph: Graph, initializer=None, penalty=10)

Bases: BaseProblem

Traveling Salesperson Problems

__init__(graph: Graph, initializer=None, penalty=10)

Initializes the TSP problem.

Parameters:
  • problem (OptProblem) – the optlang problem

  • initializer (_type_, optional) – function to initialize the parameters of the problem. Defaults to None, which means that parameters will be randomly initialized.

Methods

__init__(graph[, initializer, penalty])

Initializes the TSP problem.

convert_to_model(model_type[, backend])

Converts the problem to a model of given type, if supported.

evaluate_constraints(params)

Evaluates the constraints of the problem for a given set of (binary) parameter values.

evaluate_objective(params)

Evaluates the objective function of the problem for a given set of (binary) parameter values.

supports_model(model_type)

to_qubo([backend])

convert_to_model(model_type, backend=None) BaseModel

Converts the problem to a model of given type, if supported.

Parameters:

backend (Backend, optional) – The backend for which to derive the QUBO form. Defaults to None, which means no special requirements are imposed on the Q matrix.

Raises:

ValueError – May return a ValueError if the problem cannot be converted to the required model type.

Returns:

returns the QUBO matrix

Return type:

np.ndarray

evaluate_constraints(params: ndarray) Iterable[bool]

Evaluates the constraints of the problem for a given set of (binary) parameter values.

evaluate_objective(params: ndarray) float

Evaluates the objective function of the problem for a given set of (binary) parameter values.