QuipNetwork / QuipNetwork/xquad

[Feature Request] Add XQCP support for XQMXDomain.DISCRETE

Open
#1 1 comment 0 reactions 0 assignees View on GitHub

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:

  1. Compile models using XQMXDomain.DISCRETE.
  2. Allow the permitted range or values to be specified.
  3. Generate appropriate encoder, verifier and decoder programs.
  4. Pass the resulting discrete model to compatible XQSA solver backends.
  5. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.