(
        self,
        func: Callable[["ChainerMNTrial", "CommunicatorBase"], float],
        n_trials: Optional[int] = None,
        timeout: Optional[float] = None,
        catch: Tuple[Type[Exception], ...] = (),
    )
Optimize an objective function.

        This method provides the same interface as :func:`optuna.study.Study.optimize` except
        the absence of ``n_jobs`` argument.
Optimize an objective function.
Optimize an objective function .
def optimize(
        self,
        func: Callable[["ChainerMNTrial", "CommunicatorBase"], float],
        n_trials: Optional[int] = None,
        timeout: Optional[float] = None,
        catch: Tuple[Type[Exception], ...] = (),
    ) -> None:
        """Optimize an objective function.

        This method provides the same interface as :func:`optuna.study.Study.optimize` except
        the absence of ``n_jobs`` argument.
        """

        if self.comm.rank == 0:
            func_mn = _ChainerMNObjectiveFunc(func, self.comm)
            try:
                self.delegate.optimize(func_mn, n_trials=n_trials, timeout=timeout, catch=catch)
            finally:
                self.comm.mpi_comm.bcast(False)
        else:
            has_next_trial = self.comm.mpi_comm.bcast(None)
            while True:
                if not has_next_trial:
                    break
                try:
                    func(ChainerMNTrial(None, self.comm), self.comm)

                    # We assume that if a node raises an exception,
                    # all other nodes will do the same.
                    #
                    # The responsibility to handle acceptable exceptions (i.e., `TrialPruned` and
                    # `catch`) is in the rank-0 node, so other nodes simply ignore them.
                except TrialPruned:
                    pass
                except catch:
                    pass
                finally:
                    has_next_trial = self.comm.mpi_comm.bcast(None)
def optimize ( self , func : Callable [ [ "ChainerMNTrial" , "CommunicatorBase" ] , float ] , n_trials : Optional [ int ] = None , timeout : Optional [ float ] = None , catch : Tuple [ Type [ Exception ] , ... ] = ( ) , ) -> None : if self . comm . rank == 0 : func_mn = _ChainerMNObjectiveFunc ( func , self . comm ) try : self . delegate . optimize ( func_mn , n_trials = n_trials , timeout = timeout , catch = catch ) finally : self . comm . mpi_comm . bcast ( False ) else : has_next_trial = self . comm . mpi_comm . bcast ( None ) while True : if not has_next_trial : break try : func ( ChainerMNTrial ( None , self . comm ) , self . comm ) # We assume that if a node raises an exception, # all other nodes will do the same. # # The responsibility to handle acceptable exceptions (i.e., `TrialPruned` and # `catch`) is in the rank-0 node, so other nodes simply ignore them. except TrialPruned : pass except catch : pass finally : has_next_trial = self . comm . mpi_comm . bcast ( None )