- class Presolver(cqm: dimod.constrained.constrained.ConstrainedQuadraticModel, *, move: bool = False)¶
Presolver for constrained quadratic models.
cqm – A
move – If
True, the original constrained quadratic model is cleared and its contents are moved to the presolver. This is useful for large models where memory is a concern.
>>> import dimod >>> from dwave.preprocessing import Presolver
Given a CQM with one variable fixed by bounds
>>> cqm = dimod.ConstrainedQuadraticModel() >>> i = dimod.Integer('i', lower_bound=-5, upper_bound=5) >>> j = dimod.Integer('j', lower_bound=5, upper_bound=10) >>> cqm.set_objective(i + j) >>> c0 = cqm.add_constraint(j <= 5) # implicitly fixes 'j'
Then run the presolved with default settings.
>>> presolver = Presolver(cqm) >>> presolver.load_default_presolvers() >>> presolver.apply()
# The model has been reduced
>>> reduced_cqm = presolver.copy_model() >>> reduced_cqm.num_variables() 1 >>> reduced_cqm.num_constraints() 0
Apply any loaded presolve techniques to the held model.
Return a copy of the held CQM.
Clear the held model.
Load the default presolvers.
Restore a set of reduced samples to the original variable labels.
doxygenclass: Cannot find class “dwave::presolve::Presolver” in doxygen xml output for project “minorminer” from directory: /home/docs/checkouts/readthedocs.org/user_builds/d-wave-systems-dwave-ocean-sdk/checkouts/stable/minorminer/docs/build-cpp/xml/
doxygenclass: Cannot find class “dwave::presolve::Postsolver” in doxygen xml output for project “minorminer” from directory: /home/docs/checkouts/readthedocs.org/user_builds/d-wave-systems-dwave-ocean-sdk/checkouts/stable/minorminer/docs/build-cpp/xml/