Skip to content

Commit

Permalink
Add overload of ConstrainedQuadraticModel::fix_variables() that takes…
Browse files Browse the repository at this point in the history
… initializer lists
  • Loading branch information
arcondello committed Apr 17, 2023
1 parent eaeefd5 commit 92396b0
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion dimod/include/dimod/constrained_quadratic_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ class ConstrainedQuadraticModel {
/// Create a new model by fixing many variables.
template <class VarIter, class AssignmentIter>
ConstrainedQuadraticModel fix_variables(VarIter first, VarIter last,
AssignmentIter assignments) const;
AssignmentIter assignment) const;

/// Create a new model by fixing many variables.
template <class T>
ConstrainedQuadraticModel fix_variables(std::initializer_list<index_type> variables,
std::initializer_list<T> assignments) const;

/// Return the lower bound on variable ``v``.
bias_type lower_bound(index_type v) const;
Expand Down Expand Up @@ -554,6 +559,14 @@ ConstrainedQuadraticModel<bias_type, index_type>::fix_variables(VarIter first, V
return cqm;
}

template <class bias_type, class index_type>
template <class T>
ConstrainedQuadraticModel<bias_type, index_type>
ConstrainedQuadraticModel<bias_type, index_type>::fix_variables(
std::initializer_list<index_type> variables, std::initializer_list<T> assignments) const {
return fix_variables(variables.begin(), variables.end(), assignments.begin());
}

template <class bias_type, class index_type>
bias_type ConstrainedQuadraticModel<bias_type, index_type>::lower_bound(index_type v) const {
return varinfo_[v].lb;
Expand Down

0 comments on commit 92396b0

Please sign in to comment.