Main Content

evaluateObjective

Evaluate QUBO (Quadratic Unconstrained Binary Optimization) objective

Since R2023a

Installation Required: This functionality requires MATLAB Support Package for Quantum Computing.

Description

objective = evaluateObjective(qprob,x) returns the value of the QUBO objective function x'*Q*x + c'*x + d, where the arguments Q, c, and d are the QuadraticTerm, LinearTerm, and ConstantTerm properties of qprob, respectively.

example

Examples

collapse all

Create a QUBO problem.

Q = [0 -1 2;...
    -1 0 4;...
    2 4 0];
c = [-5 6 -4];
d = 12;
qprob = qubo(Q,c,d)
qprob = 

  qubo with properties:

    QuadraticTerm: [3×3 double]
       LinearTerm: [-5 6 -4]
     ConstantTerm: 12
     NumVariables: 3

Evaluate the QUBO at the point [0;1;0].

x = [0;1;0];
objective = evaluateObjective(qprob,x)
objective =

    18

Evaluate the QUBO at the two points [0;1;0] and [1;0;1].

x = [x 1-x]
x =

     0     1
     1     0
     0     1
objective = evaluateObjective(qprob,x)
objective =

    18    7

Solve the problem and evaluate the objective at the solution.

result = solve(qprob);
objective = evaluateObjective(qprob,result.BestX)
objective =

     7

Input Arguments

collapse all

QUBO problem, specified as a qubo object. Create qprob using the qubo function.

Evaluation point, specified as a binary column vector or binary matrix. If x is a matrix, the objective output is a row vector with entry j corresponding to column j of x. evaluateObjective evaluates objective = x'*Q*x + c'*x + d.

Example: [1;0;1;1]

Data Types: double

Output Arguments

collapse all

Value of the QUBO objective function, returned as a double scalar or double vector. The output size depends on the input data size: If the input x is a column vector, the output is a scalar. If the input x is a matrix, the output is a vector.

Version History

Introduced in R2023a