Skip to content
This repository was archived by the owner on Aug 21, 2023. It is now read-only.

Fix for DCPError gives DQCPError now #932

Closed
kjijogeorge opened this issue Jul 6, 2020 · 5 comments · Fixed by qiskit-community/qiskit-aqua#1190
Closed

Fix for DCPError gives DQCPError now #932

kjijogeorge opened this issue Jul 6, 2020 · 5 comments · Fixed by qiskit-community/qiskit-aqua#1190
Assignees
Labels
bug Something isn't working

Comments

@kjijogeorge
Copy link

Informations

  • Qiskit 0.14.2:
  • Python 3.8.3:
  • RHEL:

What is the current behavior?

With respect to the issue #928. I tested with the suggested modifications of "qcp=True" in a private env and also tested after installing from source. The example notebook for QSVM still fails with the following error

---------------------------------------------------------------------------
DQCPError                                 Traceback (most recent call last)
<ipython-input-5-8f397c5bed84> in <module>
      1 #from IPython.core.debugger import set_trace
      2 #set_trace()
----> 3 result = qsvm.run(quantum_instance)
      4 
      5 print("testing success ratio: {}".format(result['testing_accuracy']))

~/Work/Project_Q/qiskit-aqua/qiskit/aqua/algorithms/quantum_algorithm.py in run(self, quantum_instance, **kwargs)
     68                 self.quantum_instance = quantum_instance
     69 
---> 70         return self._run()
     71 
     72     @abstractmethod

~/Work/Project_Q/qiskit-aqua/qiskit/aqua/algorithms/classifiers/qsvm/qsvm.py in _run(self)
    456 
    457     def _run(self):
--> 458         return self.instance.run()
    459 
    460     @property

~/Work/Project_Q/qiskit-aqua/qiskit/aqua/algorithms/classifiers/qsvm/_qsvm_binary.py in run(self)
    134     def run(self):
    135         """Put the train, test, predict together."""
--> 136         self.train(self._qalgo.training_dataset[0], self._qalgo.training_dataset[1])
    137         if self._qalgo.test_dataset is not None:
    138             self.test(self._qalgo.test_dataset[0], self._qalgo.test_dataset[1])

~/Work/Project_Q/qiskit-aqua/qiskit/aqua/algorithms/classifiers/qsvm/_qsvm_binary.py in train(self, data, labels)
     81         labels = labels * 2 - 1  # map label from 0 --> -1 and 1 --> 1
     82         labels = labels.astype(np.float)
---> 83         [alpha, b, support] = optimize_svm(kernel_matrix, labels, scaling=scaling)
     84         support_index = np.where(support)
     85         alphas = alpha[support_index]

~/Work/Project_Q/qiskit-aqua/qiskit/aqua/utils/qp_solver.py in optimize_svm(kernel_matrix, y, scaling, maxiter, show_progress, max_iters)
     88         [G@x <= h,
     89          A@x == b])
---> 90     prob.solve(verbose=show_progress, qcp=True)
     91     result = np.asarray(x.value).reshape((n, 1))
     92     alpha = result * scaling

~/.conda/envs/quant_src/lib/python3.8/site-packages/cvxpy/problems/problem.py in solve(self, *args, **kwargs)
    288         else:
    289             solve_func = Problem._solve
--> 290         return solve_func(self, *args, **kwargs)
    291 
    292     @classmethod

~/.conda/envs/quant_src/lib/python3.8/site-packages/cvxpy/problems/problem.py in _solve(self, solver, warm_start, verbose, parallel, gp, qcp, **kwargs)
    550         if qcp and not self.is_dcp():
    551             if not self.is_dqcp():
--> 552                 raise error.DQCPError("The problem is not DQCP.")
    553             reductions = [dqcp2dcp.Dqcp2Dcp()]
    554             if type(self.objective) == Maximize:

DQCPError: The problem is not DQCP.

Steps to reproduce the problem

Running the sample notebook for QSVM.

What is the expected behavior?

Should work normally.
Or is there any special format for the data used with QSVM that should be checked?

@rraymondhp
Copy link
Contributor

I also have similar issues.

@nonhermitian
Copy link
Contributor

Same:

DCPError: Problem does not follow DCP rules. Specifically:
The objective is not DCP. Its following subexpressions are not:
QuadForm(var0, [[ 1.          0.05078125  0.49902344 ... -0.515625   -0.15527344
  -0.31347656]
 [ 0.05078125  1.          0.02832031 ... -0.04882812 -0.11523438
  -0.01171875]
 [ 0.49902344  0.02832031  1.         ... -0.15527344 -0.14453125
  -0.34082031]
 ...
 [-0.515625   -0.04882812 -0.15527344 ...  1.          0.58398438
   0.04589844]
 [-0.15527344 -0.11523438 -0.14453125 ...  0.58398438  1.
   0.32128906]
 [-0.31347656 -0.01171875 -0.34082031 ...  0.04589844  0.32128906
   1.        ]])

@amitracal
Copy link

I am getting this error still, will appreciate if this is fixed as soon as possible as the following notebook has been shared with a JDA client and need to be discussed with them soon - https://quantum-computing.ibm.com/jupyter/tutorial/advanced/aqua/machine_learning/qsvm_classification.ipynb

`DCPError: Problem does not follow DCP rules. Specifically:
The objective is not DCP. Its following subexpressions are not:
QuadForm(var45, [[ 1. 0.203125 0.73632812 ... -0.31054688 -0.03515625
-0.01269531]
[ 0.203125 1. 0.453125 ... -0.54980469 -0.01269531
-0.03710938]
[ 0.73632812 0.453125 1. ... -0.28808594 -0.01171875
-0.14941406]
...
[-0.31054688 -0.54980469 -0.28808594 ... 1. 0.4296875
0.14941406]
[-0.03515625 -0.01269531 -0.01171875 ... 0.4296875 1.
0.62890625]
[-0.01269531 -0.03710938 -0.14941406 ... 0.14941406 0.62890625

  1.    ]])
    

`

@nonhermitian
Copy link
Contributor

Those notebooks are many months old and have not been updated as of yet. The lastest ones are currently in the Qiskit documentation

@stefan-woerner
Copy link
Contributor

@amitracal The PR qiskit-community/qiskit-aqua#1190 fixes the problem for now and the notebook works for me.
We'll look into how to best integrate this and make it more transparent what is happening.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants