Robot problems as QUBOs#
Robot problems posed as binary optimisation (QUBO), ready for classical and quantum solvers.
Three problems that a robot team actually has, each with its encoding, the true objective (without the penalty terms) and a feasibility check, so a solver’s answer can be judged on the robot’s terms and not only on the QUBO energy:
multi_robot_allocation(): assign every task to one robot at the lowest total cost, optionally balancing the load.grasp_selection(): pick exactlykgrasp candidates of high quality that do not conflict (for example because they need the same finger or the same contact point).slot_scheduling(): give every robot that shares a workspace a time slot so that robots whose motions conflict never move together (graph colouring with a fixed number of slots).
The encodings are the standard penalty formulations of Lucas (2014); what this module adds is the robot vocabulary, the true objectives and the decoding.
Classes
A robot problem with its QUBO encoding. |
Functions
Assign every task to exactly one robot. |
|
Choose exactly |
|
Give every robot a time slot so that conflicting robots never share one. |
- class RobotProblem(name, qubo, objective, feasible, decode)[source]#
Bases:
objectA robot problem with its QUBO encoding.
- Variables:
name (
str)qubo (
Qubo) – The encoding; variable order is documented by each builder.objective (
callable) –objective(x): the true objective of a bit string (lower is better), without penalties.feasible (
callable) –feasible(x): whether the bit string satisfies the problem’s hard constraints.decode (
callable) –decode(x): the bit string in the robot’s vocabulary (who does what, which grasps, which slots).
- Parameters:
- optimum()[source]#
Exhaustive optimum of the true objective over feasible bit strings (n at most 22).
- Returns:
x (
numpy.ndarray)value (
float)
- multi_robot_allocation(costs, balance=0.0, penalty=None)[source]#
Assign every task to exactly one robot.
- Parameters:
costs (
array_like) –costs[r, t]: cost of robotrdoing taskt(travel time, energy, …).balance (
float, optional) – Weight of a load-balancing term \(\lambda \sum_r (\sum_t x_{r,t})^2\) that discourages piling tasks on one robot (0 ignores balance).penalty (
float, optional) – One-robot-per-task penalty (default: large enough to dominate the costs).
- Returns:
RobotProblem– Variable \(x_{r,t}\) has indexr * n_tasks + t.objectiveis the total cost plus the balance term.
Examples
>>> import numpy as np >>> from quantum_mind.computing import multi_robot_allocation >>> p = multi_robot_allocation(np.array([[1.0, 5.0], [4.0, 2.0]])) >>> x, value = p.optimum() >>> p.decode(x), value ({0: [0], 1: [1]}, 3.0)
- grasp_selection(quality, conflict, k, penalty=None)[source]#
Choose exactly
kgrasps of high total quality that do not conflict.Minimises \(-\sum_i q_i x_i + \sum_{i<j} c_{ij} x_i x_j\) subject to \(\sum_i x_i = k\).
- Parameters:
quality (
array_like) –quality[i]: quality of grasp candidatei(for example a force-closure margin), higher is better.conflict (
array_like) – Symmetric(n, n)matrix;conflict[i, j] > 0is the cost of choosing bothiandj.k (
int) – Number of grasps to choose.penalty (
float, optional) – Cardinality penalty (default: large enough to dominate).
- Returns:
RobotProblem– Variableiis graspi.objectiveis \(-\sum q_i x_i + \sum c_{ij} x_i x_j\).
- slot_scheduling(conflicts, n_slots, penalty=None)[source]#
Give every robot a time slot so that conflicting robots never share one.
- Parameters:
- Returns:
RobotProblem– Variable \(x_{i,s}\) has indexi * n_slots + s.objectiveis the number of conflicting pairs that share a slot (0 is a valid schedule).