Fixing quri-parts ansatz bug and refactoring #37
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refactor QAOA ansatz for quri-parts
バグ修正
https://github.com/Jij-Inc/JijModelingTranspilerQuantum/blob/8bcd73a0ff3ec04852b5aeda7b6afe11b00fd5a4/jijmodeling_transpiler_quantum/quri_parts/qaoa/to_qaoa.py#L99C1-L104C18
この部分の self.num_vars によって線形項がないときにansatzが適切な形にならないバグがありました。
以下のリファクタによりこのバグを修正しました。
関連するテストを追加し、通ることを確かめています。
get_qaoa_ansatz
のリファクタまた他実装を修正した方が良い部分があったので
ising_hamiltonian.py
をQAOAAnsatzクラスへ移植し、コードをシンプルにしました。定数の扱いの変更
また大きな変更として定数の扱いが異なっています。
これまでは
をそれぞれ、ising_constantはイジングハミルトニアンの定数へ、qubo_constant + ising_constant を返り値の定数。
という形でしたが、ハミルトニアンの定数には値を含めずに全て、返り値に含めるようにしました。