How to declare non-binary decision variables in an optimization problem?

I am working on a logistics problem which require me to find the optimum quantity of product to be manufactured and also to be shipped to satisfy the customer demand. I have made a decision variable $$y_{ijp}$$ where this variable gives me the qty of product $$p$$ shipped from node $$i$$ to $$j$$. I have done some simple optimization examples previously on Qiskit and D-Wave, but I am not sure how to tackle this problem, since all the decision variables I encountered earlier were binary. Any resources or help regarding this?

• You can try to express the non-binary variable as sum $\sum 2^i x_i$, where $x_i$ is a binary variable. In the end you have binary optimization. Jun 21, 2022 at 6:19
• For Qiskit take a look at the optimization tutorials qiskit.org/documentation/optimization/tutorials/index.html. It has converters that deal with integer variable as input. Also there is a warm starting optimizer tutorial around this too. Jun 21, 2022 at 13:39
• @SteveWood, i have gone through these tutorials, the main issue is, while having an integer variable in my model, it adds a constraints, that in turn adds slack variables, which results in lot of qubits being used. I have to get a way past that
– user21029
Jun 22, 2022 at 7:11
• Hi, @MartinVesely, can you elaborate or share a resource related to your answer. Thanks
– user21029
Jun 22, 2022 at 7:13

Perhaps what you really want to know is how to represent integral or rational variables using binary variables. The answer by Martin Vesely explains how to do it. Basically, you represent a non-binary variable $$x$$ with a bunch of binary variables $$y_j$$. $$\tag{1} x = \sum_{i=0}^{n-1} 2^i y_i + \sum_{j=1}^m 2^{-j} y_j.$$ If you want $$x$$ to be a float, then $$m > 0$$ and it determines the precision. Mind that this is not a good idea because your problem now has more variables than the original problem. Also, your feasibility space will be exponentially smaller compared to the solution space. Moreover, the new problem will require much more quantum resources.