Example #1
0
    def set_prox(self, prox: Prox):
        """Set proximal operator in the solver.

        Parameters
        ----------
        prox : `Prox`
            The proximal operator of the penalization function

        Returns
        -------
        output : `Solver`
            The solver with given prox

        Notes
        -----
        In some solvers, ``set_model`` must be called before
        ``set_prox``, otherwise and error might be raised.
        """
        if type(prox) is ProxZero:
            SolverFirstOrder.set_prox(self, prox)
            self._set("_prox_grad", lambda x: x)
        elif type(prox) is ProxL2Sq:
            SolverFirstOrder.set_prox(self, prox)
            self._set("_prox_grad", lambda x: prox.strength * x)
        else:
            raise ValueError("BFGS only accepts ProxZero and ProxL2sq "
                             "for now")
        return self
Example #2
0
 def set_prox(self, prox: list):
     """
     Parameters
     ----------
     prox : list[Prox]
         List of all proximal operators of the model
     """
     prox = CompositeProx(prox)
     SolverFirstOrder.set_prox(self, prox)
     return self
Example #3
0
    def set_prox(self, prox: Prox):
        """Set prox in the solver

        Parameters
        ----------
        prox : `Prox`
            Sets the prox in the solver

        Returns
        -------
        output : `Solver`
            The `Solver` with given prox
        """

        SolverFirstOrder.set_prox(self, prox)
        SolverSto.set_prox(self, prox)
        return self