Giter Club home page Giter Club logo

lasso's Introduction

LASSO: Solving Unbounded Subset Sum

With this algorithm I present a solution to the Unbounded Subset Sum Problem (USSP). The algorithm makes use of repeating commbinatorial patterns to leverage repetition in reducing the runtime that is required to retrieve all possible combinations summing to a query/target value. For application of this algorithm to a real-world problem in analytical chemistry, see this repository. Publications resulting from these works are forthcoming.

Algorithm Synopsis

The algorithm operates in two parts:

  • The first part writes all combinations of a specified combination length to local memory, making it relatively fast to retrieve this information later. This is a generalizable solution space because these combinations are repeated many times within the search space making it possible to only calculate them once.
  • The second part uses a branch and bound technique to query that generalizable solution space for combinations summing to the query/target value.

Boost

Note that this algorithm relies on the Boost::unordered_map header to operate. In some Linux-based operating systems, Boost comes with the installation, e.g. /usr/include/boost. The Gnu compiler will typically find the Boost library in a Unix type operating system but if you are using Windows, you might need to use the -I <boost source directory> flag when compiling with the Gnu compiler.

If your operating system does not come with Boost, you can use it by simply downloading Boost and unzipping the archive to the desired directory.

Build

This algorithm was originally written in C but makes use of the Boost hash table library so it is compiled in C++.
You can build from the source code using CMake and the CMakeLists.txt file included in this repository. In a Unix type operating system, the following steps can be applied from the root directory of this repository:

cmake .
./build/uss

Run

This algorithm does not take command line arguments. As such, you can simply run the algorithm using the format provided in the example main.cpp.

If running in Visual Studio Code in Windows, you can use the .vscode directory stored in this repository to run the algorithm in debugging mode as written up in the example. Note that this algorithm uses the Boost library so you will need to have a Boost installation for the CMake builder to find.

Usage

When using the algorithm in your own project, import the main header file, e.g. #include "<source directory>/unboundedSubsetSum.h", and then call the unboundedSubsetSum() function with the following parameters:

input_set         : An array filled with the input set, using double type
input_set_size    : The number of values in the input set 
query_value       : The query/target value to which combinations must sum
epsilon           : The amount by which the query value can vary, double type
print_times       : Print time taken by functions called during the algorithm (0 or 1)
print_details     : Print details relating to an algorithm rum (0 or 1)
print_comb        : Print all combinations summing to the query value (0 or 1)
print_test_times  : Print the overall time taken by an algorithm run (0 or 1)

Example

Using the algorithm is fairly straightforward. You can see an example of usage in the source/main.cpp file found in this repository.

lasso's People

Contributors

koos-burgoyne avatar glesica avatar

Watchers

James Cloos avatar

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.