QuipNetwork / QuipNetwork/xquad
[Feature Request] Add XQCP support for XQMXDomain.DISCRETE
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 18
- PR merge metrics
- No merged PRs in 30d
Description
Summary
Please add support for XQMXDomain.DISCRETE in the XQCP layer.
Motivation
I am using XQCP to formulate a portfolio-rebalancing optimisation problem. Each asset has a bounded discrete portfolio weight, such as an integer value from 0 to SCALE, rather than only a binary decision.
Currently, I need to encode each weight using multiple binary variables. Binary or thermometer encoding increases the number of variables and QUBO interactions significantly, especially when the portfolio contains many assets.
Direct discrete-variable support would allow the portfolio model to represent one discrete weight variable per asset more naturally and efficiently.
Intended usage
Conceptually, I would like to be able to define a model similar to:
from xqcp import Problem
from xqvm_py import XQMXDomain
problem = Problem("PortfolioRebalancing")
problem.define_model(
size=number_of_assets,
domain=XQMXDomain.DISCRETE,
)
The discrete variables would need either:
- An integer range, such as
0..SCALE; or - An explicitly supplied set of permitted values.
For the portfolio model, the weights would also be constrained to sum to SCALE.
Desired behaviour
It would be helpful if XQCP could:
- Compile models using
XQMXDomain.DISCRETE. - Allow the permitted range or values to be specified.
- Generate appropriate encoder, verifier and decoder programs.
- Pass the resulting discrete model to compatible XQSA solver backends.
- Include a small example demonstrating discrete variables.
I am happy to test an implementation branch using my portfolio-rebalancing model and report any problems.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the XQCP layer and the Problem.define_model API, then trace how XQMXDomain values are compiled. Review the encoder, verifier, decoder, and compatible XQSA backend paths. Done means discrete ranges or value sets compile successfully, a discrete model example is included, and the portfolio-style usage works end to end.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100