dwavesystems / dwave-optimization

Enables the formulation of nonlinear models for industrial optimization problems.
https://docs.ocean.dwavesys.com/en/stable/docs_optimization/index.html#index-optimization
Apache License 2.0
7 stars 18 forks source link

Add `compress` kwarg to `Model.to_file()` and `States.to_file()` #150

Closed arcondello closed 1 week ago

arcondello commented 1 month ago

By default this maintains the existing behavior but allows us to toggle it via a keyword argument.

See also https://github.com/dwavesystems/dimod/pull/1296

arcondello commented 4 weeks ago

On the one hand, this is a pretty harmless PR, on the other I am underwhelmed with the results. A simple benchmark

10000 binary variables in a single array with 25 states, uncompressed
serialization time: 0.006702525999571662s
file size in bytes: 2007953 bytes
10000 binary variables in a single array with 25 states, compressed
serialization time: 0.06300492599984864s
file size in bytes: 83618 bytes
10000 binary variables as 10000 scalars with 25 states, uncompressed
serialization time: 9.95059110299917s
file size in bytes: 74242127 bytes
10000 binary variables in a single array with 25 states, compressed
serialization time: 13.670800387000781s
file size in bytes: 57585889 bytes
arcondello commented 1 week ago

Closing this as stale for now. It's not a bad idea, but perhaps needs more thinking before we actually merge it.