def _nlopt_callback(available): if not available: return import nlopt # pylint: disable=import-error _logger.info( "NLopt version: %s.%s.%s", nlopt.version_major(), nlopt.version_minor(), nlopt.version_bugfix(), )
# -*- coding: utf-8 -*- # Copyright 2018 IBM. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================= import nlopt import logging logger = logging.getLogger(__name__) logger.debug('NLopt version: {}.{}.{}'.format(nlopt.version_major(), nlopt.version_minor(), nlopt.version_bugfix()))
""" Minimize using objective function """ from typing import List, Optional, Tuple, Callable from enum import Enum from abc import abstractmethod import logging import numpy as np from qiskit.aqua import MissingOptionalLibraryError from ..optimizer import Optimizer, OptimizerSupportLevel logger = logging.getLogger(__name__) try: import nlopt logger.info('NLopt version: %s.%s.%s', nlopt.version_major(), nlopt.version_minor(), nlopt.version_bugfix()) _HAS_NLOPT = True except ImportError: _HAS_NLOPT = False class NLoptOptimizerType(Enum): """ NLopt Valid Optimizer """ GN_CRS2_LM = 1 GN_DIRECT_L_RAND = 2 GN_DIRECT_L = 3 GN_ESCH = 4 GN_ISRES = 5 class NLoptOptimizer(Optimizer):