Git Product home page Git Product logo

bdd's Introduction

Build Status

BDD

An integer linear program solver using a Lagrange decomposition into binary decision diagrams. Lagrange multipliers are updated through min-marginal averaging (a form of dual block coordinate ascent). Sequential and parallel CPU solvers are provided as well as a massively parallel GPU implementation.

Installation

git clone https://github.com/LPMP/BDD

Then continue with creating a build folder and use cmake:

mkdir build && cd build && cmake ..

If CUDA-solvers are to be built, set WITH_CUDA=ON in cmake and ensure CUDA is available (tested on CUDA 11.2, later versions should also work).

Command Line Usage

Given an input file ${input} in LP format, one can solve the problem via bdd_solver_cl ${config.json} where ${config.json} is a json configuration file.

It is structured as follows:

{
    "input": "${input file}",
    "variable order": "{input|bfs|minimum degree|cuthill}",
    "normalize constraints": "{true|false}",
    "precision": "{float|double}",
    "relaxation solver": "{sequential mma|parallel mma|cuda parallel mma|lbfgs parallel mma|cuda lbfgs parallel mma|subgradient}",
    "termination criteria": {
        "maximum iterations": ${integer},
        "improvement slope": ${real number},
        "minimum improvement": ${real number},
        "time limit": ${integer}
    },
    "perturbation rounding": {
        "initial perturbation": ${real number},
        "perturbation growth rate": ${real number},
        "inner iterations": ${integer},
        "outer iterations": ${integer}
    }
}
  • input: File containing the optimization problem in .lp or .opb format, argument required.
  • variable order: The order of optimization variables. Possible values are
    • input: As encountered in the input file, this is the default.
    • bfs: Use a breadth-first search through the variable-constraint adjacency matrix to determine a variable ordering starting from the most eccentric node.
    • minimum degree: Use the minimum degree ordering.
    • cuthill: Use the Cuthill McKee algorithm on the variable-constraint adjacency matrix to determina a variable ordering.
  • normalize constraints: Should variables in constraints be sorted according to the variable order? This argument is not required and defaults to true.
  • precision: Can be either float or double precision for all floating point computations. The argument is not required and defaults to double.
  • relaxation solver: Can be one of the following:
    • sequential mma for sequential min-marginal averaging [1].
    • parallel mma for parallel CPU deferred min-marginal averaging [2].
    • cuda parallel mma for parallel deferred min-marginal averaging on GPU (available if built with WITH_CUDA=ON) [2].
    • lbfgs parallel mma for L-BFGS using the parallel_mma [2] CPU solver as backbone.
    • lbfgs cuda parallel mma for L-BFGS using the mma_cuda [2] GPU solver as backbone (available if built with WITH_CUDA=ON).
    • subgradient for subgradient ascent with adaptive step sizes.
  • termination criteria: Terminate the relaxation optimization if either of the below stopping criteria is satisfied. The argument is not required.
    • maximum iterations: For terminating after a pre-specified number of iterations, default value 1000.
    • improvement slope: For terminating if improvement between iterations is less than fraction of the improvement after the first iteration, default value 1e-6.
    • minimum improvement: For terminating if improvement between iterations is less than the specified value, default value 1e-6.
    • time limit: For terminating if optimization takes longer than value in seconds, default value 3600.
  • perturbation rounding: Compute primal solution by perturbing costs such that the relaxation solver solution becomes integral.
    • initial perturbation: By how much should costs be perturbed, default value 0.1.
    • perturbation growth rate: The factor specifying by how much perturbation should be increased in each perturbation round, default value 1.1.
    • inner iterations: For how many iterations should the relaxation solver run between perturbing costs, default value 100.
    • outer iterations: How many perturbation rounds should be performed, default value 100.
  • lbfgs: If a LBFG-S solver is chosen, the following non-required parameters can be passed:
    • history size: how many past iterates should be used, default value 5.
    • initial step size: the initial step size for the LBFG-S step, default value 1e-6.
    • required relative lb increase: the required relative increase in the lower bound for a step to be considered successful, default value 1e-6.
    • step size decrease factor: the factor by which to decrease the step size if a step is unsuccessful, default value 0.8.
    • step size increase factor: the factor by which to increase the step size if a step is successful, default value 1.1.

Python interface

All solvers are exposed to Python. To install Python solver do:

git clone [email protected]:LPMP/BDD.git
cd BDD
python setup.py install

To use Python solver only on CPU (e.g. GPU not available) replace last command by

WITH_CUDA=OFF python setup.py install

For running the solver via Python interface do:

from BDD.bdd_solver_py import bdd_solver as bdd_solver

solver = bdd_solver(input file)
solver.solve()

For more information about setting-up the solver especially from Python see this guide. The python interface is exposed via bdd_solver_py.py and one example of use is in test_bdd_solver_py.py.

Learned solver (DOGE-Train)

Please navigate to DOGE sub-folder.

References

If you use this work please cite

bdd's People

Contributors

aabbas90 avatar janhendriklange avatar pawelswoboda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bdd's Issues

Issue building

Hi! I am very interested in using your solver!

I am running into the following error:
fatal error: cub/detail/device_synchronize.cuh: No such file or directory 36 | #include <cub/detail/device_synchronize.cuh>

I am using CUDA 11.4

It looks like I don't have any cub/detail/ directory:

ls -l /usr/local/cuda-11.4/include/cub/
total 212
drwxr-xr-x 2 root root  4096 Jul  1 20:12 agent
drwxr-xr-x 3 root root  4096 Jul  1 20:12 block
drwxr-xr-x 2 root root  4096 Jul  1 20:12 cmake
-rw-r--r-- 1 root root  2000 Jul  1 20:12 config.cuh
-rw-r--r-- 1 root root  3750 Jul  1 20:12 cub.cuh
drwxr-xr-x 3 root root  4096 Jul  1 20:12 device
drwxr-xr-x 2 root root  4096 Jul  1 20:12 grid
drwxr-xr-x 2 root root  4096 Jul  1 20:12 host
drwxr-xr-x 2 root root  4096 Jul  1 20:12 iterator
drwxr-xr-x 2 root root  4096 Jul  1 20:12 thread
-rw-r--r-- 1 root root 29129 Jul  1 20:12 util_allocator.cuh
-rw-r--r-- 1 root root  6955 Jul  1 20:12 util_arch.cuh
-rw-r--r-- 1 root root  3652 Jul  1 20:12 util_compiler.cuh
-rw-r--r-- 1 root root  6333 Jul  1 20:12 util_cpp_dialect.cuh
-rw-r--r-- 1 root root  5763 Jul  1 20:12 util_debug.cuh
-rw-r--r-- 1 root root  2176 Jul  1 20:12 util_deprecated.cuh
-rw-r--r-- 1 root root 23022 Jul  1 20:12 util_device.cuh
-rw-r--r-- 1 root root  3710 Jul  1 20:12 util_macro.cuh
-rw-r--r-- 1 root root  2872 Jul  1 20:12 util_math.cuh
-rw-r--r-- 1 root root  2368 Jul  1 20:12 util_namespace.cuh
-rw-r--r-- 1 root root 22197 Jul  1 20:12 util_ptx.cuh
-rw-r--r-- 1 root root 40332 Jul  1 20:12 util_type.cuh
-rw-r--r-- 1 root root  3114 Jul  1 20:12 version.cuh
drwxr-xr-x 3 root root  4096 Jul  1 20:12 warp

Do you have any advice on how to proceed? I am unable to install different CUDA versions on this machine. Thanks!

Could you please introduce how to build the problem file?

If I have a million variables, can the solver work? Could you please explain how to build a problem file for the BDD?

In addition, the compile will break for the reason "/home/XXX/Downloads/BDD/include/run_solver_util.h(68): error: namespace "std" has no member "cout". If I add "# include " in the header file, the compile will work.

Issues and Fixes when Building

I recently wanted to build BDD solver python-bindings on my machine (Linux Ubuntu 22.04, Core i9 12900k, RTX3060) via

git clone https://github.com/LPMP/BDD
cd BDD
git submodule update --remote --recursive --init
python setup.py install # where python command refers to python 3 installation 

and encountered several issues. As a reference (and maybe for future fixes) i post them here so not everyone has to go on the journey to solve them :)

My compiler(s) are complaining about multiple things:

  • size_t not found. Fix: add #include <stddef.h> to this line of two_dimensional_variable_array.hxx
  • "narrowing conversion" in incremental_mm_agreement_rounding_cuda.cu. (Definitely just a temporary) fix: replace the linked line with thrust::transform(first, last, delta_it_begin, mm_types_transform<typename SOLVER::value_type>{(float)cur_delta, (float)max_incon_mm_diff, 2.0, false}); (basically casting cur_delta and max_incon_mm_diff ALWAYS to float which might cause precision loss when using double-solvers)
  • file <cub/detail/detect_cuda_runtime.cuh not found. fix: 1) navigate with console to <bdd_root>/external/thrust/dependencies/cub/ and git checkout main && git pull (in fact, before building the bdd project i did perform git submodule update --init --recursive --remote which should actually solve it but it didnt...)
  • file <cuda_runtime.h> not found. Fix: i added after this line include_directories("${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}")

help

when the project 'make' in the 'build' directory,an ‘size_t don‘’t defined’ error appear,how can i deal with it?does the version of gcc11 cause that?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.