Skip to content

Commit

Permalink
version 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kthohr committed Jan 17, 2022
1 parent 3aa62b0 commit 728ef09
Show file tree
Hide file tree
Showing 99 changed files with 1,495 additions and 1,206 deletions.
3 changes: 2 additions & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CXX = @CXX@

CXX_STD = @OPTIM_CXX_STD@
OPT_FLAGS = @OPTIM_WARN_FLAGS@ @OPTIM_OPT_FLAGS@
FPN_FLAGS = -DOPTIM_FPN_TYPE=@OPTIM_FPN_TYPE@

OPTIM_MATLIB_FLAGS = @OPTIM_MATLIB_FLAGS@
OPTIM_MATLIB_INCLUDE_PATH = @OPTIM_MATLIB_INCLUDE_PATH@
Expand All @@ -23,7 +24,7 @@ SHLIB = @OPTIM_SHLIB_NAME@
SHLIB_FLAGS = $(CXX_STD) @OPTIM_SHLIB_FLAGS@

# general flags
CXXFLAGS = $(CXX_STD) $(OPT_FLAGS) $(OPTIM_MATLIB_FLAGS) -I$(OPTIM_MATLIB_INCLUDE_PATH) -I$(OPTIM_HEADER_DIR)
CXXFLAGS = $(CXX_STD) $(OPT_FLAGS) $(FPN_FLAGS) $(OPTIM_MATLIB_FLAGS) -I$(OPTIM_MATLIB_INCLUDE_PATH) -I$(OPTIM_HEADER_DIR)
LIBS= @OPTIM_BLAS_LAPACK@

# core Optim files
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Features:
* [Eigen](http://eigen.tuxfamily.org/index.php) (version >= 3.4.0)
* OpenMP-accelerated algorithms for parallel computation.
* Straightforward linking with parallelized BLAS libraries, such as [OpenBLAS](https://github.com/xianyi/OpenBLAS).
* Available as a single (``float``) or double precision (``double``) library.
* Available as a header-only library, or as a compiled shared library.
* Released under a permissive, non-GPL license.

Expand Down Expand Up @@ -58,10 +59,10 @@ The inputs, in order, are:

For example, the BFGS algorithm is called using
```cpp
bfgs(Vec_t& init_out_vals, std::function<double (const Vec_t& vals_inp, Vec_t* grad_out, void* opt_data)> opt_objfn, void* opt_data);
bfgs(ColVec_t& init_out_vals, std::function<double (const ColVec_t& vals_inp, ColVec_t* grad_out, void* opt_data)> opt_objfn, void* opt_data);
```
where ``Vec_t`` is used to represent either ``arma::vec`` or ``Eigen::VectorXd`` types.
where ``ColVec_t`` is used to represent either ``arma::vec`` or ``Eigen::VectorXd`` types.
## Installation Method 1: Shared Library
Expand Down Expand Up @@ -90,7 +91,8 @@ Configuration options (see `./configure -h`):
&nbsp; &nbsp; &nbsp; **Primary**
* `-h` print help
* `-i` installation path; default: the build directory
* `-l` specify the choice of linear algebra library; `arma` or `eigen`
* `-f` floating-point precision mode (Eigen-based builds only); default: `double`
* `-l` specify the choice of linear algebra library; choose `arma` or `eigen`
* `-m` specify the BLAS and Lapack libraries to link against; for example, `-m "-lopenblas"` or `-m "-framework Accelerate"`
* `-o` compiler optimization options; defaults to `-O3 -march=native -ffp-contract=fast -flto -DARMA_NO_DEBUG`
* `-p` enable OpenMP parallelization features (*recommended*)
Expand Down
13 changes: 12 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ function print_help
echo " (default: disabled)" ;
echo " -d Developmental build" ;
echo " (default: disabled)" ;
echo " -f Floating-point number type" ;
echo " (default: double)" ;
echo " -g Debugging build (optimization flags set to -O0 -g)" ;
echo " (default: disabled)" ;
echo " -h Print help" ;
Expand All @@ -30,7 +32,7 @@ function print_help
echo "" ;
}

while getopts hcdgi:l:m:o:pr:-: option; do
while getopts hcdgf:i:l:m:o:pr:-: option; do
case "${option}" in
-)
case "${OPTARG}" in
Expand All @@ -41,6 +43,7 @@ while getopts hcdgi:l:m:o:pr:-: option; do
h) print_help; exit 2;;
c) OPTIM_COVERAGE_BUILD="y";;
d) OPTIM_DEV_BUILD="y";;
f) OPTIM_FPN_TYPE=${OPTARG};;
g) OPTIM_DEBUG_BUILD="y";;
i) OPTIM_INSTALL_PATH=${OPTARG};;
l) OPTIM_LINEAR_ALG_LIB=${OPTARG};;
Expand Down Expand Up @@ -207,6 +210,12 @@ fi

OPTIM_WARN_FLAGS="-Wall"

# floating-point number type

if [[ "${OPTIM_FPN_TYPE}" == "" ]]; then
OPTIM_FPN_TYPE="double"
fi

# shared library name and install path

OPTIM_SHLIB_NAME="liboptim.so"
Expand Down Expand Up @@ -286,6 +295,7 @@ else
echo -e " - OpenMP features: \x1B[31mdisabled\033[0m" >&2 ;
fi

echo " - floating-point number type: ${OPTIM_FPN_TYPE}"
echo " - optimization flags:"
echo " ${OPTIM_OPT_FLAGS}"

Expand Down Expand Up @@ -317,6 +327,7 @@ sed -e "s|@CXX@|${CXX}|" \
-e "s|@OPTIM_BLAS_LAPACK@|${OPTIM_BLAS_LAPACK}|" \
-e "s|@OPTIM_WARN_FLAGS@|${OPTIM_WARN_FLAGS}|" \
-e "s|@OPTIM_OPT_FLAGS@|${OPTIM_OPT_FLAGS}|" \
-e "s|@OPTIM_FPN_TYPE@|${OPTIM_FPN_TYPE}|" \
-e "s|@OPTIM_SHLIB_NAME@|${OPTIM_SHLIB_NAME}|" \
-e "s|@OPTIM_SHLIB_FLAGS@|${OPTIM_SHLIB_FLAGS}|" \
-e "s|@OPTIM_INSTALL_PATH@|${OPTIM_INSTALL_PATH}|" \
Expand Down
16 changes: 8 additions & 8 deletions docs/source/api/bfgs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ Function Declarations
---------------------

.. _bfgs-func-ref1:
.. doxygenfunction:: bfgs(Vec_t&, std::function<doubleconst Vec_t &vals_inp, Vec_t *grad_out, void *opt_data>, void *)
.. doxygenfunction:: bfgs(ColVec_t&, std::function<doubleconst ColVec_t &vals_inp, ColVec_t *grad_out, void *opt_data>, void *)
:project: optimlib

.. _bfgs-func-ref2:
.. doxygenfunction:: bfgs(Vec_t&, std::function<doubleconst Vec_t &vals_inp, Vec_t *grad_out, void *opt_data>, void *, algo_settings_t&)
.. doxygenfunction:: bfgs(ColVec_t&, std::function<doubleconst ColVec_t &vals_inp, ColVec_t *grad_out, void *opt_data>, void *, algo_settings_t&)
:project: optimlib

----
Expand All @@ -89,9 +89,9 @@ Optimization Control Parameters

The basic control parameters are:

- ``double grad_err_tol``: the error tolerance value controlling how small the :math:`L_2` norm of the gradient vector :math:`\| \nabla f \|` should be before 'convergence' is declared.
- ``fp_t grad_err_tol``: the error tolerance value controlling how small the :math:`L_2` norm of the gradient vector :math:`\| \nabla f \|` should be before 'convergence' is declared.

- ``double rel_sol_change_tol``: the error tolerance value controlling how small the proportional change in the solution vector should be before 'convergence' is declared.
- ``fp_t rel_sol_change_tol``: the error tolerance value controlling how small the proportional change in the solution vector should be before 'convergence' is declared.

The relative change is computed using:

Expand All @@ -105,17 +105,17 @@ The basic control parameters are:

- ``bool vals_bound``: whether the search space of the algorithm is bounded. If ``true``, then

- ``Vec_t lower_bounds``: defines the lower bounds of the search space.
- ``ColVec_t lower_bounds``: defines the lower bounds of the search space.

- ``Vec_t upper_bounds``: defines the upper bounds of the search space.
- ``ColVec_t upper_bounds``: defines the upper bounds of the search space.

Additional settings:

- ``double bfgs_settings.wolfe_cons_1``: Line search tuning parameter that controls the tolerance on the Armijo sufficient decrease condition.
- ``fp_t bfgs_settings.wolfe_cons_1``: Line search tuning parameter that controls the tolerance on the Armijo sufficient decrease condition.

- Default value: ``1E-03``.

- ``double bfgs_settings.wolfe_cons_2``: Line search tuning parameter that controls the tolerance on the curvature condition.
- ``fp_t bfgs_settings.wolfe_cons_2``: Line search tuning parameter that controls the tolerance on the curvature condition.

- Default value: ``0.90``.

Expand Down
16 changes: 8 additions & 8 deletions docs/source/api/broyden.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,19 @@ Function Declarations
---------------------

.. _broyden-func-ref1:
.. doxygenfunction:: broyden(Vec_t&, std::function<Vec_tconst Vec_t &vals_inp, void *opt_data>, void *)
.. doxygenfunction:: broyden(ColVec_t&, std::function<Vec_tconst ColVec_t &vals_inp, void *opt_data>, void *)
:project: optimlib

.. _broyden-func-ref2:
.. doxygenfunction:: broyden(Vec_t&, std::function<Vec_tconst Vec_t &vals_inp, void *opt_data>, void *, algo_settings_t&)
.. doxygenfunction:: broyden(ColVec_t&, std::function<Vec_tconst ColVec_t &vals_inp, void *opt_data>, void *, algo_settings_t&)
:project: optimlib

.. _broyden-func-ref3:
.. doxygenfunction:: broyden(Vec_t&, std::function<Vec_tconst Vec_t &vals_inp, void *opt_data>, void *, std::function<Mat_tconst Vec_t &vals_inp, void *jacob_data>, void *)
.. doxygenfunction:: broyden(ColVec_t&, std::function<Vec_tconst ColVec_t &vals_inp, void *opt_data>, void *, std::function<Mat_tconst ColVec_t &vals_inp, void *jacob_data>, void *)
:project: optimlib

.. _broyden-func-ref4:
.. doxygenfunction:: broyden(Vec_t&, std::function<Vec_tconst Vec_t &vals_inp, void *opt_data>, void *, std::function<Mat_tconst Vec_t &vals_inp, void *jacob_data>, void *, algo_settings_t&)
.. doxygenfunction:: broyden(ColVec_t&, std::function<Vec_tconst ColVec_t &vals_inp, void *opt_data>, void *, std::function<Mat_tconst ColVec_t &vals_inp, void *jacob_data>, void *, algo_settings_t&)
:project: optimlib

----
Expand All @@ -91,9 +91,9 @@ Optimization Control Parameters

The basic control parameters are:

- ``double rel_objfn_change_tol``: the error tolerance value controlling how small :math:`\| F \|` should be before 'convergence' is declared.
- ``fp_t rel_objfn_change_tol``: the error tolerance value controlling how small :math:`\| F \|` should be before 'convergence' is declared.

- ``double rel_sol_change_tol``: the error tolerance value controlling how small the proportional change in the solution vector should be before 'convergence' is declared.
- ``fp_t rel_sol_change_tol``: the error tolerance value controlling how small the proportional change in the solution vector should be before 'convergence' is declared.

The relative change is computed using:

Expand All @@ -107,9 +107,9 @@ The basic control parameters are:

- ``bool vals_bound``: whether the search space of the algorithm is bounded. If ``true``, then

- ``Vec_t lower_bounds``: defines the lower bounds of the search space.
- ``ColVec_t lower_bounds``: defines the lower bounds of the search space.

- ``Vec_t upper_bounds``: defines the upper bounds of the search space.
- ``ColVec_t upper_bounds``: defines the upper bounds of the search space.

In addition to these:

Expand Down
16 changes: 8 additions & 8 deletions docs/source/api/broyden_df.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,19 @@ Function Declarations
---------------------

.. _broyden-df-func-ref1:
.. doxygenfunction:: broyden_df(Vec_t&, std::function<Vec_tconst Vec_t &vals_inp, void *opt_data>, void *)
.. doxygenfunction:: broyden_df(ColVec_t&, std::function<Vec_tconst ColVec_t &vals_inp, void *opt_data>, void *)
:project: optimlib

.. _broyden-df-func-ref2:
.. doxygenfunction:: broyden_df(Vec_t&, std::function<Vec_tconst Vec_t &vals_inp, void *opt_data>, void *, algo_settings_t&)
.. doxygenfunction:: broyden_df(ColVec_t&, std::function<Vec_tconst ColVec_t &vals_inp, void *opt_data>, void *, algo_settings_t&)
:project: optimlib

.. _broyden-df-func-ref3:
.. doxygenfunction:: broyden_df(Vec_t&, std::function<Vec_tconst Vec_t &vals_inp, void *opt_data>, void *, std::function<Mat_tconst Vec_t &vals_inp, void *jacob_data>, void *)
.. doxygenfunction:: broyden_df(ColVec_t&, std::function<Vec_tconst ColVec_t &vals_inp, void *opt_data>, void *, std::function<Mat_tconst ColVec_t &vals_inp, void *jacob_data>, void *)
:project: optimlib

.. _broyden-df-func-ref4:
.. doxygenfunction:: broyden_df(Vec_t&, std::function<Vec_tconst Vec_t &vals_inp, void *opt_data>, void *, std::function<Mat_tconst Vec_t &vals_inp, void *jacob_data>, void *, algo_settings_t&)
.. doxygenfunction:: broyden_df(ColVec_t&, std::function<Vec_tconst ColVec_t &vals_inp, void *opt_data>, void *, std::function<Mat_tconst ColVec_t &vals_inp, void *jacob_data>, void *, algo_settings_t&)
:project: optimlib

----
Expand All @@ -109,9 +109,9 @@ Optimization Control Parameters

The basic control parameters are:

- ``double rel_objfn_change_tol``: the error tolerance value controlling how small :math:`\| F \|` should be before 'convergence' is declared.
- ``fp_t rel_objfn_change_tol``: the error tolerance value controlling how small :math:`\| F \|` should be before 'convergence' is declared.

- ``double rel_sol_change_tol``: the error tolerance value controlling how small the proportional change in the solution vector should be before 'convergence' is declared.
- ``fp_t rel_sol_change_tol``: the error tolerance value controlling how small the proportional change in the solution vector should be before 'convergence' is declared.

The relative change is computed using:

Expand All @@ -125,9 +125,9 @@ The basic control parameters are:

- ``bool vals_bound``: whether the search space of the algorithm is bounded. If ``true``, then

- ``Vec_t lower_bounds``: defines the lower bounds of the search space.
- ``ColVec_t lower_bounds``: defines the lower bounds of the search space.

- ``Vec_t upper_bounds``: defines the upper bounds of the search space.
- ``ColVec_t upper_bounds``: defines the upper bounds of the search space.

In addition to these:

Expand Down
18 changes: 9 additions & 9 deletions docs/source/api/cg.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ Function Declarations
---------------------

.. _cg-func-ref1:
.. doxygenfunction:: cg(Vec_t&, std::function<doubleconst Vec_t &vals_inp, Vec_t *grad_out, void *opt_data>, void *)
.. doxygenfunction:: cg(ColVec_t&, std::function<doubleconst ColVec_t &vals_inp, ColVec_t *grad_out, void *opt_data>, void *)
:project: optimlib

.. _cg-func-ref2:
.. doxygenfunction:: cg(Vec_t&, std::function<doubleconst Vec_t &vals_inp, Vec_t *grad_out, void *opt_data>, void *, algo_settings_t&)
.. doxygenfunction:: cg(ColVec_t&, std::function<doubleconst ColVec_t &vals_inp, ColVec_t *grad_out, void *opt_data>, void *, algo_settings_t&)
:project: optimlib

----
Expand All @@ -136,9 +136,9 @@ Optimization Control Parameters

The basic control parameters are:

- ``double grad_err_tol``: the error tolerance value controlling how small the :math:`L_2` norm of the gradient vector :math:`\| \nabla f \|` should be before 'convergence' is declared.
- ``fp_t grad_err_tol``: the error tolerance value controlling how small the :math:`L_2` norm of the gradient vector :math:`\| \nabla f \|` should be before 'convergence' is declared.

- ``double rel_sol_change_tol``: the error tolerance value controlling how small the proportional change in the solution vector should be before 'convergence' is declared.
- ``fp_t rel_sol_change_tol``: the error tolerance value controlling how small the proportional change in the solution vector should be before 'convergence' is declared.

The relative change is computed using:

Expand All @@ -152,29 +152,29 @@ The basic control parameters are:

- ``bool vals_bound``: whether the search space of the algorithm is bounded. If ``true``, then

- ``Vec_t lower_bounds``: defines the lower bounds of the search space.
- ``ColVec_t lower_bounds``: defines the lower bounds of the search space.

- ``Vec_t upper_bounds``: defines the upper bounds of the search space.
- ``ColVec_t upper_bounds``: defines the upper bounds of the search space.

Additional settings:

- ``int cg_settings.method``: Update method.

- Default value: ``2``.

- ``double cg_settings.restart_threshold``: parameter :math:`\nu` from step 2 in the algorithm description.
- ``fp_t cg_settings.restart_threshold``: parameter :math:`\nu` from step 2 in the algorithm description.

- Default value: ``0.1``.

- ``bool use_rel_sol_change_crit``: whether to enable the ``rel_sol_change_tol`` stopping criterion.

- Default value: ``false``.

- ``double cg_settings.wolfe_cons_1``: Line search tuning parameter that controls the tolerance on the Armijo sufficient decrease condition.
- ``fp_t cg_settings.wolfe_cons_1``: Line search tuning parameter that controls the tolerance on the Armijo sufficient decrease condition.

- Default value: ``1E-03``.

- ``double cg_settings.wolfe_cons_2``: Line search tuning parameter that controls the tolerance on the curvature condition.
- ``fp_t cg_settings.wolfe_cons_2``: Line search tuning parameter that controls the tolerance on the curvature condition.

- Default value: ``0.10``.

Expand Down
14 changes: 7 additions & 7 deletions docs/source/api/de.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,21 @@ Function Declarations
---------------------

.. _de-func-ref1:
.. doxygenfunction:: de(Vec_t&, std::function<doubleconst Vec_t &vals_inp, Vec_t *grad_out, void *opt_data>, void *)
.. doxygenfunction:: de(ColVec_t&, std::function<doubleconst ColVec_t &vals_inp, ColVec_t *grad_out, void *opt_data>, void *)
:project: optimlib

.. _de-func-ref2:
.. doxygenfunction:: de(Vec_t&, std::function<doubleconst Vec_t &vals_inp, Vec_t *grad_out, void *opt_data>, void *, algo_settings_t&)
.. doxygenfunction:: de(ColVec_t&, std::function<doubleconst ColVec_t &vals_inp, ColVec_t *grad_out, void *opt_data>, void *, algo_settings_t&)
:project: optimlib

----

.. _de-prmm-func-ref1:
.. doxygenfunction:: de_prmm(Vec_t&, std::function<doubleconst Vec_t &vals_inp, Vec_t *grad_out, void *opt_data>, void *)
.. doxygenfunction:: de_prmm(ColVec_t&, std::function<doubleconst ColVec_t &vals_inp, ColVec_t *grad_out, void *opt_data>, void *)
:project: optimlib

.. _de-prmm-func-ref2:
.. doxygenfunction:: de_prmm(Vec_t&, std::function<doubleconst Vec_t &vals_inp, Vec_t *grad_out, void *opt_data>, void *, algo_settings_t&)
.. doxygenfunction:: de_prmm(ColVec_t&, std::function<doubleconst ColVec_t &vals_inp, ColVec_t *grad_out, void *opt_data>, void *, algo_settings_t&)
:project: optimlib


Expand All @@ -113,15 +113,15 @@ Optimization Control Parameters

The basic control parameters are:

- ``double rel_objfn_change_tol``: the error tolerance value controlling how small the relative change in best candidate solution should be before 'convergence' is declared.
- ``fp_t rel_objfn_change_tol``: the error tolerance value controlling how small the relative change in best candidate solution should be before 'convergence' is declared.

- ``size_t iter_max``: the maximum number of iterations/updates before the algorithm exits.

- ``bool vals_bound``: whether the search space of the algorithm is bounded. If ``true``, then

- ``Vec_t lower_bounds``: defines the lower bounds of the search space.
- ``ColVec_t lower_bounds``: defines the lower bounds of the search space.

- ``Vec_t upper_bounds``: defines the upper bounds of the search space.
- ``ColVec_t upper_bounds``: defines the upper bounds of the search space.

In addition to these:

Expand Down
12 changes: 6 additions & 6 deletions docs/source/api/gd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ Function Declarations
---------------------

.. _gd-func-ref1:
.. doxygenfunction:: gd(Vec_t&, std::function<doubleconst Vec_t &vals_inp, Vec_t *grad_out, void *opt_data>, void *)
.. doxygenfunction:: gd(ColVec_t&, std::function<doubleconst ColVec_t &vals_inp, ColVec_t *grad_out, void *opt_data>, void *)
:project: optimlib

.. _gd-func-ref2:
.. doxygenfunction:: gd(Vec_t&, std::function<doubleconst Vec_t &vals_inp, Vec_t *grad_out, void *opt_data>, void *, algo_settings_t&)
.. doxygenfunction:: gd(ColVec_t&, std::function<doubleconst ColVec_t &vals_inp, ColVec_t *grad_out, void *opt_data>, void *, algo_settings_t&)
:project: optimlib

----
Expand All @@ -177,9 +177,9 @@ Optimization Control Parameters

The basic control parameters are:

- ``double grad_err_tol``: the error tolerance value controlling how small the :math:`L_2` norm of the gradient vector :math:`\| \nabla f \|` should be before 'convergence' is declared.
- ``fp_t grad_err_tol``: the error tolerance value controlling how small the :math:`L_2` norm of the gradient vector :math:`\| \nabla f \|` should be before 'convergence' is declared.

- ``double rel_sol_change_tol``: the error tolerance value controlling how small the proportional change in the solution vector should be before 'convergence' is declared.
- ``fp_t rel_sol_change_tol``: the error tolerance value controlling how small the proportional change in the solution vector should be before 'convergence' is declared.

The relative change is computed using:

Expand All @@ -193,9 +193,9 @@ The basic control parameters are:

- ``bool vals_bound``: whether the search space of the algorithm is bounded. If ``true``, then

- ``Vec_t lower_bounds``: defines the lower bounds of the search space.
- ``ColVec_t lower_bounds``: defines the lower bounds of the search space.

- ``Vec_t upper_bounds``: defines the upper bounds of the search space.
- ``ColVec_t upper_bounds``: defines the upper bounds of the search space.

In addition to these:

Expand Down
Loading

0 comments on commit 728ef09

Please sign in to comment.