dimod icon indicating copy to clipboard operation
dimod copied to clipboard

Support for single-binary-variable discrete variable

Open JoelPasvolsky opened this issue 3 years ago • 1 comments

Application Currently dimod.ConstrainedQuadraticModel.add_discrete() rejects discrete variables with fewer than two binary variables. I think it makes sense to support a single-binary-variable discrete because that can be a use case for a programmable range of N down to one; something like,

x = dimod.Binaries([f"x{i}" for i in range(USER_SELECTION)])

where for the case of len(x) == 1 the binary var is always 1 (selected).

Proposed Solution Allow single-bainary discrete vars

Additional Context I ran into this in an example where the user can select the supported number of modes, which constitute a discrete variable, and may select a single mode.

JoelPasvolsky avatar Oct 31 '22 13:10 JoelPasvolsky

That would be a constant, not a variable. At some point we'd like to add support for constants but it's not supported at the moment.

arcondello avatar Oct 31 '22 15:10 arcondello

I am warming to this idea. Especially now that we treat discreteness as a marker rather than a true flag. And also because presolve will remove invalid markers and will fix the constant variable.

arcondello avatar Mar 01 '23 17:03 arcondello