Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Levenberg-Marquardt for systems, mixed-integer programming and truncated Newton

ProblemSolve nonlinear least-squares problems and square systems with MINPACK’s Levenberg-Marquardt method; bounded least squares by the dogbox method; linear programs in which some variables must be integers; and bound-constrained minimisation without a Hessian by truncated Newton
Devised byKenneth Levenberg (1944), Donald Marquardt (1963), Jorge Moré (1978), MINPACK; C. Voglis and I. Lagaris (2004), dogbox; Ailsa Land and Alison Doig (1960), branch and bound; Ron Dembo and Trond Steihaug (1983), Stephen Nash (1984), truncated Newton
AccuracyMINPACK and dogbox follow SciPy’s iterations exactly (same evaluation counts and status); milp reaches the same optima as SciPy’s HiGHS; truncated Newton converges to – where SciPy’s TNC stops at –
CostLevenberg-Marquardt: one QR factorisation of the Jacobian per iteration, ; milp: one LP per branch-and-bound node, exponential in the worst case; truncated Newton: a few gradient evaluations per conjugate-gradient step
Read firstNonlinear least squares and curve fitting, Bound-constrained optimisation, Linear programming
APIleastsq, root_lm, LmOptions; least_squares_dogbox; milp, MilpOptions; minimize_tnc

Overview

Four solvers from scipy.optimize that the library lacked:

  • MINPACK’s Levenberg-Marquardt (leastsq, root(method="lm"), and least_squares(method="lm")), the classic code for unconstrained nonlinear least squares. For square systems it is a robust root finder that also works when the Jacobian is singular at the root.
  • The dogbox method (least_squares(method="dogbox")), a dogleg in a rectangular trust region for least squares with bounds. It is the alternative to the trust-region reflective method already in the library.
  • Mixed-integer linear programming (milp): a linear program in which some variables must be integers. It models choices such as which facilities to open, whether to schedule a task, or how many units to make.
  • Truncated Newton (minimize(method="TNC")), Newton’s method with the Newton equations solved only approximately, by conjugate gradients with Hessian-vector products from gradient differences. It suits bound-constrained problems with many variables.

Where it is used

Three tools for problems that go beyond smooth unconstrained optimisation.

  • Levenberg-Marquardt for systems. Solving square systems of nonlinear equations, as in circuit equilibria and chemical equilibrium, with the robust MINPACK method.
  • Mixed-integer programming. Decisions that are yes/no: whether to build a facility, schedule a job or switch a generator on.
  • Truncated Newton. Large bound-constrained problems with many variables, as in data fitting and parameter estimation.

History

Kenneth Levenberg (1944) and Donald Marquardt (1963) proposed damping the Gauss-Newton step. Jorge Moré (1978) gave the trust-region implementation in MINPACK, written with Burton Garbow and Kenneth Hillstrom at Argonne. It remains the standard, and SciPy calls it unchanged. C. Voglis and I. Lagaris (2004) proposed the rectangular trust-region dogleg that SciPy calls dogbox.

Ailsa Land and Alison Doig (1960) introduced branch and bound for integer programming at the London School of Economics. With cutting planes (Ralph Gomory, 1958) and decades of engineering it underlies every modern MILP solver, including HiGHS, which SciPy uses. Ron Dembo and Trond Steihaug (1983) analysed truncated Newton methods, and Stephen Nash (1984) wrote the TN code with bounds on which SciPy’s TNC is based.

The idea

MINPACK’s Levenberg-Marquardt

Each iteration linearises and solves Here scales the variables by the column norms of , the largest seen so far. The solution is for the at which the constraint holds. Moré’s lmpar finds that by a safeguarded Newton iteration on , accurate to 10 %. Each trial costs only a Givens update of the QR factors of (qrsolv), not a new factorisation.

The ratio of the actual to the predicted reduction in decides whether to accept the step and how to change . Without a Jacobian, forward differences with step supply one, at extra evaluations per iteration.

Dogbox

The trust region is a box , so it intersects the variable bounds in another box. Variables on a bound whose gradient points outwards are fixed. For the rest:

  1. If the Gauss-Newton step fits the intersected box, take it.
  2. Otherwise go to the Cauchy point (the minimum along within the box).
  3. Then move towards the Gauss-Newton step until a face of the box is reached.

Steps that land on an original bound mark that variable active.

Branch and bound

The LP relaxation, which drops integrality, gives a lower bound on the optimum. If its solution has a fractional integer variable , the problem splits into two subproblems with and . Together they contain every integer solution and exclude . The search keeps the best integer solution found, the incumbent, and discards any subproblem whose relaxation cannot beat it.

Exploring the subproblem with the best bound first proves optimality soonest. The search stops when the incumbent is within mip_rel_gap of the best open bound. SciPy’s default gap, , is kept as the default.

Truncated Newton with bounds

Newton’s step solves . Conjugate gradients need only products , so no Hessian is formed or stored. Far from the solution an approximate Newton step is as good as an exact one. The inner iteration therefore stops at a relative residual , which tightens as the gradient shrinks and gives superlinear convergence. It also stops at negative curvature.

Variables on a bound whose gradient points outwards are held fixed, and a projected backtracking line search keeps the iterates feasible.

Implementation

/// Minimises `‖F(x)‖²` by MINPACK's Levenberg-Marquardt method (SciPy's `leastsq`; `lmder` with
/// an analytic Jacobian, `lmdif` with forward differences). Each iteration factorises the
/// Jacobian `J P = Q R` once, then finds by `lmpar` the damping `λ` whose step
/// `min ‖J p + F‖² + λ‖D p‖²` fits the trust region `‖D p‖ ≤ Δ`, with `D` the running maximum of
/// the column norms of `J` (MINPACK's `mode = 1`); `Δ` grows or shrinks with the ratio of actual
/// to predicted reduction. `jac` returns the `m × n` Jacobian by rows.
pub fn leastsq(
    mut fun: impl FnMut(&[f64]) -> Vec<f64>,
    mut jac: Option<JacobianFn<'_>>,
    x0: &[f64],
    options: LmOptions,
) -> Result<LmResult, ErrorsJSL> {
    let n = x0.len();
    let eps = f64::EPSILON;
    let mut x = x0.to_vec();
    let mut fvec = fun(&x);
    let m = fvec.len();
    if n == 0 || m < n {
        return Err(ErrorsJSL::InvalidInputRange("leastsq: need at least as many residuals as unknowns"));
    }
    let maxfev = options.maxfev.unwrap_or(if jac.is_some() { 100 * (n + 1) } else { 200 * (n + 1) });
    let (mut nfev, mut njev) = (1usize, 0usize);
    let mut fnorm = enorm(&fvec);
    let mut par = 0.0;
    let mut iter = 1;
    let mut diag = vec![0.0; n];
    let (mut delta, mut xnorm) = (0.0, 0.0);
    let mut info = 0;
    let fd_eps = options.epsfcn.max(eps).sqrt();
    'outer: loop {
        // The Jacobian, analytic or by forward differences (MINPACK's fdjac2).
        let mut fjac: Vec<Vec<f64>> = match jac.as_mut() {
            Some(j) => {
                njev += 1;
                j(&x)
            }
            None => {
                let mut cols = vec![vec![0.0; n]; m];
                for jj in 0..n {
                    let temp = x[jj];
                    let mut h = fd_eps * temp.abs();
                    if h == 0.0 {
                        h = fd_eps;
                    }
                    x[jj] = temp + h;
                    let wa = fun(&x);
                    x[jj] = temp;
                    for i in 0..m {
                        cols[i][jj] = (wa[i] - fvec[i]) / h;
                    }
                }
                nfev += n;
                cols
            }
        };
        if fjac.len() != m || fjac.iter().any(|r| r.len() != n) {
            return Err(ErrorsJSL::IncompatibleArraySizes((fjac.len(), m)));
        }
        let (ipvt, rdiag, acnorm) = qrfac(&mut fjac, m, n);
        if iter == 1 {
            for j in 0..n {
                diag[j] = if acnorm[j] == 0.0 { 1.0 } else { acnorm[j] };
            }
            xnorm = enorm(&(0..n).map(|j| diag[j] * x[j]).collect::<Vec<_>>());
            delta = options.factor * xnorm;
            if delta == 0.0 {
                delta = options.factor;
            }
        }
        // Qᵀ F, keeping the first n components.
        let mut wa4 = fvec.clone();
        let mut qtf = vec![0.0; n];
        for j in 0..n {
            if fjac[j][j] != 0.0 {
                let sum: f64 = (j..m).map(|i| fjac[i][j] * wa4[i]).sum();
                let temp = -sum / fjac[j][j];
                for i in j..m {
                    wa4[i] += fjac[i][j] * temp;
                }
            }
            fjac[j][j] = rdiag[j];
            qtf[j] = wa4[j];
        }
        let mut gnorm = 0.0f64;
        if fnorm != 0.0 {
            for j in 0..n {
                let l = ipvt[j];
                if acnorm[l] != 0.0 {
                    let sum: f64 = (0..=j).map(|i| fjac[i][j] * (qtf[i] / fnorm)).sum();
                    gnorm = gnorm.max((sum / acnorm[l]).abs());
                }
            }
        }
        if gnorm <= options.gtol {
            info = 4;
            break;
        }
        for j in 0..n {
            diag[j] = diag[j].max(acnorm[j]);
        }
        let mut r: Vec<Vec<f64>> = (0..n).map(|i| fjac[i][..n].to_vec()).collect();
        loop {
            let (p, step) = lmpar(&mut r, n, &ipvt, &diag, &qtf, delta, par);
            par = p;
            let wa1: Vec<f64> = step.iter().map(|v| -v).collect();
            let wa2: Vec<f64> = (0..n).map(|j| x[j] + wa1[j]).collect();
            let pnorm = enorm(&(0..n).map(|j| diag[j] * wa1[j]).collect::<Vec<_>>());
            if iter == 1 {
                delta = delta.min(pnorm);
            }
            let wa4 = fun(&wa2);
            nfev += 1;
            let fnorm1 = enorm(&wa4);
            let actred = if 0.1 * fnorm1 < fnorm { 1.0 - (fnorm1 / fnorm).powi(2) } else { -1.0 };
            let mut wa3 = vec![0.0; n];
            for j in 0..n {
                let temp = wa1[ipvt[j]];
                for i in 0..=j {
                    wa3[i] += r[i][j] * temp;
                }
            }
            let temp1 = enorm(&wa3) / fnorm;
            let temp2 = par.sqrt() * pnorm / fnorm;
            let prered = temp1 * temp1 + temp2 * temp2 / 0.5;
            let dirder = -(temp1 * temp1 + temp2 * temp2);
            let ratio = if prered != 0.0 { actred / prered } else { 0.0 };
            if ratio <= 0.25 {
                let mut temp = if actred >= 0.0 { 0.5 } else { 0.5 * dirder / (dirder + 0.5 * actred) };
                if 0.1 * fnorm1 >= fnorm || temp < 0.1 {
                    temp = 0.1;
                }
                delta = temp * delta.min(pnorm / 0.1);
                par /= temp;
            } else if par == 0.0 || ratio >= 0.75 {
                delta = pnorm / 0.5;
                par *= 0.5;
            }
            if ratio >= 1e-4 {
                x = wa2;
                xnorm = enorm(&(0..n).map(|j| diag[j] * x[j]).collect::<Vec<_>>());
                fvec = wa4;
                fnorm = fnorm1;
                iter += 1;
            }
            if actred.abs() <= options.ftol && prered <= options.ftol && 0.5 * ratio <= 1.0 {
                info = 1;
            }
            if delta <= options.xtol * xnorm {
                info = if info == 1 { 3 } else { 2 };
            }
            if info != 0 {
                break 'outer;
            }
            if nfev >= maxfev {
                info = 5;
            }
            if actred.abs() <= eps && prered <= eps && 0.5 * ratio <= 1.0 {
                info = 6;
            }
            if delta <= eps * xnorm {
                info = 7;
            }
            if gnorm <= eps {
                info = 8;
            }
            if info != 0 {
                break 'outer;
            }
            if ratio >= 1e-4 {
                break;
            }
        }
    }
    Ok(LmResult { x, fvec, nfev, njev, info })
}
/// Minimises `cᵀx` over a [`LinearProgram`]'s constraints with `x[i]` integer where
/// `integrality[i]` (SciPy's `milp`). Branch and bound: each node solves the LP relaxation with
/// tightened bounds; a relaxation no better than the best integer point found (the incumbent)
/// is pruned; an integral one becomes the incumbent; otherwise the most fractional variable
/// `xⱼ = v` splits the node into `xⱼ ≤ ⌊v⌋` and `xⱼ ≥ ⌈v⌉`. Nodes are explored best bound first,
/// and the search stops when the incumbent is within `mip_rel_gap` of the best open bound.
pub fn milp(problem: &LinearProgram, integrality: &[bool], options: MilpOptions) -> Result<MilpResult, ErrorsJSL> {
    let n = problem.n_vars();
    if integrality.len() != n {
        return Err(ErrorsJSL::IncompatibleArraySizes((integrality.len(), n)));
    }
    let tol = options.integrality_tolerance;
    // Integer variables take integer bounds.
    let root_bounds: Vec<(f64, f64)> = problem
        .bounds()
        .iter()
        .zip(integrality)
        .map(|(&(lo, hi), &int)| if int { ((lo - tol).ceil(), (hi + tol).floor()) } else { (lo, hi) })
        .collect();
    let mut result = MilpResult { status: MilpStatus::Infeasible, x: Vec::new(), objective: f64::INFINITY, dual_bound: f64::INFINITY, mip_gap: f64::INFINITY, nodes: 0 };
    if root_bounds.iter().any(|&(lo, hi)| lo > hi) {
        return Ok(result);
    }
    let solve = |bounds: &[(f64, f64)]| {
        let mut lp = problem.clone();
        for (i, &(lo, hi)) in bounds.iter().enumerate() {
            lp = lp.with_bounds(i, lo, hi);
        }
        lp.solve()
    };
    let mut heap = BinaryHeap::new();
    heap.push(Node { bound: f64::NEG_INFINITY, depth: 0, bounds: root_bounds });
    let gap_closed = |incumbent: f64, bound: f64| incumbent - bound <= options.mip_rel_gap * incumbent.abs().max(1e-300) || incumbent - bound <= 1e-9 * (1.0 + incumbent.abs());
    while let Some(node) = heap.pop() {
        if result.objective.is_finite() && gap_closed(result.objective, node.bound) {
            // Every open node's bound is at least this one's.
            heap.push(node);
            break;
        }
        if result.nodes >= options.node_limit {
            heap.push(node);
            result.status = MilpStatus::NodeLimit;
            break;
        }
        let lp = solve(&node.bounds)?;
        result.nodes += 1;
        match lp.status {
            LpStatus::Infeasible => continue,
            LpStatus::Unbounded => {
                result.status = MilpStatus::Unbounded;
                return Ok(result);
            }
            LpStatus::Optimal => {}
        }
        if result.objective.is_finite() && lp.objective >= result.objective - 1e-12 * (1.0 + result.objective.abs()) {
            continue;
        }
        // The most fractional integer variable.
        let branch = (0..n)
            .filter(|&i| integrality[i])
            .map(|i| (i, (lp.x[i] - lp.x[i].round()).abs()))
            .filter(|&(_, f)| f > tol)
            .max_by(|a, b| a.1.total_cmp(&b.1).then(b.0.cmp(&a.0)));
        match branch {
            None => {
                let x: Vec<f64> = (0..n).map(|i| if integrality[i] { lp.x[i].round() } else { lp.x[i] }).collect();
                let obj: f64 = problem.objective().iter().zip(&x).map(|(c, v)| c * v).sum();
                result.x = x;
                result.objective = obj;
                result.status = MilpStatus::Optimal;
            }
            Some((j, _)) => {
                let v = lp.x[j];
                let mut down = node.bounds.clone();
                down[j].1 = v.floor();
                let mut up = node.bounds;
                up[j].0 = v.ceil();
                for b in [down, up] {
                    if b[j].0 <= b[j].1 {
                        heap.push(Node { bound: lp.objective, depth: node.depth + 1, bounds: b });
                    }
                }
            }
        }
    }
    let open_bound = heap.iter().map(|nd| nd.bound).fold(f64::INFINITY, f64::min);
    result.dual_bound = open_bound.min(result.objective);
    if result.status == MilpStatus::NodeLimit && result.x.is_empty() {
        result.objective = f64::INFINITY;
    }
    if result.objective.is_finite() {
        result.mip_gap = if result.objective == result.dual_bound { 0.0 } else { (result.objective - result.dual_bound) / result.objective.abs().max(1e-300) };
    }
    Ok(result)
}
/// Minimises `f` subject to `lb ≤ x ≤ ub` by a truncated Newton method; `fg` returns `f` and its
/// gradient. Each iteration fixes the variables on a bound whose gradient points outwards, and
/// solves the Newton equations `H p = −g` for the others only approximately, by conjugate
/// gradients stopped at a relative residual `min(½, √‖g‖)` or at negative curvature; the
/// Hessian-vector products are forward differences of the gradient, so no Hessian is needed.
/// A projected backtracking line search along `p` keeps the iterates in the box.
pub fn minimize_tnc(mut fg: impl FnMut(&[f64]) -> (f64, Vec<f64>), x0: &[f64], lb: &[f64], ub: &[f64], options: TncOptions) -> Result<BoundedResult, ErrorsJSL> {
    let n = x0.len();
    if n == 0 || lb.len() != n || ub.len() != n {
        return Err(ErrorsJSL::IncompatibleArraySizes((lb.len(), n)));
    }
    if (0..n).any(|i| lb[i].is_nan() || ub[i].is_nan() || lb[i] > ub[i]) {
        return Err(ErrorsJSL::InvalidInputRange("minimize_tnc: need lb ≤ ub"));
    }
    let maxfun = options.maxfun.unwrap_or((100 * n).max(1000));
    let max_cg = options.max_cg.unwrap_or(n.clamp(1, 50));
    let mut x: Vec<f64> = (0..n).map(|i| x0[i].clamp(lb[i], ub[i])).collect();
    let (mut f, mut g) = fg(&x);
    let mut nfev = 1;
    let mut iterations = 0;
    let free_of = |x: &[f64], g: &[f64]| -> Vec<bool> { (0..n).map(|i| !((x[i] <= lb[i] && g[i] > 0.0) || (x[i] >= ub[i] && g[i] < 0.0))).collect() };
    let pg_norm = |x: &[f64], g: &[f64]| -> f64 { (0..n).map(|i| ((x[i] - g[i]).clamp(lb[i], ub[i]) - x[i]).abs()).fold(0.0, f64::max) };
    let mut converged = false;
    while nfev < maxfun {
        if pg_norm(&x, &g) <= options.pgtol {
            converged = true;
            break;
        }
        let free = free_of(&x, &g);
        let gf: Vec<f64> = (0..n).map(|i| if free[i] { g[i] } else { 0.0 }).collect();
        let gnorm = dot(&gf, &gf).sqrt();
        // Truncated conjugate gradients on H p = −g over the free variables.
        let hv = |v: &[f64], fg: DynFg<'_>, x: &[f64], g: &[f64]| -> Vec<f64> {
            let vn = dot(v, v).sqrt();
            let xn = dot(x, x).sqrt();
            let h = f64::EPSILON.sqrt() * (1.0 + xn) / vn.max(1e-300);
            let xh: Vec<f64> = (0..n).map(|i| x[i] + h * v[i]).collect();
            let (_, gh) = fg(&xh);
            (0..n).map(|i| if free[i] { (gh[i] - g[i]) / h } else { 0.0 }).collect()
        };
        let mut p = vec![0.0; n];
        let mut r: Vec<f64> = gf.iter().map(|v| -v).collect();
        let mut d = r.clone();
        let mut rr = dot(&r, &r);
        let eta = 0.5f64.min(gnorm.sqrt());
        for k in 0..max_cg {
            let hd = hv(&d, &mut fg, &x, &g);
            nfev += 1;
            let curv = dot(&d, &hd);
            if curv <= 1e-16 * dot(&d, &d) {
                if k == 0 {
                    p.clone_from(&d);
                }
                break;
            }
            let alpha = rr / curv;
            for i in 0..n {
                p[i] += alpha * d[i];
                r[i] -= alpha * hd[i];
            }
            let rr_new = dot(&r, &r);
            if rr_new.sqrt() <= eta * gnorm {
                break;
            }
            let beta = rr_new / rr;
            rr = rr_new;
            for i in 0..n {
                d[i] = r[i] + beta * d[i];
            }
        }
        if dot(&p, &gf) >= 0.0 {
            p = gf.iter().map(|v| -v).collect();
        }
        // Projected backtracking (Armijo) line search.
        let mut step = 1.0;
        let mut accepted = None;
        for _ in 0..40 {
            let xt: Vec<f64> = (0..n).map(|i| (x[i] + step * p[i]).clamp(lb[i], ub[i])).collect();
            let (ft, gt) = fg(&xt);
            nfev += 1;
            let decrease: f64 = (0..n).map(|i| g[i] * (xt[i] - x[i])).sum();
            if ft.is_finite() && ft <= f + 1e-4 * decrease {
                accepted = Some((xt, ft, gt));
                break;
            }
            step *= 0.5;
        }
        iterations += 1;
        let Some((xt, ft, gt)) = accepted else { break };
        let decrease = f - ft;
        let scale = f.abs().max(ft.abs());
        x = xt;
        f = ft;
        g = gt;
        if decrease <= options.ftol * scale {
            converged = pg_norm(&x, &g) <= options.pgtol;
            break;
        }
    }
    let active = (0..n).map(|i| if x[i] <= lb[i] { -1 } else if x[i] >= ub[i] { 1 } else { 0 }).collect();
    Ok(BoundedResult { x, fun: f, gradient: g, iterations, nfev, converged, active })
}
  • leastsq and root_lm are a line-by-line port of MINPACK’s lmder, lmdif, qrfac, lmpar and qrsolv, with SciPy’s defaults (ftol = xtol = 1.49012e-8, factor = 100).
  • least_squares_dogbox is a port of SciPy’s dogbox with the exact trust-region solver, unit x_scale and the robust losses.
  • milp solves each relaxation with the library’s two-phase simplex. That is reliable but slow, so milp is meant for problems with tens of integer variables, not the thousands HiGHS handles with presolve, cuts and heuristics.
  • minimize_tnc is the library’s own truncated Newton, without Nash’s preconditioner. It therefore defaults to more conjugate-gradient steps and a larger evaluation budget than SciPy’s TNC, and stops on the projected gradient alone.

In practice

The references are from SciPy 1.17.1, written by book/generator/data/make_opt211_refs.py:

Table 5.17. Dogbox and MINPACK's Levenberg-Marquardt against SciPy: the solutions, evaluation counts and termination codes.

Problemx vs SciPynfev: library / SciPynjevstatus / info
dogbox: Rosenbrock, x₁ ≥ 1.506 / 66 / 61 / 1
dogbox: Rosenbrock, −2 ≤ x ≤ (0.5, 2)012 / 1210 / 101 / 1
dogbox: exponential fit, rate ≤ 1.2 (active)2e-168 / 88 / 82 / 2
dogbox: exponential fit with outliers, soft L1 loss013 / 1311 / 112 / 2
leastsq: Rosenbrock, analytic Jacobian021 / 2116 / 164 / 4
leastsq: Rosenbrock, forward differences054 / 54—2 / 2
leastsq: exponential fit, 30 residuals4e-938 / 38—1 / 1
leastsq: x² + y² = 4, eˣ + y = 1016 / 16—2 / 2
leastsq: Powell’s badly scaled system2e-1353 / 53—2 / 2
root_lm: the same system016 / ——converged

The MINPACK and dogbox ports take the same steps as SciPy’s, with identical evaluation counts and termination codes. The solutions differ by at most relative, on the ill-conditioned exponential fit, where sums are rounded in a different order. SciPy’s root(method="lm") reports two more evaluations than leastsq for the same iterations, from its wrapper.

Table 5.18. Mixed-integer programs against SciPy's `milp` (HiGHS), with `mip_rel_gap = 0` except in the first.

ProblemObjective: library / SciPyxNodes
milp: SciPy’s example, 2 integers-2 / -2same5
milp: 0-1 knapsack, 20 items-487 / -487same71
milp: 3 integers and 1 continuous, with an equality26 / 26same15
milp: random, 8 integers in [0, 5], 6 constraints-49 / -49same15

Table 5.19. Truncated Newton against SciPy's TNC on the Rosenbrock function from , with SciPy's default options; errors against the true minimiser.

ProblemLibrary: error in xSciPy TNC: error in xnfev: library / SciPy
Rosenbrock, n = 21e-133e-665 / 83
Rosenbrock, n = 68e-157e-4237 / 60
Rosenbrock, n = 202e-142e-6567 / 118
Rosenbrock, n = 6, x₁ ≤ 0.5 (against tight L-BFGS-B)2e-115e-886 / 45

SciPy’s TNC stops when successive function values agree, which on Rosenbrock’s narrow valley leaves errors up to . The library’s runs continue to a projected gradient of . That costs more evaluations, mainly because there is no preconditioner, but gives the minimiser to near machine precision.

Figure 5.15. SciPy's example: maximise over the integer points under three constraints. The LP relaxation peaks at the vertex . Branching on or finds the integer optimum , attained at both and .

Strengths

  • MINPACK’s Levenberg-Marquardt is the most trusted unconstrained least-squares code, and the port reproduces SciPy’s results exactly.
  • Dogbox handles bounds with simple steps and few evaluations on small problems.
  • milp proves optimality (or reports the gap), handles mixed integer and continuous variables, and reports infeasibility.
  • Truncated Newton needs only gradients and memory.

Weaknesses

  • milp has no presolve, cutting planes or primal heuristics, and its simplex is dense, so it is far slower than HiGHS on larger problems.
  • Truncated Newton uses more evaluations than SciPy’s preconditioned TNC.

Exercises

  1. Show that the Levenberg-Marquardt step tends to the Gauss-Newton step as and to a short steepest-descent step as .
  2. Why does MINPACK need only one QR factorisation of per iteration, however many values of lmpar tries?
  3. In branch and bound, why can a node be discarded when its LP bound is no better than the incumbent?
  4. Show that .
Hints and answers
  1. . At this is the Gauss-Newton step. For large it is , a scaled negative gradient of .
  2. The factorisation is computed once. For each , the rows of are rotated into by Givens rotations in qrsolv, at cost per .
  3. Every integer point of the node is a feasible point of its relaxation, so none can be better than the relaxation’s optimum.
  4. Expand .

Further reading

  • J. J. Moré, “The Levenberg-Marquardt algorithm: implementation and theory”, in Numerical Analysis, Lecture Notes in Mathematics 630, Springer (1978) 105–116.
  • J. J. Moré, B. S. Garbow and K. E. Hillstrom, User Guide for MINPACK-1, Argonne National Laboratory report ANL-80-74 (1980).
  • C. Voglis and I. E. Lagaris, “A rectangular trust region dogleg approach for unconstrained and bound constrained nonlinear optimization”, WSEAS International Conference on Applied Mathematics (2004).
  • A. H. Land and A. G. Doig, “An automatic method of solving discrete programming problems”, Econometrica 28 (1960) 497–520.
  • R. S. Dembo and T. Steihaug, “Truncated-Newton algorithms for large-scale unconstrained optimization”, Mathematical Programming 26 (1983) 190–212.
  • S. G. Nash, “Newton-type minimization via the Lanczos method”, SIAM Journal on Numerical Analysis 21 (1984) 770–788.
  • Q. Huangfu and J. A. J. Hall, “Parallelizing the dual revised simplex method”, Mathematical Programming Computation 10 (2018) 119–142 (HiGHS).