mir-optim 0.0.1

Optimization Framework


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

Gitter Build Status Dub downloads Dub downloads License Latest version

mir-optim

Dlang Nonlinear Optimisers with external C API.

Algorithms

  • Modified Levenberg-Marquardt Algorithm (Nonlinear Least Squares).

See also online documentation.

Features

  • Idiomatic BetterC library. See example.cpp for compilation details.
  • C/C++ header
  • Multithread C++ examples
  • Tiny BetterC library size, <38KB
  • Based on LAPACK
  • Fast compilaiton speed. There are two (for float and double) precompiled algorithm instatiations. All generic API is thin wrappers around them.
  • Four APIs for any purpose:
    • Extern C/C++ API
    • Powerfull high level generic D API
    • Nothrow middle level generic D API
    • Low level nongeneric D API

Required system libraries

See wiki: Link with CBLAS & LAPACK.

Examples

Least Squares. Analitical Jacobian.

unittest
{
    import mir.ndslice.allocation: slice;
    import mir.ndslice.slice: sliced;
    import mir.blas: nrm2;

    auto lm = LeastSquaresLM!double(2, 2);
    lm.x[] = [100, 100]; // initial X
    // argmin_x f_0(x)^^2 + f_1(x)^^2
    lm.optimize!(
        (x, y) // f(x)
        {
            y[0] = x[0];
            y[1] = 2 - x[1];
        },
        (x, J) // J(x)
        {
            J[0, 0] = 1;
            J[0, 1] = 0;
            J[1, 0] = 0;
            J[1, 1] = -1;
        },
    );

    assert(nrm2((lm.x - [0, 2].sliced).slice) < 1e-8);
}

Least Squares. Multithread Jacobian approximation.

Jacobian finite difference approximation computed using in multiple threads.

unittest
{
    import mir.ndslice.allocation: slice;
    import mir.ndslice.slice: sliced;
    import mir.blas: nrm2;
    import std.parallelism: taskPool;

    auto lm = LeastSquaresLM!double(2, 2);
    lm.x[] = [100, 100];
    lm.optimize!(
        (x, y)
        {
            y[0] = x[0];
            y[1] = 2 - x[1];
        },
    )(taskPool);

    assert(nrm2((lm.x - [0, 2].sliced).slice) < 1e-8);
}

Our sponsors

<img src="https://raw.githubusercontent.com/libmir/mir-algorithm/master/images/symmetry.png" height="80" />         <img src="https://raw.githubusercontent.com/libmir/mir-algorithm/master/images/kaleidic.jpeg" height="80" />

Authors:
  • Ilya Yaroshenko
Dependencies:
mir-lapack, mir-algorithm
Versions:
2.0.5 2023-Mar-14
2.0.4 2023-Mar-13
2.0.3 2023-Mar-13
2.0.2 2023-Mar-11
2.0.1 2021-May-13
Show all 67 versions
Download Stats:
  • 0 downloads today

  • 2 downloads this week

  • 85 downloads this month

  • 18782 downloads total

Score:
2.5
Short URL:
mir-optim.dub.pm