Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing variables on quadratic expression causes memory errors. #1351

Closed
arcondello opened this issue Jul 6, 2023 · 0 comments · Fixed by #1352
Closed

Fixing variables on quadratic expression causes memory errors. #1351

arcondello opened this issue Jul 6, 2023 · 0 comments · Fixed by #1352
Labels

Comments

@arcondello
Copy link
Member

Description
#1319 introduced a bug in `dimod::ConstrainedQuadraticModel::fix_variables()``.

Steps To Reproduce

#include "dimod/constrained_quadratic_model.h"

auto cqm = dimod::ConstrainedQuadraticModel<double>();

cqm.add_variables(dimod::Vartype::BINARY, 5);

auto c = cqm.add_linear_constraint({3, 1, 4, 0}, {1, 2, 3, 4}, dimod::Sense::LE, 5);
cqm.constraint_ref(c).add_quadratic(3, 1, -15);
cqm.constraint_ref(c).add_quadratic(4, 0, 14);
cqm.constraint_ref(c).add_quadratic(4, 3, 17);

std::vector<int> variables{1, 2, 3};
std::vector<double> values{1, 1, 1};

cqm.fix_variables(variables.begin(), variables.end(), values.begin());

will cause memory corruption.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant