dwavesystems / dwavesystems/dimod

Add a shrink_to_fit function for the quadratic models.

Open
#937 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
143
Forks
91
Avg merge
1h 24m
Merged PRs (30d)
3

Description

**Application**
It will shrink the size of the quadratic models to what is actually required. Though when creating the CQM through serialization we calculate how much memory will be required exactly, there are other phases where that is not possible, it may help in those scenarios if there are later steps to that which allocate memory (so the added memory allocation do not exceed the total system memory). If there are no later steps then it is not required.

**Proposed Solution**
We just need to call the function shrink_to_fit() for all the vectors contained in the object.

**Alternatives Considered**
We could have a reserve function, to reserve memory for the individual functions in the quadratic model. This alternative will be more efficient but we will have to insert additional code to calculate the size of the vectors in the different functions. Given the creation of a quadratic model is not one of the hottest functions. shrink_to_fit() is simpler.

**Additional Context**
There are some functions where we use add/set_quadratic, and we want to keep those functions simple and call shrink_to_fit for the quadratic model objects.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.