Example #1
0
File: bqp.py Project: joeywen/nlpy
 def __init__(self, g, H, **kwargs):
     TruncatedCG.__init__(self, g, H, **kwargs)
     self.name = 'Suff-CG'
     self.qval = 0.0   # Initial value of quadratic objective.
     self.best_decrease = 0
     self.cg_reltol = kwargs.get('cg_reltol', 0.1)
     self.detect_stalling = kwargs.get('detect_stalling', True)
Example #2
0
 def __init__(self, g, H, **kwargs):
     TruncatedCG.__init__(self, g, H, **kwargs)
     self.name = 'Suff-CG'
     self.qval = 0.0  # Initial value of quadratic objective.
     self.best_decrease = 0
     self.cg_reltol = kwargs.get('cg_reltol', 0.1)
     self.detect_stalling = kwargs.get('detect_stalling', True)
Example #3
0
    def __init__(self, g, H, **kwargs):

        TrustRegionSolver.__init__(self, g, **kwargs)
        self.cgSolver = TruncatedCG(g, H, **kwargs)
        self.niter = 0
        self.stepNorm = 0.0
        self.step = None
        self.m = None  # Model value at candidate solution
Example #4
0
class TrustRegionCG(TrustRegionSolver):
    """
    Instantiate a trust-region subproblem solver based on the truncated
    conjugate gradient method of Steihaug and Toint. See the :mod:`pcg` module
    for more information.

    The main difference between this class and the :class:`TrustRegionPCG`
    class is that :class:`TrustRegionPCG` only accepts explicit
    preconditioners (i.e. in matrix form). This class accepts an implicit
    preconditioner, i.e., any callable object.
    """
    def __init__(self, g, H, **kwargs):

        TrustRegionSolver.__init__(self, g, **kwargs)
        self.cgSolver = TruncatedCG(g, H, **kwargs)
        self.niter = 0
        self.stepNorm = 0.0
        self.step = None
        self.m = None  # Model value at candidate solution

    def Solve(self, **kwargs):
        """
        Solve trust-region subproblem using the truncated conjugate-gradient
        algorithm.
        """
        self.cgSolver.Solve(**kwargs)
        self.niter = self.cgSolver.niter
        self.stepNorm = self.cgSolver.stepNorm
        self.step = self.cgSolver.step
        # Compute model reduction.
        self.m = np.dot(self.g, self.step)
        self.m += 0.5 * np.dot(self.step, self.cgSolver.H * self.step)
        return
Example #5
0
File: lstr.py Project: joeywen/nlpy
    def __init__(self, J, c, radius=None, transposed=False, **kwargs):
        """
        :parameters:
            :J: coefficient matrix (may be rectangular)
            :c: constant vector (numpy array)
            :radius: positive real number or None (default: None)
            :transpose: if set to True, replace J with its transpose.

        `J` should be a linear operator.
        Additional keyword arguments are passed directly to `TruncatedCG`.

        Upon completion, the member `step` is set to the most recent solution
        estimate. See the documentation of `TruncatedCG` for more
        information.
        """
        self.op = SquaredLinearOperator(J, transposed=transposed)
        TruncatedCG.__init__(self, J.T * c, self.op, radius=radius, **kwargs)
        return
Example #6
0
    def __init__(self, J, c, radius=None, transposed=False, **kwargs):
        """
        :parameters:
            :J: coefficient matrix (may be rectangular)
            :c: constant vector (numpy array)
            :radius: positive real number or None (default: None)
            :transpose: if set to True, replace J with its transpose.

        `J` should be a linear operator.
        Additional keyword arguments are passed directly to `TruncatedCG`.

        Upon completion, the member `step` is set to the most recent solution
        estimate. See the documentation of `TruncatedCG` for more
        information.
        """
        self.op = SquaredLinearOperator(J, transposed=transposed)
        TruncatedCG.__init__(self, J.T * c, self.op, radius=radius, **kwargs)
        return