• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

qiskit-community / qiskit-algorithms / 15802199099

13 Jun 2025 01:21PM CUT coverage: 90.448%. Remained the same
15802199099

push

github

web-flow
Fix getter/setter type mismatch (#232)

1 of 1 new or added line in 1 file covered. (100.0%)

6401 of 7077 relevant lines covered (90.45%)

0.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

52.17
/qiskit_algorithms/optimizers/imfil.py
1
# This code is part of a Qiskit project.
2
#
3
# (C) Copyright IBM 2019, 2023.
4
#
5
# This code is licensed under the Apache License, Version 2.0. You may
6
# obtain a copy of this license in the LICENSE.txt file in the root directory
7
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
8
#
9
# Any modifications or derivative works of this code must retain this
10
# copyright notice, and modified files need to carry a notice indicating
11
# that they have been altered from the originals.
12

13
"""IMplicit FILtering (IMFIL) optimizer."""
14
from __future__ import annotations
1✔
15

16
from collections.abc import Callable
1✔
17
from typing import Any
1✔
18

19
from qiskit_algorithms.utils import optionals as _optionals
1✔
20
from .optimizer import Optimizer, OptimizerSupportLevel, OptimizerResult, POINT
1✔
21

22

23
@_optionals.HAS_SKQUANT.require_in_instance
1✔
24
class IMFIL(Optimizer):
1✔
25
    """IMplicit FILtering algorithm.
26

27
    Implicit filtering is a way to solve bound-constrained optimization problems for
28
    which derivatives are not available. In comparison to methods that use interpolation to
29
    reconstruct the function and its higher derivatives, implicit filtering builds upon
30
    coordinate search followed by interpolation to get an approximate gradient.
31

32
    Uses skquant.opt installed with pip install scikit-quant.
33
    For further detail, please refer to
34
    https://github.com/scikit-quant/scikit-quant and https://qat4chem.lbl.gov/software.
35
    """
36

37
    def __init__(
1✔
38
        self,
39
        maxiter: int = 1000,
40
    ) -> None:
41
        """
42
        Args:
43
            maxiter: Maximum number of function evaluations.
44

45
        Raises:
46
            MissingOptionalLibraryError: scikit-quant not installed
47
        """
48
        super().__init__()
×
49
        self._maxiter = maxiter
×
50

51
    def get_support_level(self):
1✔
52
        """Returns support level dictionary."""
53
        return {
×
54
            "gradient": OptimizerSupportLevel.ignored,
55
            "bounds": OptimizerSupportLevel.required,
56
            "initial_point": OptimizerSupportLevel.required,
57
        }
58

59
    @property
1✔
60
    def settings(self) -> dict[str, Any]:
1✔
61
        return {
×
62
            "maxiter": self._maxiter,
63
        }
64

65
    def minimize(
1✔
66
        self,
67
        fun: Callable[[POINT], float],
68
        x0: POINT,
69
        jac: Callable[[POINT], POINT] | None = None,
70
        bounds: list[tuple[float, float]] | None = None,
71
    ) -> OptimizerResult:
72
        from skquant import opt as skq
×
73

74
        res, history = skq.minimize(
×
75
            func=fun,
76
            x0=x0,
77
            bounds=bounds,
78
            budget=self._maxiter,
79
            method="imfil",
80
        )
81

82
        optimizer_result = OptimizerResult()
×
83
        optimizer_result.x = res.optpar
×
84
        optimizer_result.fun = res.optval
×
85
        optimizer_result.nfev = len(history)
×
86
        return optimizer_result
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc