qiskit.optimization.converters.quadratic_program_converter의 소스 코드
# This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
"""An abstract class for optimization algorithms in Qiskit's optimization module."""
import warnings
from abc import ABC, abstractmethod
import qiskit.optimization.algorithms # pylint: disable=unused-import
from ..problems.quadratic_program import QuadraticProgram
[문서]class QuadraticProgramConverter(ABC):
"""
An abstract class for converters of quadratic programs in Qiskit's optimization module.
"""
[문서] @abstractmethod
def convert(self, problem: QuadraticProgram) -> QuadraticProgram:
"""Convert a QuadraticProgram into another form
and keep the information required to interpret the result.
"""
raise NotImplementedError
[문서] @abstractmethod
def interpret(self, result: 'qiskit.optimization.algorithms.OptimizationResult') \
-> 'qiskit.optimization.algorithms.OptimizationResult': # type: ignore
""" Interpret a result into another form using the information of conversion"""
raise NotImplementedError
[문서] def encode(self, problem: QuadraticProgram) -> QuadraticProgram: # type: ignore
"""DEPRECATED Encode a QuadraticProgram into another form
and keep the information required to decode the result.
"""
warnings.warn('The qiskit.optimization.converters.QuadraticProgramConverter.encode() '
'method is deprecated as of 0.7.4 and will be removed no sooner '
'than 3 months after the release. You should use '
'qiskit.optimization.converters.QuadraticProgramConverter.convert() '
'instead.',
DeprecationWarning, stacklevel=1)
return self.convert(problem)
[문서] def decode(self, result: 'qiskit.optimization.algorithms.OptimizationResult') \
-> 'qiskit.optimization.algorithms.OptimizationResult': # type: ignore
"""DEPRECATED Decode a result into another form using the information of conversion."""
warnings.warn('The qiskit.optimization.converters.QuadraticProgramConverter.decode() '
'method is deprecated as of 0.7.4 and will be removed no sooner '
'than 3 months after the release. You should use '
'qiskit.optimization.converters.QuadraticProgramConverter.interpret() '
'instead.',
DeprecationWarning, stacklevel=1)
return self.interpret(result)