Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Story] Investigate Manifold Convex Class Model and Convex Optimization #7

Closed
gcattan opened this issue Oct 5, 2021 · 9 comments
Closed
Labels

Comments

@gcattan
Copy link
Collaborator

gcattan commented Oct 5, 2021

The work is twofold:

  1. Investigate [1] which is an approach to transform SPD classes in a convex model.
  2. Investigate [2], which a quantum approach to convex optimization.

[1] K. Zhao, A. Wiliem, S. Chen, and B. C. Lovell, ‘Convex Class Model on Symmetric
Positive Definite Manifolds’, ArXiv180605343 Cs, May 2019, Accessed: Sep. 24, 2021.
[Online]. Available: http://arxiv.org/abs/1806.05343

[2] J. van Apeldoorn, A. Gilyén, S. Gribling, and R. de Wolf, ‘Convex optimization using
quantum oracles’, Quantum, vol. 4, p. 220, Jan. 2020, doi: 10.22331/q-2020-01-13-220

Quantum convex optimization example:
https://qiskit.org/documentation/tutorials/optimization/5_admm_optimizer.html
https://medium.com/qiskit/towards-quantum-advantage-for-optimization-with-qiskit-9a564339ef26

cvxpy examples:
https://www.cvxpy.org/examples/basic/sdp.html
https://math.stackexchange.com/questions/4109504/solving-the-multi-dimensional-scaling-problem-in-cvxpy

@qbarthelemy
Copy link
Member

[1] looks like the MDM published by Barachant in 2012.

@gcattan
Copy link
Collaborator Author

gcattan commented Oct 6, 2021

Yes, looks like you also got a special thank :)

image

@gcattan
Copy link
Collaborator Author

gcattan commented Oct 6, 2021

[1] looks like the MDM published by Barachant in 2012.

Yes, you are right. One practical impediment I see is to transform the actual implementation using constraint programming, as at first sight, Qiskit is taking a convex model as an input for quantum optimization.

One aspect which seems not discussed in the above paper is also the determination of the class prototypes.
In pyRiemann some of the mean_ algorithms are iterative. May be worth trying to express them using constraint programming and investigate if there are some outcomes when running on a quantum simulator. But these are only intuitive suggestions opened to discussion.

@gcattan gcattan mentioned this issue Oct 10, 2021
@gcattan
Copy link
Collaborator Author

gcattan commented Oct 20, 2021

Technical update:

@gcattan
Copy link
Collaborator Author

gcattan commented Nov 27, 2021

Here is a template on how could look like an implementation of mean_ (MDM still in the box) using constraint programming (not tested, probably need some improvement):

def fro_mean_convex(covmats, sample_weight=None):
    n_trials, n_channels, _ = covmats.shape
    channels=range(n_channels)
    trials=range(n_trials)

    prob = Model()

    ContinuousVarType.one_letter_symbol = lambda _: 'C'
    X_mean = prob.continuous_var_matrix(keys1=channels, keys2=channels,
                                        name='fro_mean', lb=-prob.infinity) 

    def _fro_dist(A, B):
        return prob.sum_squares(A[r, c] - B[r,c] for r in channels for c in channels)

    objectives = prob.sum(_fro_dist(covmats[i], X_mean) for i in trials)
    
    prob.set_objective("min", objectives)

    qp = QuadraticProgram()
    qp.from_docplex(prob)
    
    result = CobylaOptimizer().solve(qp)

    return np.reshape(result.x, (n_channels, n_channels))

The problem is that Qiskit only supports problems with unconstrained binary variables (see ADMM documentation):

image

A naive approach to work around this problem could be to round covariance matrices to some precision and convert the resulting integers to binary.

Here is the official response from Qiskit when I asked:

If you want to deal with continuous variables quantumly, you need to encode it with qubits. Because the number of qubits is very limited, you need to encode it by yourself, for example, in a form coeff * integer_var.

However, it might be possible to directly optimize problems with continuous variables on quantum (CV QAOA algorithm).

I contacted the first author from this paper who pointed me to this resource:

https://docs.google.com/presentation/d/1_OiNA9QG9vzJFBwPAxuPzjm6DDXKRRw2LGwS_XI6OGM/edit#slide=id.p1

@sylvchev
Copy link
Member

sylvchev commented Dec 3, 2021

Super interesting! Do you think it is possible to adapt the Guillaume Verdon's approach? It is not clear for me how we could do that.

@gcattan
Copy link
Collaborator Author

gcattan commented Dec 3, 2021

I am not sure either how to start. Probably need to look at the QAOA implementation of Qiskit again, before doing a POC for CV-QAOA. But Guillaume Verdon seems confident we can implement it on Qiskit, and I understood he is working on implementation with TensorFlow quantum.
That said I am also contacting the author of the integer-to-binary converter to confirm the naive approach.

@gcattan gcattan changed the title Investigate Manifold Convex Class Model and Convex Optimization [Story] Investigate Manifold Convex Class Model and Convex Optimization Jan 27, 2022
@gcattan
Copy link
Collaborator Author

gcattan commented Jan 27, 2022

#26
#27
#28
#29
#30
#32

This was referenced Aug 20, 2022
@gcattan gcattan added the story label Jun 5, 2023
@gcattan
Copy link
Collaborator Author

gcattan commented Jan 14, 2025

Closing this task as completed.
The implementation is covered by the NCH and NaiveQAOAOptimizer/QAOACVOptimizer in the docplex module.

@gcattan gcattan closed this as completed Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants