libatomprobe
Library for Atom Probe Tomography (APT) computation
Static Public Member Functions | List of all members
AtomProbe::MassTool Class Reference

Class that brute-force solves the knapsack problem. More...

#include <massTool.h>

Static Public Member Functions

static void bruteKnapsack (std::vector< Weight > &weights, float targetWeight, float tolerance, unsigned int maxObjects, std::vector< std::vector< Weight > > &solutions)
 Depth-First-Search based brute force solve the knapsack problem,. More...
 
static void bruteKnapsack (std::vector< Weight > &weights, const std::vector< float > &targetWeight, float tolerance, unsigned int maxObjects, std::vector< std::vector< Weight > > &solutions)
 Multiple-target version of brute knapsack. More...
 

Detailed Description

Class that brute-force solves the knapsack problem.

Definition at line 43 of file massTool.h.

Member Function Documentation

◆ bruteKnapsack() [1/2]

void MassTool::bruteKnapsack ( std::vector< Weight > &  weights,
float  targetWeight,
float  tolerance,
unsigned int  maxObjects,
std::vector< std::vector< Weight > > &  solutions 
)
static

Depth-First-Search based brute force solve the knapsack problem,.

Record all solutions within "tolerance" of the value "targetWeight". Solutions are reported as std::vectors of weights. All solutions are ensured unique.

"weights" vector should contain the masses of the input object. Note that the elemIdx and isotopeIdx values in the Weight structure are used for tracking purposes only. Elements may be removed from this input vector by MassTool.

targetWeight is the total mass you want to find out what combination of weights matches. tolerance is the mass error from targetweight (+-tolerance) you are willing to accept maxObjects is the maximum number of weights you can combine to get the solution

Definition at line 117 of file massTool.cpp.

References WEIGHT_SEARCH_ENTRY::allowableWeights, WEIGHT_SEARCH_ENTRY::cumulativeWeight, WEIGHT_SEARCH_ENTRY::curWeights, FixedStack< T >::empty(), WEIGHT_SEARCH_ENTRY::offset, FixedStack< T >::pop(), FixedStack< T >::push(), and FixedStack< T >::top().

Referenced by main().

Here is the call graph for this function:

◆ bruteKnapsack() [2/2]

void MassTool::bruteKnapsack ( std::vector< Weight > &  weights,
const std::vector< float > &  targetWeight,
float  tolerance,
unsigned int  maxObjects,
std::vector< std::vector< Weight > > &  solutions 
)
static

The documentation for this class was generated from the following files: