text: # This code is part of Qiskit.
  #
  # (C) Copyright IBM 2020, 2021.
  #
  # 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.
  
  """The ground state calculation interface."""
  
  from abc import ABC, abstractmethod
  from typing import Dict, List, Optional, Union
  
  import numpy as np
  from qiskit import QuantumCircuit
  from qiskit.circuit import Instruction
  from qiskit.quantum_info import Statevector
  from qiskit.result import Result
  from qiskit.opflow import OperatorBase, PauliSumOp
  
  from qiskit_nature.operators.second_quantization import SecondQuantizedOp
  from qiskit_nature.converters.second_quantization import QubitConverter
  from qiskit_nature.problems.second_quantization import BaseProblem
  from qiskit_nature.results import EigenstateResult
  
  
  class GroundStateSolver(ABC):
      """The ground state calculation interface"""
  
      def __init__(self, qubit_converter: QubitConverter) -> None:
          """
          Args:
              qubit_converter: a class that converts second quantized operator to qubit operator
                               according to a mapper it is initialized with.
          """
          self._qubit_converter = qubit_converter
  
      @abstractmethod
      def solve(self, problem: BaseProblem,
                aux_operators: Optional[List[Union[SecondQuantizedOp, PauliSumOp]]] = None,
                ) -> EigenstateResult:
          """Compute the ground state energy of the molecule that was supplied via the driver.
  
          Args:
              problem: a class encoding a problem to be solved.
              aux_operators: Additional auxiliary operators to evaluate.
  
          Returns:
              An interpreted :class:`~.EigenstateResult`. For more information see also
              :meth:`~.BaseProblem.interpret`.
          """
          raise NotImplementedError
  
      @abstractmethod
      def returns_groundstate(self) -> bool:
          """Whether this class returns only the ground state energy or also the ground state itself.
  
          Returns:
              True, if this class also returns the ground state in the results object.
              False otherwise.
          """
          raise NotImplementedError
  
      @abstractmethod
      def evaluate_operators(self,
                             state: Union[str, dict, Result,
                                          list, np.ndarray, Statevector,
                                          QuantumCircuit, Instruction,
                                          OperatorBase],
                             operators: Union[PauliSumOp, OperatorBase, list, dict]
                             ) -> Union[float, List[float], Dict[str, List[float]]]:
          """Evaluates additional operators at the given state.
  
          Args:
              state: any kind of input that can be used to specify a state. See also ``StateFn`` for
                     more details.
              operators: either a single, list or dictionary of ``PauliSumOp``s or any kind
                         of operator implementing the ``OperatorBase``.
  
          Returns:
              The expectation value of the given operator(s). The return type will be identical to the
              format of the provided operators.
          """
          raise NotImplementedError
  
      @property
      def qubit_converter(self):
          """Returns the qubit converter."""
          return self._qubit_converter
  