Beispiel #1
0
    def proj(self, w, index, eps=consts.TOLERANCE, max_iter=100):
        """The projection operator of a constraint that corresponds to the
        function with the given index.

        From the interface "MultiblockProjectionOperator".

        Parameters
        ----------
        w : List of numpy arrays. The weight vectors.

        index : Non-negative integer. Which variable the step is for.
        """
        prox = self._prox[index]
        proj = self._c[index]
        if len(proj) == 1 and len(prox) == 0:
            proj_w = proj[0].proj(w[index], eps=eps, max_iter=max_iter)

        elif len(proj) == 2 and len(prox) == 0:
            from parsimony.algorithms.proximal \
                    import DykstrasProjectionAlgorithm
            combo = DykstrasProjectionAlgorithm(eps=eps,
                                                max_iter=max_iter, min_iter=1)

            proj_w = combo.run(proj, w[index])

        else:
            proj_w = self.prox(w, index, eps=eps, max_iter=max_iter)

        return proj_w
Beispiel #2
0
    def proj(self, w, index, eps=consts.TOLERANCE, max_iter=100):
        """The projection operator of a constraint that corresponds to the
        function with the given index.

        From the interface "MultiblockProjectionOperator".

        Parameters
        ----------
        w : List of numpy arrays. The weight vectors.

        index : Non-negative integer. Which variable the step is for.
        """
        prox = self._prox[index]
        proj = self._c[index]
        if len(proj) == 1 and len(prox) == 0:
            proj_w = proj[0].proj(w[index], eps=eps, max_iter=max_iter)

        elif len(proj) == 2 and len(prox) == 0:
            from parsimony.algorithms.proximal \
                import DykstrasProjectionAlgorithm
            combo = DykstrasProjectionAlgorithm(eps=eps,
                                                max_iter=max_iter, min_iter=1)

            proj_w = combo.run(proj, w[index])

        else:
            proj_w = self.prox(w, index, eps=eps, max_iter=max_iter)

        return proj_w
Beispiel #3
0
    def proj(self, w, index, eps=consts.TOLERANCE, max_iter=100):
        """The projection operator of a constraint that corresponds to the
        function with the given index.

        From the interface "MultiblockProjectionOperator".

        Parameters
        ----------
        w : list of numpy arrays
            The weight vectors.

        index : int
            Non-negative integer. Which variable the projection is for.
        """
        prox = self._p[index]
        proj = self._c[index]

        # We have no penalties with projection operators:
        if len(prox) == 0 and len(proj) == 0:
            proj_w = w[index]  # Do nothing!

        # There is one projection operator and no proximal operators:
        elif len(proj) == 1 and len(prox) == 0:
            proj_w = proj[0].proj(w[index], eps=eps, max_iter=max_iter)

        # There are two projection operators and no proximal operators:
        elif len(proj) == 2 and len(prox) == 0:
            from parsimony.algorithms.proximal \
                import DykstrasProjectionAlgorithm
            combo = DykstrasProjectionAlgorithm(eps=eps,
                                                max_iter=max_iter,
                                                min_iter=1)
            proj_w = combo.run(proj, w[index])

        # There are no constraints, but one or two proximal operators, or any
        # number of constraints and any number of proximal oeprators:
        else:
            proj_w = self.prox(w, index, eps=eps, max_iter=max_iter)

        return proj_w
Beispiel #4
0
    def proj(self, w, index, eps=consts.TOLERANCE, max_iter=100):
        """The projection operator of a constraint that corresponds to the
        function with the given index.

        From the interface "MultiblockProjectionOperator".

        Parameters
        ----------
        w : list of numpy arrays
            The weight vectors.

        index : int
            Non-negative integer. Which variable the projection is for.
        """
        prox = self._p[index]
        proj = self._c[index]

        # We have no penalties with projection operators:
        if len(prox) == 0 and len(proj) == 0:
            proj_w = w[index]  # Do nothing!

        # There is one projection operator and no proximal operators:
        elif len(proj) == 1 and len(prox) == 0:
            proj_w = proj[0].proj(w[index], eps=eps, max_iter=max_iter)

        # There are two projection operators and no proximal operators:
        elif len(proj) == 2 and len(prox) == 0:
            from parsimony.algorithms.proximal \
                import DykstrasProjectionAlgorithm
            combo = DykstrasProjectionAlgorithm(eps=eps,
                                                max_iter=max_iter, min_iter=1)
            proj_w = combo.run(proj, w[index])

        # There are no constraints, but one or two proximal operators, or any
        # number of constraints and any number of proximal oeprators:
        else:
            proj_w = self.prox(w, index, eps=eps, max_iter=max_iter)

        return proj_w