Open FedeHR opened 3 months ago
Thank you for providing a detailed description of the issue and your proposed solution. Your approach to modifying the to_quadratic_program() function makes sense, especially since you've already tested the solution and confirmed it works with custom graphs. We encourage you to submit a Pull Request (PR) with your changes, as it will help us review, test, and integrate the improvements you’ve suggested. Please let us know if you need any help with the PR process!
Environment
What is happening?
Dear qiskit-optimization team, I believe the implementation of the
to_quadratic_program()
function of the TSP application could be improved. The problem I'm facing is that I'm currently using custom graphs, and the function is apparently only compatible with geometric graphs. The random instance generator of TSP uses this kind of graphs, so the problem does not arise when using the provided instance generator. However, I want to use a different type of graph in my implementation.How can we reproduce the issue?
My graph has the following edges:
When trying to convert the TSP instance of my graph into a quadratic program I get the following error:
What should happen?
I would expect the
to_quadratic_program()
function to be compatible with any graph, as is the case with the MaxCut application.Any suggestions?
I tried to adjust the source code and modify it to match the MaxCut implementation of the function. In the following code snippet you can see the original implementation of the problematic code and my alternative (under
# New
).If you compare the original implementation with that of MaxCut, you can see that TSP iterates over all possible edges, while I think it should be iterating over the existing edges only.
My implementation works with any graph, but the problem instance / Ising hamiltonian I get is different from that of the original implementation. I greatly appreciate your support. Best regards, Federico