Esempio n. 1
0
class t(Optizelle.Unconstrained.State.t):
    """Internal state of the optimization"""
    def __init__(self, X, Y, msg, x, y):
        """Constructor"""

        # Check our arguments
        Optizelle.checkVectorSpace("X", X)
        Optizelle.checkVectorSpace("Y", Y)
        Optizelle.checkMessaging("msg", msg)

        # Allocate memory for our vectors
        Optizelle.Unconstrained.State.allocateVectors(self, X, x)
        allocateVectors(self, X, Y, x, y)

        # Create the state
        Optizelle.Utility.EqualityConstrainedStateCreate(self, X, Y, msg, x, y)

    # Create all of the properties
    y = Optizelle.createVectorProperty(
        "y", "Equality multiplier (dual variable or Lagrange multiplier)")
    dy = Optizelle.createVectorProperty("dy",
                                        "Step in the equality multiplier")
    zeta = Optizelle.createFloatProperty(
        "zeta",
        "The fraction of the total trust-region used for the quasi-norm step")
    eta0 = Optizelle.createFloatProperty(
        "eta0",
        ("Trust-region parameter that bounds the error in the predicted "
         "reduction"))
    rho = Optizelle.createFloatProperty(
        "rho", "Penalty parameter for the augmented-Lagrangian")
    rho_old = Optizelle.createFloatProperty(
        "rho_old", "Penalty parameter from the last iteration")
    rho_bar = Optizelle.createFloatProperty(
        "rho_bar", "Fixed increase in the penalty parameter")
    eps_constr = Optizelle.createFloatProperty(
        "eps_constr", "Stopping tolerance for the norm of the constraints")
    xi_qn = Optizelle.createFloatProperty(
        "xi_qn", "Inexactness tolerance for the quasi-Newton step")
    xi_pg = Optizelle.createFloatProperty(
        "xi_pg", "Inexactness tolerance for the projection of the gradient")
    xi_proj = Optizelle.createFloatProperty(
        "xi_proj", "Inexactness tolerance for the null-space projection")
    xi_tang = Optizelle.createFloatProperty(
        "xi_tang", "Inexactness tolerance for the tangential step")
    xi_lmh = Optizelle.createFloatProperty(
        "xi_lmh", "Inexactness tolerance for the equality multiplier")

    def xi_all(self, value):
        """Sets all the inexactness tolerances: xi_qn, xi_pg, xi_proj, xi_tang, and xi_lmh"""
        self.xi_qn = value
        self.xi_pg = value
        self.xi_proj = value
        self.xi_tang = value
        self.xi_lmh = value

    xi_lmg = Optizelle.createFloatProperty(
        "xi_lmg",
        "Absolute tolerance on the residual of the equality multiplier solve")
    xi_4 = Optizelle.createFloatProperty(
        "xi_4",
        ("Tolerance for how much error is acceptable after computing the "
         "tangential step given the result from the tangential subproblem"))
    rpred = Optizelle.createFloatProperty(
        "rpred", "Residual term in the predicted reduction")
    PSchur_left_type = Optizelle.createEnumProperty(
        "PSchur_left_type", Optizelle.Operators,
        "Left preconditioner for the augmented system")
    PSchur_right_type = Optizelle.createEnumProperty(
        "PSchur_right_type", Optizelle.Operators,
        "Right preconditioner for the augmented system")
    augsys_iter_max = Optizelle.createNatProperty(
        "augsys_iter_max",
        "Maximum number of iterations used when solving the augmented system")
    augsys_rst_freq = Optizelle.createNatProperty("augsys_rst_freq", (
        "Equality constraint evaluated at x.  This is used in the quasinormal "
        "step as well as in the computation of the linear Taylor series at x "
        "in the direciton dx_n."))
    norm_gxtyp = Optizelle.createFloatProperty(
        "norm_gxtyp",
        ("A typical norm for norm_gx.  Generally, we just take the value at "
         "the first iteration."))
    gpxdxn_p_gx = Optizelle.createVectorProperty(
        "gpxdxn_p_gx",
        ("Linear Taylor series at x in the direction dx_n.  This is used both "
         "in the predicted reduction as well as the residual predicted "
         "reduction."))
    gpxdxt = Optizelle.createVectorProperty(
        "gpxdxt",
        ("Derivative of the constraint applied to the tangential step this is "
         "used in the residual predicted reduction."))
    norm_gpxdxnpgx = Optizelle.createVectorProperty(
        "norm_gpxdxnpgx",
        ("Norm of gpxdxn_p_gx.  This is used in the penalty parameter "
         "computation and predicted reduction."))
    dx_n = Optizelle.createVectorProperty("dx_n", "Normal step")
    dx_ncp = Optizelle.createVectorProperty("dx_ncp",
                                            "Cauchy point for normal step")
    dx_t = Optizelle.createVectorProperty("dx_t",
                                          "(Corrected) tangential step")
    dx_t_uncorrected = Optizelle.createVectorProperty(
        "dx_t_uncorrected", "Tangential step prior to correction")
    dx_tcp_uncorrected = Optizelle.createVectorProperty(
        "dx_tcp_uncorrected",
        "Cauchy point for tangential step prior to correction")
    H_dxn = Optizelle.createVectorProperty("H_dxn", (
        "Hessian applied to the normal step.  This is required by W_gradpHdxn "
        "as well as the predicted reduction."))
    W_gradpHdxn = Optizelle.createVectorProperty("W_gradpHdxn", (
        "Quantity grad f(x) + g'(x)*y + H dx_n projected into the null-space ",
        "of the constraints.  This is required in the tangential subproblem "
        "and the predicted reduction."))
    H_dxtuncorrected = Optizelle.createVectorProperty(
        "H_dxtuncorrected",
        ("Hessian applied to the uncorrected tangential step.  This is needed "
         "in the predicted reduction."))
    g_diag = Optizelle.createEnumProperty("g_diag",
                                          Optizelle.FunctionDiagnostics,
                                          "Function diagnostics on g")
Esempio n. 2
0
class t(object):
    """Internal state of the optimization"""
    def __init__(self, X, msg, x):
        """Constructor"""

        # Check our arguments
        Optizelle.checkVectorSpace("X", X)
        Optizelle.checkMessaging("msg", msg)

        # Allocate memory for our vectors
        allocateVectors(self, X, x)

        # Create the state
        Optizelle.Utility.UnconstrainedStateCreate(self, X, msg, x)

    # Create all of the properties
    eps_grad = Optizelle.createFloatProperty(
        "eps_grad", "Tolerance for the gradient stopping condition")
    eps_dx = Optizelle.createFloatProperty(
        "eps_dx", "Tolerance for the step length stopping criteria")
    algorithm_class = Optizelle.createEnumProperty("algorihm_class",
                                                   Optizelle.AlgorithmClass,
                                                   "Algorithm class")
    stored_history = Optizelle.createNatProperty(
        "stored_history",
        "Number of control objects to store in a quasi-Newton method")
    history_reset = Optizelle.createNatProperty(
        "history_reset", "Number of failed iterations before we reset the "
        "history for quasi-Newton methods")
    iter = Optizelle.createNatProperty("iter", "Current iteration")
    iter_max = Optizelle.createNatProperty(
        "iter_max", "Maximum number of optimization iterations")
    opt_stop = Optizelle.createEnumProperty(
        "opt_stop", Optizelle.StoppingCondition,
        "Why we've stopped the optimization")
    krylov_iter = Optizelle.createNatProperty(
        "krylov_iter", "Current number of Krylov iterations taken")
    krylov_iter_max = Optizelle.createNatProperty(
        "krylov_iter_max", "Maximum number of iterations in the Krylov method")
    krylov_iter_total = Optizelle.createNatProperty(
        "krylov_iter_total", "Total number of Krylov iterations taken")
    krylov_orthog_max = Optizelle.createNatProperty(
        "krylov_orthog_max",
        ("The maximum number of vectors we orthogonalize "
         "against in the Krylov method.  For something like "
         "CG, this is 1."))
    krylov_stop = Optizelle.createEnumProperty(
        "krylov_stop", Optizelle.KrylovStop,
        "Why the Krylov method was last stopped")
    krylov_rel_err = Optizelle.createFloatProperty(
        "krylov_rel_err", "Relative error in the Krylov method")
    eps_krylov = Optizelle.createFloatProperty(
        "eps_krylov", "Stopping tolerance for the Krylov method")
    krylov_solver = Optizelle.createEnumProperty(
        "krylov_solver", Optizelle.KrylovSolverTruncated,
        "Truncated Krylov solver")
    algorithm_class = Optizelle.createEnumProperty("algorithm_class",
                                                   Optizelle.AlgorithmClass,
                                                   "Algorithm class")
    PH_type = Optizelle.createEnumProperty("PH_type", Optizelle.Operators,
                                           "Preconditioner for the Hessian")
    H_type = Optizelle.createEnumProperty("H_type", Optizelle.Operators,
                                          "Hessian approximation")
    norm_gradtyp = Optizelle.createFloatProperty("norm_gradtyp",
                                                 "Norm of a typical tradient")
    norm_dxtyp = Optizelle.createFloatProperty("norm_dxtyp",
                                               "Norm of a typical trial step")
    x = Optizelle.createVectorProperty("x", "Optimization variable")
    grad = Optizelle.createVectorProperty(
        "grad",
        ("Gradient, possibly of the objective, possibly of the  Lagrangian.  "
         "It depends on the context."))
    dx = Optizelle.createVectorProperty("dx", "Trial step")
    x_old = Optizelle.createVectorProperty("x_old",
                                           "Old optimization variable")
    grad_old = Optizelle.createVectorProperty("grad_old", "Old gradient")
    dx_old = Optizelle.createVectorProperty("dx_old", "Old trial step")
    oldY = Optizelle.createVectorListProperty("oldY",
                                              "Difference in prior gradients")
    oldS = Optizelle.createVectorListProperty("oldS",
                                              "Difference in prior steps")
    f_x = Optizelle.createFloatProperty(
        "f_x", "Current value of the objective function")
    f_xpdx = Optizelle.createFloatProperty(
        "f_xpdx", "Objective function at the trial step")
    msg_level = Optizelle.createNatProperty("msg_level", "Messaging level")
    delta = Optizelle.createFloatProperty("delta", "Trust region radius")
    eta1 = Optizelle.createFloatProperty(
        "eta1",
        "Trust-region parameter for checking whether a step has been accepted")
    eta2 = Optizelle.createFloatProperty(
        "eta2", ("Trust-region parameter for checking whether we enlarge the "
                 "trust-region radius"))
    ared = Optizelle.createFloatProperty("ared", "Actual reduction")
    pred = Optizelle.createFloatProperty("pred", "Predicted reduction")
    rejected_trustregion = Optizelle.createNatProperty(
        "rejected_trustregion", "Number of rejected trust-region steps")
    alpha0 = Optizelle.createFloatProperty("alpha0",
                                           "Base line-search step length")
    alpha = Optizelle.createFloatProperty("alpha",
                                          "Actual line-search step length")
    c1 = Optizelle.createFloatProperty(
        "c1", "Parameter that helps govern the sufficient decrease")
    linesearch_iter = Optizelle.createNatProperty(
        "linesearch_iter",
        "Current number of iterations used in the line-search")
    linesearch_iter_max = Optizelle.createNatProperty(
        "linesearch_iter_max",
        "Maximum number of iterations used in the line-search")
    linesearch_iter_total = Optizelle.createNatProperty(
        "linesearch_iter_total",
        "Total number of line-search iterations computed")
    eps_ls = Optizelle.createFloatProperty(
        "eps_ls", "Stopping tolerance for the line-search")
    dir = Optizelle.createEnumProperty("dir", Optizelle.LineSearchDirection,
                                       "Search direction type")
    kind = Optizelle.createEnumProperty("kind", Optizelle.LineSearchKind,
                                        "Type of line-search")
    f_diag = Optizelle.createEnumProperty("f_diag",
                                          Optizelle.FunctionDiagnostics,
                                          "Function diagnostics on f")
    dscheme = Optizelle.createEnumProperty("dscheme",
                                           Optizelle.DiagnosticScheme,
                                           "Diagnostic scheme")