Evaluate functional value of previous iteration.
769217
def evaluate(self):
        """"""

        X = mp_Z_Y
        Xf = mp_Zf
        Df = mp_Df
        Sf = mp_Sf
        Ef = sl.inner(Df[np.newaxis, ...], Xf,
                       axis=self.xstep.cri.axisM+1) - Sf
        Ef = np.swapaxes(Ef, 0, self.xstep.cri.axisK+1)[0]
        dfd = sl.rfl2norm2(Ef, self.xstep.S.shape,
                            axis=self.xstep.cri.axisN)/2.0
        rl1 = np.sum(np.abs(X))
        obj = dfd + self.xstep.lmbda*rl1
        return (obj, dfd, rl1)
556851
def eval_Rf(self, Vf):
        """"""

        return sl.inner(self.Df, Vf, axis=self.cri.axisM) - self.Sf
77905
def _evaluate(self,x):
        '''
        
        '''
        if _isscalar(x):
            y = np.nanmin([f(x) for f in self.functions])
        else:
            m = len(x)
            fx = np.zeros((m,self.funcCount))
            for j in range(self.funcCount):
                fx[:,j] = self.functions[j](x)
            y = np.nanmin(fx,axis=1)
        return y
615880
def _call(self, x):
        """"""
        if self.prior is None:
            tmp = self.domain.element((np.exp(x) - 1)).inner(self.domain.one())
        else:
            tmp = (self.prior * (np.exp(x) - 1)).inner(self.domain.one())
        return tmp
207880
def _call(self, x):
        """"""
        x_norm = self.pointwise_norm(x).ufuncs.max()

        if x_norm > 1:
            return np.inf
        else:
            return 0
1232540
def evaluate(self, sequence):
        
        last_cache_index = self.cache_scan()
        transformations = self.transformations[last_cache_index:]
        return self.engine.evaluate(sequence, transformations)
698796
def eval(self, valuation=None, trace=None):
        
        return super().eval(valuation=valuation, trace=trace)
763603
def evaluate(self,n, features, stack_float, stack_bool,labels=None):
        """"""
        np.seterr(all='ignore')
        if len(stack_float) >= n.arity['f'] and len(stack_bool) >= n.arity['b']:
            if n.out_type == 'f':
                stack_float.append(
                    self.safe(self.eval_dict[n.name](n,features,stack_float,
                                                     stack_bool,labels)))
                if (np.isnan(stack_float[-1]).any() or
                    np.isinf(stack_float[-1]).any()):
                    print("problem operator:",n)
            else:
                stack_bool.append(self.safe(self.eval_dict[n.name](n,features,
                                                                   stack_float,
                                                                   stack_bool,
                                                                   labels)))
                if np.isnan(stack_bool[-1]).any() or np.isinf(stack_bool[-1]).any():
                    print("problem operator:",n)
320973
def evaluate_cached(self, **kwargs):
        """"""
        if not hasattr(self, 'result'):
            self.result = self.evaluate(cache=True, **kwargs)

        return self.result
801541
def _call(self, x):
        """"""

        if abs(x.ufuncs.sum() / self.sum_value - 1) <= self.sum_rtol:
            return 0
        else:
            return np.inf
303135
def _call(self, x):
        """"""
        return (self.functional(x) +
                self.quadratic_coeff * x.inner(x) +
                x.inner(self.linear_term) + self.constant)
1187595
def use(self, key, value):
        
        old_value = self[key]
        try:
            self[key] = value
            yield self
        finally:
            self[key] = old_value
557424
def given(self):
        """"""
        if self._primary.value[0] and self._primary.value[2]:
            return self._primary.value[0] + ' ' + self._primary.value[2]
        return self._primary.value[0] or self._primary.value[2]
1108082
def iteration_stats(self, k, frcxd):
        """"""

        tk = self.timer.elapsed(self.opt['IterTimer'])
        tpl = (k,) + self.eval_objfn() + \
            (frcxd, self.F, self.Q, self.iterBTrack, self.L) + \
            self.itstat_extra() + (tk,)
        return type(self).IterationStats(*tpl)
781183
def gradient(self):
        """"""
        try:
            op_to_return = self.functional.gradient
        except NotImplementedError:
            raise NotImplementedError(
                '`self.functional.gradient` is not implemented for '
                '`self.functional` {}'.format(self.functional))

        op_to_return = op_to_return - ConstantOperator(self.subgrad)
        return op_to_return
202241
def iteration_stats(self, k, r, s, epri, edua):
        """"""

        tk = self.timer.elapsed(self.opt['IterTimer'])
        tpl = (k,) + self.eval_objfn() + (r, s, epri, edua, self.rho) + \
            self.itstat_extra() + (tk,)
        return type(self).IterationStats(*tpl)
333466
def _call(self, x):
        """"""
        # The algorithm takes finite differences in one dimension at a time
        # reusing the dx vector to improve efficiency.
        dfdx = self.domain.zero()
        dx = self.domain.zero()

        if self.method == 'backward':
            fx = self.functional(x)
            for i in range(self.domain.size):
                dx[i - 1] = 0  # reset step from last iteration
                dx[i] = self.step
                dfdx[i] = fx - self.functional(x - dx)
        elif self.method == 'forward':
            fx = self.functional(x)
            for i in range(self.domain.size):
                dx[i - 1] = 0  # reset step from last iteration
                dx[i] = self.step
                dfdx[i] = self.functional(x + dx) - fx
        elif self.method == 'central':
            for i in range(self.domain.size):
                dx[i - 1] = 0  # reset step from last iteration
                dx[i] = self.step / 2
                dfdx[i] = self.functional(x + dx) - self.functional(x - dx)
        else:
            raise RuntimeError('unknown method')

        dfdx /= self.step
        return dfdx