Developing New Components#
The dwave-hybrid framework enables you to build your own components to incorporate into your workflow.
The key superclass is the Runnable
class: all basic components—samplers,
decomposers, composers—and flow-structuring components such as branches inherit
from this class. A Runnable
is run for an iteration in which it updates
the State
it receives. Typical methods are run or next to execute an
iteration and stop to terminate the Runnable
.
The Primitives and Flow Structuring sections describe, respectively, the basic Runnable
classes (building blocks) and flow-structuring ones and their methods. If you are
implementing these methods for your own Runnable
class, see comments in
the code.
The Racing Branches graphic below shows the top-down composition (tree structure) of a hybrid loop.
State traits are verified for all Runnable
objects that inherit
from StateTraits
or its subclasses. Verification includes:
Minimal checks of workflow construction (composition of
Runnable
classes)Runtime checks
All built-in Runnable
classes declare state traits requirements that are
either independent (for simple ones) or derived from a child workflow. Traits of a new
Runnable
must be expressed and modified at construction time by its parent.
When developing new Runnable
classes, constructing composite traits can be
nontrivial for some advanced flow-control runnables.
The Dimod Conversion section describes the HybridRunnable
class you can use to produce a Runnable
sampler based on
a dimod sampler.
The Utilities section provides a list of useful utility methods.