Add a shrink_to_fit function for the quadratic models.
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.
Do you want this just at the C++ level or the Cython level as well? Probably not the Python level...
As far
Do you want this just at the C++ level or the Cython level as well? Probably not the Python level...
For my purpose I only need C++ level one, so that in the function toBQM, I can call it at the end. But as I said it will only matter if we need to allocate more memory after the call to toBQM. Cannot confirm the last statement till I have gone through all the hss code.