# dwave_networkx.default_sampler.set_default_sampler¶

set_default_sampler(sampler)[source]

Sets a default binary quadratic model sampler.

Parameters: sampler – A binary quadratic model sampler. A sampler is a process that samples from low-energy states in models defined by an Ising equation or a Quadratic Unconstrained Binary Optimization Problem (QUBO). A sampler is expected to have a ‘sample_qubo’ and ‘sample_ising’ method. A sampler is expected to return an iterable of samples, in order of increasing energy.

Examples

This example sets sampler0 as the default sampler and finds an independent set for graph G, first using the default sampler and then overriding it by specifying a different sampler.

>>> dnx.set_default_sampler(sampler0)  # doctest: +SKIP
>>> indep_set = dnx.maximum_independent_set_dm(G)  # doctest: +SKIP
>>> indep_set = dnx.maximum_independent_set_dm(G, sampler1)  # doctest: +SKIP