QUBO formulation for the knapsack problem
Converting a constraint problem into a QUBO (or an unconstrained) model requires the matrix to include all the constraint information. In Chapter 5, Using the Quantum Annealer – Developing a QUBO Function and Using Constraints, we developed the constraint for the number of employees. That constraint was relatively easy to implement as we were able to add terms right on top of the original matrix. Please review that chapter and its Simple penalty function to implement the constraint section before proceeding. As you will see, we must convert the “constrained” problem into a QUBO, which is a matrix where we do not have any constraints; the solver must be able to track the total weight of the items selected in the knapsack. How will it do this when we are simply giving a matrix? One way to think about this is that the QUBO matrix must include data for scenarios already mapped out for the QUBO solver. Alternatively, you could...