From bffc4e13227251d384562f0a60fad8a9c4ebacee Mon Sep 17 00:00:00 2001 From: arcondello Date: Tue, 13 Dec 2022 09:08:02 -0800 Subject: [PATCH] Implement minor doc changes --- dimod/binary/binary_quadratic_model.py | 2 +- dimod/constrained/constrained.py | 4 ++-- dimod/include/dimod/abc.h | 10 +++++----- dimod/include/dimod/binary_quadratic_model.h | 4 ++-- dimod/include/dimod/constraint.h | 14 ++++++++++++-- docs/intro/intro_samplers.rst | 2 +- docs/reference/models.rst | 2 +- 7 files changed, 24 insertions(+), 14 deletions(-) diff --git a/dimod/binary/binary_quadratic_model.py b/dimod/binary/binary_quadratic_model.py index b3021e237..628ba674b 100644 --- a/dimod/binary/binary_quadratic_model.py +++ b/dimod/binary/binary_quadratic_model.py @@ -17,7 +17,7 @@ .. math:: E(\bf{v}) - = \sum_{i=1} a_i v_i + = \sum_{i} a_i v_i + \sum_{i void add_quadratic_from_dense(const T dense[], index_type num_variables); - /// First neighbor of variable `v`. + /// Return an iterator to the beginning of the neighborhood of `v`. const_neighborhood_iterator cbegin_neighborhood(index_type v) const; - /// Last neighbor of variable `v`. + /// Return an iterator to the end of the neighborhood of `v`. const_neighborhood_iterator cend_neighborhood(index_type v) const; - /// First interaction (edges and quadratic coefficient) in an objective or constraint. + /// Return an iterator to the beginning of the quadratic interactions. const_quadratic_iterator cbegin_quadratic() const; - /// Last interaction (edges and quadratic coefficient) in an objective or constraint. + /// Return an iterator to the end of the quadratic interactions. const_quadratic_iterator cend_quadratic() const; /// Remove the offset and all variables and interactions from the model. @@ -259,7 +259,7 @@ class QuadraticModelBase { template bool is_equal(const QuadraticModelBase& other) const; - /// Return true if the model has no quadratic biases. + /// Test whether the model has no quadratic biases. bool is_linear() const; /// The linear bias of variable `v`. diff --git a/dimod/include/dimod/binary_quadratic_model.h b/dimod/include/dimod/binary_quadratic_model.h index 3018885fb..6b412769e 100644 --- a/dimod/include/dimod/binary_quadratic_model.h +++ b/dimod/include/dimod/binary_quadratic_model.h @@ -70,7 +70,7 @@ class BinaryQuadraticModel : public abc::QuadraticModelBase { * * [COOrdinate]: https://w.wiki/n$L * - * `row_iterator` must be a random access iterator pointig to the + * `row_iterator` must be a random access iterator pointing to the * beginning of the row data. `col_iterator` must be a random access * iterator pointing to the beginning of the column data. `bias_iterator` * must be a random access iterator pointing to the beginning of the bias @@ -83,7 +83,7 @@ class BinaryQuadraticModel : public abc::QuadraticModelBase { /// Add one (disconnected) variable to the BQM and return its index. index_type add_variable(); - /// Change the `vartype` of the BQM. + /// Change the variable type of the BQM. void change_vartype(Vartype vartype); bias_type lower_bound() const; diff --git a/dimod/include/dimod/constraint.h b/dimod/include/dimod/constraint.h index 1711e9d3a..319b6e851 100644 --- a/dimod/include/dimod/constraint.h +++ b/dimod/include/dimod/constraint.h @@ -51,14 +51,19 @@ class Constraint : public Expression { /// Return true for a one-hot constraint of discrete variables. bool is_onehot() const; + /// Return true for a soft constraint with a finite weight that can be violated. bool is_soft() const; - /// Mark as a constraint of discrete variables. + + /// Mark the constraint as encoding a discrete variable. void mark_discrete(bool mark = true); - /// Return true for a constraint of discrete variables. + + /// Return true if the constraint encodes a discrete variable. bool marked_discrete() const; + /// Return the penalty set for a soft constraint. Penalty penalty() const; + /// Return a constraint's right-hand side. bias_type rhs() const; @@ -68,14 +73,19 @@ class Constraint : public Expression { /// Sense (greater or equal, less or equal, equal) of a constraint. Sense sense() const; + /// Set the penalty for a soft constraint. void set_penalty(Penalty penalty); + /// Set a constraint's right-hand side. void set_rhs(bias_type rhs); + /// Set the sense (greater or equal, less or equal, equal) of a constraint. void set_sense(Sense sense); + /// Set the weight for a soft constraint. void set_weight(bias_type weight); + /// Return a soft constraint's weight. bias_type weight() const; diff --git a/docs/intro/intro_samplers.rst b/docs/intro/intro_samplers.rst index 897ca0dbd..e762490e0 100644 --- a/docs/intro/intro_samplers.rst +++ b/docs/intro/intro_samplers.rst @@ -21,7 +21,7 @@ Example: Using a Reference Sampler To find solutions to the small four-node `maximum cut `_ -BQM generated in the :ref:`intro_qm` section, shown again in the figure below, +BQM generated in the :ref:`intro_models` section, shown again in the figure below, you can use one of dimod's reference samplers: its :class:`~dimod.reference.samplers.ExactSolver` test sampler, for example, calculates the energy of all possible samples. diff --git a/docs/reference/models.rst b/docs/reference/models.rst index d1bfe6e61..3297d9b3b 100644 --- a/docs/reference/models.rst +++ b/docs/reference/models.rst @@ -5,7 +5,7 @@ Models: BQM, CQM, QM, Others ============================ This page describes the `dimod` package's quadratic models: classes, -attributes, and methods. For an introduction and the data structure, see :ref:`intro_qm`. +attributes, and methods. For an introduction and the data structure, see :ref:`intro_models`. .. contents:: :local: