quri_parts.algo.optimizer.nft module#
- class quri_parts.algo.optimizer.nft.OptimizerStateNFT(params: 'npt.NDArray[np.float_]', cost: float = 0.0, status: quri_parts.algo.optimizer.interface.OptimizerStatus = <OptimizerStatus.SUCCESS: 1>, niter: int = 0, funcalls: int = 0, gradcalls: int = 0)#
Bases:
OptimizerState
- params: npt.NDArray[np.float_]#
Current parameter values.
- class quri_parts.algo.optimizer.nft.NFTBase(randomize: bool = False, ftol: float | None = 1e-05)#
Bases:
Optimizer
- get_init_state(init_params: npt.NDArray[np.float_]) OptimizerStateNFT #
Returns an initial state for optimization.
- step(state: OptimizerState, cost_function: Callable[[npt.NDArray[np.float_]], float], grad_function: Callable[[npt.NDArray[np.float_]], npt.NDArray[np.float_]] | None = None) OptimizerStateNFT #
Run a single optimization step and returns a new state.
- class quri_parts.algo.optimizer.nft.NFT(randomize: bool = False, reset_interval: int | None = 32, eps: float = 1e-32, ftol: float | None = 1e-05)#
Bases:
NFTBase
Nakanishi-Fujii-Todo optimization algorithm proposed in [1]. The algorithms optimizes the cost function sequentially with respect to the parameters.
- Parameters:
randomize – If
True
, the order of the parameters over which the cost function is optimized will be random. IfFalse
, the order will be the same as the order of the array of initial parameters.reset_interval – minimum value of the cost function is evaluated by direct function-call only once in
reset_interval
times.eps – a small number used for avoiding zero division.
ftol – If not None, judge convergence by cost function tolerance. See
ftol()
for details.
- Ref:
- [1]: Ken M. Nakanishi, Keisuke Fujii, and Synge Todo,
Sequential minimal optimization for quantum-classical hybrid algorithms, Phys. Rev. Research 2, 043158 (2020).
- class quri_parts.algo.optimizer.nft.NFTfit(randomize: bool = False, n_points: int = 3, ftol: float | None = 1e-05)#
Bases:
NFTBase
Basically the same as Nakanishi-Fujii-Todo optimization algorithm [1]. The difference from
NFT
class is thatNFTfit
uses SciPy fitting functioncurve_fit
for parameters update.- Parameters:
randomize – If
True
, the order of the parameters over which the cost function is optimized will be random. IfFalse
, the order will be the same as the order of the array of initial parameters.n_point – Number of values of cost function for function fitting using SciPy fitting function
curve_fit
.ftol – If not None, judge convergence by cost function tolerace. See
ftol()
for details.
- Ref:
- [1]: Ken M. Nakanishi, Keisuke Fujii, and Synge Todo,
Sequential minimal optimization for quantum-classical hybrid algorithms, Phys. Rev. Research 2, 043158 (2020).