# mir-optim 1.5.1

Optimisation Framework

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

## mir-optim

Dlang Nonlinear Optimisers with external C API.

#### Konwn bugs

• Random wrong results when `taskPool` is passed.

#### Algorithms

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

See also online documentation.

#### Features

• Idiomatic BetterC library. See `examples/least_squares.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. Generic API is a 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

## Examples

#### Least Squares. Analytical Jacobian.

``````unittest
{
import mir.optim.least_squares;
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. Multithreaded Jacobian approximation.

Jacobian finite difference approximation computed in multiple threads.

``````unittest
{
import mir.optim.least_squares;
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[] = [-1.2, 1];
lm.optimize!(
(x, y) // Rosenbrock function
{
y[0] = 10 * (x[1] - x[0]^^2);
y[1] = 1 - x[0];
},
)(taskPool);

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

#### Our sponsors

• Registered by Ilya Yaroshenko
• 1.5.1 released 19 days ago
• libmir/mir-optim
• BSL-1.0
Authors:
• Ilya Yaroshenko
Dependencies:
mir-lapack
Versions:
 1.5.1 2019-Nov-16 1.5.0 2019-Sep-06 1.4.6 2019-Aug-15 1.4.5 2019-Apr-20 1.4.4 2019-Jan-04
Download Stats:
• 5 downloads today

• 35 downloads this week

• 158 downloads this month

• 955 downloads total

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