Problems

QAOA and related solvers accept a QAOAProblem instance that encapsulates the optimization objective, mixer, initial state, and solution decoding. Divi provides concrete classes for common graph and binary optimization problems.

divi.qprog.problems Package

Functions

binary_block_config(n_customers, n_vehicles)

Compute the binary encoding layout.

check_matching_matrix(M, A)

Validate that adjacency matrix M is a valid matching in graph A.

create_tsp_qubo(cost_matrix[, start_city, ...])

Generate a QUBO for TSP with a fixed start city.

cvrp_block_structure(n_customers, n_vehicles)

Return the block structure for CVRP CE-QAOA.

draw_graph_solution_nodes(main_graph, ...)

Visualize a graph with solution nodes highlighted.

draw_partitions(graph, reverse_index_maps[, ...])

Draw a graph with nodes colored by partition.

is_valid_matching(edges)

Check that no node appears in more than one selected edge.

is_valid_tsp_tour(bitstring, n_cities)

Check if a bitstring represents a valid TSP tour.

parse_tsplib_file(path)

Parse a TSPLIB/CVRPLIB format .vrp or .tsp file.

parse_vrp_solution(path)

Parse a CVRPLIB solution file.

tour_cost(tour, cost_matrix)

Compute the total travel cost of a tour.

Classes

BinaryBlockConfig(n_customers, n_vehicles, ...)

Configuration for binary-encoded CE-QAOA blocks.

BinaryOptimizationProblem(problem, *[, ...])

Generic QUBO or HUBO problem for QAOA.

CVRPProblem(cost_matrix, *, demands, ...[, ...])

Capacitated Vehicle Routing Problem for QAOA.

GraphPartitioningConfig([...])

Configuration for graph partitioning algorithms.

MaxCliqueProblem(graph, *[, is_constrained, ...])

Max clique problem on a graph.

MaxCutProblem(graph, *[, is_constrained, config])

MaxCut problem on a graph.

MaxIndependentSetProblem(graph, *[, ...])

Max independent set problem on a graph.

MaxWeightCycleProblem(graph, *[, ...])

Max weight cycle problem on a directed graph.

MaxWeightMatchingProblem(graph[, ...])

Maximum-weight matching problem for QAOA.

MinVertexCoverProblem(graph, *[, ...])

Min vertex cover problem on a graph.

QAOAProblem()

Base class for all QAOA-compatible problems.

RoutingInstance([name, comment, ...])

Parsed VRP/TSP instance data.

TSPProblem(cost_matrix, *[, start_city, ...])

Traveling Salesman Problem for QAOA.