Skip to content

Commit

Permalink
Implement minor doc changes
Browse files Browse the repository at this point in the history
  • Loading branch information
arcondello committed Dec 13, 2022
1 parent 21e5f7f commit bffc4e1
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion dimod/binary/binary_quadratic_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
.. math::
E(\bf{v})
= \sum_{i=1} a_i v_i
= \sum_{i} a_i v_i
+ \sum_{i<j} b_{i,j} v_i v_j
+ c
\qquad\qquad v_i \in\{-1,+1\} \text{ or } \{0,1\}
Expand Down
4 changes: 2 additions & 2 deletions dimod/constrained/constrained.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
\quad m=1, \dots, M,
\end{align}
where :math:`\{ x_i\}_{i=1, \dots, N}` can be binary\ [#]_ or integer
where :math:`\{ x_i\}_{i=1, \dots, N}` can be binary\ [#]_, integer, or continuous
variables, :math:`a_{i}, b_{ij}, c` are real values,
:math:`\circ \in \{ \ge, \le, = \}` and :math:`M` is the total number of constraints.
Expand All @@ -33,7 +33,7 @@
:math:`i < j` because :math:`x^2 = x` for binary values :math:`\{0, 1\}`
and :math:`s^2 = 1` for spin values :math:`\{-1, 1\}`.
Constraints are often categorized as either "hard" or "soft". Any hard constraint
Constraints can be categorized as either "hard" or "soft". Any hard constraint
must be satisfied for a solution of the model to qualify as feasible. Soft
constraints may be violated to achieve an overall good solution. By setting
appropriate weights to soft constraints in comparison to the objective
Expand Down
10 changes: 5 additions & 5 deletions dimod/include/dimod/abc.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,16 @@ class QuadraticModelBase {
template <class T>
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.
Expand Down Expand Up @@ -259,7 +259,7 @@ class QuadraticModelBase {
template <class B, class I>
bool is_equal(const QuadraticModelBase<B, I>& 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`.
Expand Down
4 changes: 2 additions & 2 deletions dimod/include/dimod/binary_quadratic_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class BinaryQuadraticModel : public abc::QuadraticModelBase<Bias, Index> {
*
* [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
Expand All @@ -83,7 +83,7 @@ class BinaryQuadraticModel : public abc::QuadraticModelBase<Bias, Index> {
/// 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;
Expand Down
14 changes: 12 additions & 2 deletions dimod/include/dimod/constraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,19 @@ class Constraint : public Expression<Bias, Index> {

/// 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;

Expand All @@ -68,14 +73,19 @@ class Constraint : public Expression<Bias, Index> {

/// 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;

Expand Down
2 changes: 1 addition & 1 deletion docs/intro/intro_samplers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Example: Using a Reference Sampler

To find solutions to the small four-node
`maximum cut <https://en.wikipedia.org/wiki/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.
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit bffc4e1

Please sign in to comment.