global namespace of project. More...
Namespaces | |
auctions | |
Auctions namespace. | |
data_structures | |
Data Structure namespace. | |
detail | |
Detail namespace. | |
greedy | |
Greedy namespace. | |
hash | |
Hash functions namespace. | |
ir | |
Iterative Rounding namespace. | |
local_search | |
Local Search namespace. | |
lp | |
Linear Programming namespace. | |
utils | |
Utils namespace. | |
Classes | |
struct | k_means_visitor |
k means visitor More... | |
class | thread_pool |
simple threadpool, class uses also current thread! More... | |
class | distance_oracle_thorup2kminus1approximation |
2k-1 approximate distance oracle More... | |
class | hash_function_tuple |
functor representing tuple of hash functions More... | |
class | hash_function_tuple_generator |
class | lsh_nearest_neighbors_regression |
detail More... | |
class | frequent_directions |
Represents sketch of matrix. More... | |
class | dreyfus_wagner |
class | average_accumulator |
helper class facilitating counting average More... | |
class | subset_backtrack |
detail More... | |
struct | edge_hash |
hash for edge_descriptor in bgl, undirected version More... | |
struct | edge_hash< Graph, typename std::enable_if< std::is_same< typename boost::graph_traits< Graph >::directed_category, boost::directed_tag >::value >::type > |
hash for edge_descriptor in bgl, directed version More... | |
struct | range_hash |
Functor that can be used as a std::unordered_map/set hash param, when key is a range. copied from: http://stackoverflow.com/questions/10405030/c-unordered-map-fail-when-used-with-a-vector-as-key. More... | |
struct | density |
density functor, for given value and size More... | |
struct | less_pointees_t |
compare pointee using comparator More... | |
struct | make_tuple |
function object for std::make_tuple More... | |
struct | pretty_stream |
pretty_stream stream that uses pretty_to_string method More... | |
Typedefs | |
using | RestrictionsVector = std::vector< std::pair< unsigned, unsigned >> |
using | default_hash_function_generator = lsh::hamming_hash_function_generator |
using | minus_infinity = detail::infinity< false > |
detail | |
using | plus_infinity = detail::infinity< true > |
template<typename T > | |
using | decay_t = typename std::decay< T >::type |
short version of std::decay | |
template<typename Range > | |
using | range_to_ref_t = typename boost::range_reference< Range >::type |
for given range returns type of its reference | |
template<typename Range > | |
using | range_to_elem_t = typename boost::range_value< Range >::type |
for given range returns type of its element | |
template<typename Range > | |
using | range_to_diff_type_t = typename boost::range_difference< Range >::type |
for given collection returns its difference type | |
template<typename T , int k> | |
using | k_tuple_t = typename detail::k_tuple< T, k >::type |
returns tuple consisting of k times type T | |
template<class F > | |
using | pure_result_of_t = typename std::decay< typename std::result_of< F >::type >::type |
return pure type of function (decays const and reference) | |
template<typename T1 , typename T2 > | |
using | promote_with_t = puretype(std::declval< T1 >()+std::declval< T2 >()) |
return type obtained after adding values of given types | |
template<typename T > | |
using | promote_with_double_t = promote_with_t< T, double > |
return type after promotion with double | |
Enumerations | |
enum | Terminals { NONTERMINAL, TERMINAL } |
enum indicates if given color represents terminal or NONTERMINAL. | |
Functions | |
template<typename Cluster , typename OutputIterator > | |
void | centroid_minimalize_w_c_s_s (Cluster &&cluster, OutputIterator out) |
return centroid that minimize within-cluster sum of squares | |
template<typename Clusters , typename OutputIterator > | |
void | centroids_minimalize_w_c_s_s (Clusters &&clusters, OutputIterator out) |
centroid minimize within cluster sum of squares More... | |
template<typename Points , class Centers , class OutputIterator , class Visitor = k_means_visitor> | |
auto | k_means (Points &&points, Centers &¢ers, OutputIterator result, Visitor visitor=Visitor{}) |
this is solve k_means_clustering problem and return vector of cluster example:
#include <vector>
#include <iostream>
#include "paal/clustering/k_means_clustering.hpp"
#include "paal/utils/functors.hpp"
int main() {
using Point = std::vector<double>;
// sample data
unsigned const int NUMBER_OF_CLUSTER = 2;
std::vector<Point> points = { { 0, 0 },
{ 0, 3 },
{ 4, 0 } };
std::vector<std::pair<Point , int>> point_cluster_pair;
std::vector<Point> centers(NUMBER_OF_CLUSTER);
// solution
paal::get_random_centers(points, NUMBER_OF_CLUSTER, centers.begin());
paal::k_means(points , centers,
back_inserter(point_cluster_pair));
for (auto i : point_cluster_pair) {
for(auto && j : i.first) {
std::cout << j << ",";
}
std::cout<< " " << i.second << std::endl;
}
| |
template<class RangeLeft , class RangeRight > | |
auto | distance_square (RangeLeft &&lrange, RangeRight &&rrange) |
template<class Point , class Centers > | |
auto | closest_to (Point &&point, Centers &¢ers) |
template<class Points , class Centers , class Centroid , class ClosestTo , class OutputIterator , class CentroidEqual = utils::equal_to, class Visitor = k_means_visitor> | |
auto | k_means (Points &&points, Centers ¢ers, Centroid centroid, ClosestTo closest_to, OutputIterator result, CentroidEqual c_equal=CentroidEqual{}, Visitor visitor=Visitor{}) |
template<typename Points , typename OutputIterator , typename RNG = std::default_random_engine> | |
auto | get_random_centers (Points &&points, int number_of_centers, OutputIterator out, RNG &&rng=std::default_random_engine{}) |
template<typename Points , typename RNG = std::default_random_engine> | |
auto | get_random_clusters (Points &&points, int number_of_clusters, RNG &&rng=std::default_random_engine{}) |
template<typename Metric , typename Cycle > | |
Metric::DistanceType | get_cycle_length (const Metric &m, const Cycle &cm) |
computes length of the cycle More... | |
template<typename Cycle , typename Stream > | |
void | print_cycle (const Cycle &cm, Stream &o, const std::string &endl="\n") |
pints cycle to std out | |
template<typename Graph , typename EdgeWeightMap , typename VertexIndexMap , typename Rand = std::default_random_engine> | |
distance_oracle_thorup2kminus1approximation < Graph, VertexIndexMap, EdgeWeightMap, Rand > | make_distance_oracle_thorup2kminus1approximation (const Graph &g, const int k, VertexIndexMap index, EdgeWeightMap edge_weight, Rand &&random_engine=Rand(5426u)) |
template<typename Graph , typename P = char, typename T = boost::detail::unused_tag_type, typename R = boost::no_property, typename Rand = std::default_random_engine> | |
auto | make_distance_oracle_thorup2kminus1approximation (const Graph &g, const int k, const boost::bgl_named_params< P, T, R > ¶ms=boost::no_named_parameters(), Rand &&random_engine=Rand(5426u)) -> distance_oracle_thorup2kminus1approximation< Graph, decltype(choose_const_pmap(get_param(params, boost::vertex_index), g, boost::vertex_index)), decltype(choose_const_pmap(get_param(params, boost::edge_weight), g, boost::edge_weight)), Rand > |
template<typename ValueIterator , typename Objects , typename ObjectSizeFunctor , typename Combine , typename Compare , typename Init , typename GetPositionRange > | |
detail::FunctorOnRangePValue < ObjectSizeFunctor, Objects > | fill_knapsack_dynamic_table (ValueIterator valuesBegin, ValueIterator valuesEnd, Objects &&objects, ObjectSizeFunctor size, Combine combine, Compare compare, Init init, GetPositionRange get_range) |
Computes dynamic algorithm table (valuesBegin, valuesEnd) The values collection has element type ValueOrNull, The default constructed ValueOrNull should represent empty object. This collection is filled using init, compare and combine functors. More... | |
template<typename Objects , typename OutputIterator , typename ObjectSizeFunctor , typename ObjectValueFunctor = utils::return_one_functor> | |
auto | knapsack_0_1 (Objects &&objects, detail::FunctorOnRangePValue< ObjectSizeFunctor, Objects > capacity, OutputIterator out, ObjectSizeFunctor size, ObjectValueFunctor value=ObjectValueFunctor{}) |
Solution to Knapsack 0/1 problem. More... | |
template<typename Objects , typename ObjectSizeFunctor , typename ObjectValueFunctor = utils::return_one_functor> | |
auto | knapsack_0_1_no_output (Objects &&objects, detail::FunctorOnRangePValue< ObjectSizeFunctor, Objects > capacity, ObjectSizeFunctor size, ObjectValueFunctor value=ObjectValueFunctor{}) |
Solution to Knapsack 0/1 problem, without retrieving the objects in the solution. More... | |
template<typename OutputIterator , typename Objects , typename ObjectSizeFunctor , typename ObjectValueFunctor > | |
detail::knapsack_base< Objects, ObjectSizeFunctor, ObjectValueFunctor > ::return_type | knapsack_0_1_on_value_fptas (double epsilon, Objects &&objects, detail::FunctorOnRangePValue< ObjectSizeFunctor, Objects > capacity, OutputIterator out, ObjectSizeFunctor size, ObjectValueFunctor value) |
template<typename OutputIterator , typename Objects , typename ObjectSizeFunctor , typename ObjectValueFunctor > | |
detail::knapsack_base< Objects, ObjectSizeFunctor, ObjectValueFunctor > ::return_type | knapsack_0_1_on_size_fptas (double epsilon, Objects &&objects, detail::FunctorOnRangePValue< ObjectSizeFunctor, Objects > capacity, OutputIterator out, ObjectSizeFunctor size, ObjectValueFunctor value) |
template<typename Objects , typename ObjectSizeFunctor , typename ObjectValueFunctor > | |
detail::knapsack_base< Objects, ObjectSizeFunctor, ObjectValueFunctor > ::return_type | knapsack_0_1_no_output_on_value_fptas (double epsilon, Objects &&objects, detail::FunctorOnRangePValue< ObjectSizeFunctor, Objects > capacity, ObjectSizeFunctor size, ObjectValueFunctor value) |
template<typename Objects , typename ObjectSizeFunctor , typename ObjectValueFunctor > | |
detail::knapsack_base< Objects, ObjectSizeFunctor, ObjectValueFunctor > ::return_type | knapsack_0_1_no_output_on_size_fptas (double epsilon, Objects &&objects, detail::FunctorOnRangePValue< ObjectSizeFunctor, Objects > capacity, ObjectSizeFunctor size, ObjectValueFunctor value) |
template<typename Objects , typename OutputIterator , typename ObjectSizeFunctor , typename ObjectValueFunctor = utils::return_one_functor> | |
detail::knapsack_base< Objects, ObjectSizeFunctor, ObjectValueFunctor > ::return_type | knapsack_unbounded (Objects &&objects, detail::FunctorOnRangePValue< ObjectSizeFunctor, Objects > capacity, OutputIterator out, ObjectSizeFunctor size, ObjectValueFunctor value=ObjectValueFunctor()) |
Solution to the knapsack problem. More... | |
template<typename OutputIterator , typename Objects , typename ObjectSizeFunctor , typename ObjectValueFunctor > | |
detail::knapsack_base< Objects, ObjectSizeFunctor, ObjectValueFunctor > ::return_type | knapsack_unbounded_on_value_fptas (double epsilon, Objects &&objects, detail::FunctorOnRangePValue< ObjectSizeFunctor, Objects > capacity, OutputIterator out, ObjectSizeFunctor size, ObjectValueFunctor value) |
template<typename OutputIterator , typename Objects , typename ObjectSizeFunctor , typename ObjectValueFunctor > | |
detail::knapsack_base< Objects, ObjectSizeFunctor, ObjectValueFunctor > ::return_type | knapsack_unbounded_on_size_fptas (double epsilon, Objects &&objects, detail::FunctorOnRangePValue< ObjectSizeFunctor, Objects > capacity, OutputIterator out, ObjectSizeFunctor size, ObjectValueFunctor value) |
template<typename OutputIterator , typename Objects , typename ObjectSizeFunctor , typename ObjectValueFunctor , typename std::enable_if< !detail::is_range_const< Objects >::value >::type * = nullptr> | |
detail::knapsack_base< Objects, ObjectSizeFunctor, ObjectValueFunctor > ::return_type | knapsack_0_1_two_app (Objects &&objects, typename detail::FunctorOnRangePValue< ObjectSizeFunctor, Objects > capacity, OutputIterator out, ObjectValueFunctor value, ObjectSizeFunctor size) |
detail More... | |
template<typename OutputIterator , typename Objects , typename ObjectSizeFunctor , typename ObjectValueFunctor , typename std::enable_if<!detail::is_range_const< Objects >::value >::type * = nullptr> | |
detail::knapsack_base< Objects, ObjectSizeFunctor, ObjectValueFunctor > ::return_type | knapsack_unbounded_two_app (Objects &&objects, typename detail::FunctorOnRangePValue< ObjectSizeFunctor, Objects > capacity, OutputIterator out, ObjectValueFunctor value, ObjectSizeFunctor size) |
detail More... | |
template<typename Graph , typename OutputIterator , typename EdgeWeightMap , typename ColorMap > | |
auto | steiner_tree_greedy (const Graph &g, OutputIterator out, EdgeWeightMap edge_weight, ColorMap color_map) -> typename std::pair< typename boost::property_traits< EdgeWeightMap >::value_type, typename boost::property_traits< EdgeWeightMap >::value_type > |
non-named version of steiner_tree_greedy More... | |
template<typename Graph , typename OutputIterator , typename P , typename T , typename R > | |
auto | steiner_tree_greedy (const Graph &g, OutputIterator out, const boost::bgl_named_params< P, T, R > ¶ms) |
named version of steiner_tree_greedy More... | |
template<typename Graph , typename OutputIterator > | |
auto | steiner_tree_greedy (const Graph &g, OutputIterator out) |
version of steiner_tree_greedy with all default parameters More... | |
template<typename Restrictions > | |
RestrictionsVector | prune_restrictions_to_tree (Restrictions res, int N) |
Returns a list of restrictions, made of the edges of a maximum spanning tree in a clique with edge weights equal to restriction values between the edges. More... | |
template<typename Rand = std::default_random_engine, typename Distribution = std::uniform_real_distribution<double>, typename LP = lp::glp, typename Graph , typename OutputIterator , typename P , typename T , typename R > | |
auto | multiway_cut (const Graph &g, OutputIterator out, const boost::bgl_named_params< P, T, R > ¶ms, Rand &&random_engine=std::default_random_engine(5426u)) -> typename boost::property_traits< puretype(boost::choose_const_pmap(get_param(params, boost::edge_weight), g, boost::edge_weight))>::value_type |
detail More... | |
template<typename Rand = std::default_random_engine, typename Distribution = std::uniform_real_distribution<double>, typename LP = lp::glp, typename Graph , class OutputIterator > | |
auto | multiway_cut (const Graph &graph, OutputIterator result, Rand random_engine=std::default_random_engine(5426u)) -> detail::CostType< Graph > |
this is solve multiway_cut problem and return cut_cost example:
#include "paal/multiway_cut/multiway_cut.hpp"
#include <boost/graph/adjacency_list.hpp>
int main() {
// sample data
std::vector<std::pair<int,int>> edges_p{{0,3},{1,3},
{0,4},{2,4},
{1,5},{2,5},
{3,6},{4,6},
{3,7},{5,7},
{4,8},{5,8},
{6,7},{6,8},{7,8}
};
const int vertices_num = 9;
std::vector<int> cost_edges{100,100,100,100,100,100,10,10,10,10,10,10,1,1,1};
std::vector<int> terminals = { 0, 1, 2 };
boost::adjacency_list<
boost::vecS, boost::vecS, boost::undirectedS,
boost::property<boost::vertex_index_t, int,
boost::property<boost::vertex_color_t, int>>,
boost::property<boost::edge_weight_t, int>
> graph(edges_p.begin(), edges_p.end(), cost_edges.begin(), vertices_num);
for (std::size_t i = 1; i <= terminals.size(); ++i) {
put(boost::vertex_color, graph, terminals[i - 1], i);
}
//solve
std::vector<std::pair<int,int>> vertices_parts;
auto cost_cut = paal::multiway_cut(graph, back_inserter(vertices_parts));
//print result
std::cout << "cost cut: " << cost_cut << std::endl;
std::cout << "vertices (part)" << std::endl;
for(auto i: vertices_parts) {
std::cout << " " << i.first << " ( " << i.second << " )" << std::endl;
}
paal::lp::glp::free_env();
}
| |
template<typename FunctionGenerator > | |
auto | make_hash_function_tuple_generator (FunctionGenerator &&function_generator, unsigned hash_functions_per_point) |
template<typename TrainingPoints , typename TrainingResults , typename LshFunctionGenerator > | |
auto | make_lsh_nearest_neighbors_regression (TrainingPoints &&training_points, TrainingResults &&training_results, unsigned passes, LshFunctionGenerator &&lsh_function_generator, unsigned threads_count=std::thread::hardware_concurrency()) |
this is the most general version of the make_lsh_nearest_neighbors_regression, It takes any hash function generator. More... | |
template<typename TrainingPoints , typename TrainingResults , typename FunctionGenerator > | |
auto | make_lsh_nearest_neighbors_regression_tuple_hash (TrainingPoints &&training_points, TrainingResults &&training_results, unsigned passes, FunctionGenerator &&function_generator, unsigned hash_functions_per_point, unsigned threads_count=std::thread::hardware_concurrency()) |
This is the special version of make_lsh_nearest_neighbors_regression. This version assumes that hash function is concatenation (tuple) of several hash functions. In this function user provide Function generator for the inner functions only. More... | |
template<typename Matrix > | |
auto | make_frequent_directions (Matrix matrix) |
make for frequent_directions | |
template<typename Matrix > | |
auto | make_frequent_directions (Matrix matrix, std::size_t const compress_size) |
make for frequent_directions with compress_size | |
template<typename CoordinateType > | |
auto | make_frequent_directions (std::size_t rows_count, std::size_t columns_count) |
make for frequent_directions using default matrix | |
template<typename CoordinateType > | |
auto | make_frequent_directions (std::size_t rows_count, std::size_t columns_count, std::size_t const compress_size) |
make for frequent_directions using default matrix and compress_size | |
template<unsigned int TerminalsLimit = 32, typename Metric , typename Terminals , typename NonTerminals > | |
dreyfus_wagner< Metric, Terminals, NonTerminals, TerminalsLimit > | make_dreyfus_wagner (const Metric &metric, const Terminals &terminals, const NonTerminals &non_terminals) |
Creates a dreyfus_wagner object. More... | |
template<typename Metric , typename Voronoi , typename OutputIterator > | |
void | steiner_tree_zelikovsky11per6approximation (const Metric &m, const Voronoi &v, OutputIterator out) |
11/6 approximation for steiner_tree problem More... | |
template<typename Range , typename T , typename Functor , typename BinaryOperation = utils::plus> | |
T | accumulate_functor (const Range &rng, T init, Functor f, BinaryOperation bin_op=BinaryOperation{}) |
combination of boost::accumulate and boost::adaptors::transformed | |
template<typename Range , typename Functor > | |
auto | sum_functor (const Range &rng, Functor f) |
sum of functor values over the range elements | |
template<typename Range , typename Functor > | |
auto | max_element_functor (Range &&range, Functor f) |
combination of boost::max_element and boost::adaptors::transformed | |
template<typename Range , typename Functor > | |
auto | min_element_functor (Range &&range, Functor f) |
combination of boost::min_element and boost::adaptors::transformed | |
template<class Elements > | |
auto | make_subset_backtrack (const Elements &elements) |
make subset_backtrack | |
template<typename Letter > | |
void | lcp (std::vector< int > const &suffix_array, std::vector< int > const &rank, std::vector< int > &lcp, std::vector< Letter > const &sumWords) |
fill array lcp lcp[0] is undefined and lcp[i] stores the largest common prefix of the lexicographically i-1'th smallest suffix and its predecessor in the suffix array More... | |
template<typename Letter > | |
void | suffix_array (std::vector< Letter > &text, std::vector< int > &SA, Letter max_letter=0) |
detail More... | |
template<typename T > | |
void | assign_max (T &t, const T &u) |
template<typename T > | |
void | assign_min (T &t, const T &u) |
float | fast_pow2 (float p) |
fast Power of 2 More... | |
float | fast_exp (float p) |
fast power of e. More... | |
template<typename T > | |
auto | irange (T begin, T end) |
irange More... | |
template<typename T > | |
auto | irange (T end) |
irange More... | |
template<typename Value , typename Size > | |
density< Value, Size > | make_density (Value value, Size size) |
make for density More... | |
template<class Comparator > | |
less_pointees_t< Comparator > | make_less_pointees_t (Comparator compare) |
make function for less_pointees_t More... | |
template<typename Range , typename Element = range_to_elem_t<Range>> | |
auto | make_unordered_set (Range const &r) |
make for unordered_set | |
template<typename Functor > | |
void | parse (std::istream &input_stream, Functor f) |
parses stream ignoring empty lines or beginning with '#' More... | |
template<typename Functor > | |
void | parse (const std::string &filename, Functor f) |
additional version of parse function More... | |
template<typename FloatType = double, typename Probs , typename TestResults > | |
FloatType | log_loss (Probs &&probs, TestResults &&test_results) |
template<typename FloatType > | |
FloatType | likelihood_from_log_loss (FloatType log_loss) |
template<typename FloatType = double, typename Probs , typename TestResults > | |
FloatType | likelihood (Probs &&probs, TestResults &&test_results) |
template<typename FloatType = double, typename Probs , typename TestResults > | |
FloatType | mean_absolute_error (Probs &&probs, TestResults &&test_results) |
std::string | pretty_to_string (double x, double epsilon=1e-9) |
pretty_to_string prints double which is close to int as int More... | |
template<typename T > | |
std::string | pretty_to_string (T &&t) |
generic version of pretty_to_string More... | |
template<typename Stream > | |
pretty_stream< Stream > | make_pretty_stream (Stream &s, double epsilon=1e-9) |
make for pretty_stream More... | |
template<typename Range , typename Stream > | |
void | print_collection (Stream &o, Range &&r, const std::string &del) |
prints collection with delimiters without trailing delimiter More... | |
template<typename Matrix , typename Stream > | |
void | print_matrix (Stream &o, Matrix &&m, const std::string &del) |
prints matrix with delimiters More... | |
template<typename CoordinateType , typename RowType = std::vector<CoordinateType>, typename ShouldIgnoreBadRow = utils::always_true> | |
void | read_rows (std::istream &input_stream, std::vector< RowType > &rows, std::size_t row_size, std::size_t max_rows_to_read, ShouldIgnoreBadRow &&should_ignore_bad_row=ShouldIgnoreBadRow{}) |
reads up to max_rows_to_read rows of size row_size More... | |
template<typename CoordinateType , typename RowType = std::vector<CoordinateType>, typename ShouldIgnoreBadRow = utils::always_true, typename FailureMessage = utils::failure_message> | |
void | read_rows_first_row_size (std::istream &input_stream, std::vector< RowType > &rows, std::size_t max_rows_to_read, ShouldIgnoreBadRow &&should_ignore_bad_row=ShouldIgnoreBadRow{}, FailureMessage &&failure_message=FailureMessage{}) |
reads up to max_rows_to_read rows, size is determine by first row More... | |
template<typename RowType , typename ResultType = int, typename ShouldIgnoreBadRow = utils::always_false> | |
void | read_svm (std::istream &input_stream, std::size_t &max_dimensions, std::vector< std::tuple< RowType, ResultType >> &points, std::size_t max_points_to_read, ShouldIgnoreBadRow &&should_ignore_bad_row=ShouldIgnoreBadRow{}) |
detail More... | |
template<typename RowType , typename ResultType = int> | |
auto | read_svm (std::istream &input_stream) |
Function parses svm stream of format: More... | |
global namespace of project.
void paal::assign_max | ( | T & | t, |
const T & | u | ||
) |
removes boilerplate for x = max(x,y). it becomes assign_max(x, y)
Definition at line 18 of file assign_updates.hpp.
void paal::assign_min | ( | T & | t, |
const T & | u | ||
) |
removes boilerplate for x = min(x,y). it becomes assign_min(x, y)
Definition at line 25 of file assign_updates.hpp.
void paal::centroids_minimalize_w_c_s_s | ( | Clusters && | clusters, |
OutputIterator | out | ||
) |
centroid minimize within cluster sum of squares
clusters | |
out |
Clusters | |
OutputIterator |
Definition at line 49 of file k_means_clustering.hpp.
auto paal::closest_to | ( | Point && | point, |
Centers && | centers | ||
) |
point | |
centers |
Point | |
Centers |
Definition at line 53 of file k_means_clustering_engine.hpp.
auto paal::distance_square | ( | RangeLeft && | lrange, |
RangeRight && | rrange | ||
) |
lrange | |
rrange |
RangeLeft | |
RangeRight |
Definition at line 33 of file k_means_clustering_engine.hpp.
|
inline |
|
inline |
detail::FunctorOnRangePValue<ObjectSizeFunctor, Objects> paal::fill_knapsack_dynamic_table | ( | ValueIterator | valuesBegin, |
ValueIterator | valuesEnd, | ||
Objects && | objects, | ||
ObjectSizeFunctor | size, | ||
Combine | combine, | ||
Compare | compare, | ||
Init | init, | ||
GetPositionRange | get_range | ||
) |
Computes dynamic algorithm table (valuesBegin, valuesEnd) The values collection has element type ValueOrNull, The default constructed ValueOrNull should represent empty object. This collection is filled using init, compare and combine functors.
valuesBegin | begin of the table which will store the values for specific positions in dynamic algorithm computation |
valuesEnd | |
objects | - possible object collection |
size | - functor, for given opbjedt return its size |
combine | - for given Objects and value gives new object representing adding *Objects to value |
compare | - compares to values. |
init | - discover element and assign the 0 value |
get_range |
ValueIterator | has to be RandomAccess output iterator |
Objects | |
ObjectSizeFunctor | |
Combine | |
Compare | |
Init | |
GetPositionRange |
Definition at line 50 of file fill_knapsack_dynamic_table.hpp.
Metric::DistanceType paal::get_cycle_length | ( | const Metric & | m, |
const Cycle & | cm | ||
) |
computes length of the cycle
Metric | |
Cycle |
m | |
cm |
Definition at line 39 of file cycle_algo.hpp.
auto paal::get_random_centers | ( | Points && | points, |
int | number_of_centers, | ||
OutputIterator | out, | ||
RNG && | rng = std::default_random_engine{} |
||
) |
points | |
number_of_centers |
Points |
Definition at line 151 of file k_means_clustering_engine.hpp.
auto paal::get_random_clusters | ( | Points && | points, |
int | number_of_clusters, | ||
RNG && | rng = std::default_random_engine{} |
||
) |
points | |
number_of_clusters |
Points |
Definition at line 170 of file k_means_clustering_engine.hpp.
auto paal::irange | ( | T | begin, |
T | end | ||
) |
auto paal::irange | ( | T | end | ) |
auto paal::k_means | ( | Points && | points, |
Centers && | centers, | ||
OutputIterator | result, | ||
Visitor | visitor = Visitor{} |
||
) |
this is solve k_means_clustering problem and return vector of cluster example:
complete example is k_means_clustering_example.cpp
points | |
centers | |
result | pairs of point and id of cluster (number form 0,1,2 ...,number_of_cluster-1) |
visitor |
Points | |
OutputIterator | |
CoordinateType | |
Visitor |
Definition at line 85 of file k_means_clustering.hpp.
auto paal::k_means | ( | Points && | points, |
Centers & | centers, | ||
Centroid | centroid, | ||
ClosestTo | closest_to, | ||
OutputIterator | result, | ||
CentroidEqual | c_equal = CentroidEqual{} , |
||
Visitor | visitor = Visitor{} |
||
) |
points | |
centers | |
centroid | functor return centroid of set of samples |
closest_to | |
result | pairs of point and id of cluster (number from 0,1,2 ...,k-1) |
c_equal | |
visitor |
Points | |
Centers | |
Centroid | |
ClosestTo | |
OutputIterator | |
CentroidEqual | |
Visitor |
Definition at line 105 of file k_means_clustering_engine.hpp.
auto paal::knapsack_0_1 | ( | Objects && | objects, |
detail::FunctorOnRangePValue< ObjectSizeFunctor, Objects > | capacity, | ||
OutputIterator | out, | ||
ObjectSizeFunctor | size, | ||
ObjectValueFunctor | value = ObjectValueFunctor{} |
||
) |
Solution to Knapsack 0/1 problem.
Objects | |
OutputIterator | |
ObjectSizeFunctor | |
ObjectValueFunctor |
oBegin | given objects |
oEnd | |
out | the result is returned using output iterator |
size | functor that for given object returns its size |
value | functor that for given object returns its value |
Definition at line 268 of file knapsack_0_1.hpp.
auto paal::knapsack_0_1_no_output | ( | Objects && | objects, |
detail::FunctorOnRangePValue< ObjectSizeFunctor, Objects > | capacity, | ||
ObjectSizeFunctor | size, | ||
ObjectValueFunctor | value = ObjectValueFunctor{} |
||
) |
Solution to Knapsack 0/1 problem, without retrieving the objects in the solution.
Objects | |
OutputIterator | |
ObjectSizeFunctor | |
ObjectValueFunctor |
oBegin | given objects |
oEnd | |
size | functor that for given object returns its size |
value | functor that for given object returns its value |
Definition at line 295 of file knapsack_0_1.hpp.
detail::knapsack_base<Objects, ObjectSizeFunctor, ObjectValueFunctor>::return_type paal::knapsack_0_1_two_app | ( | Objects && | objects, |
typename detail::FunctorOnRangePValue< ObjectSizeFunctor, Objects > | capacity, | ||
OutputIterator | out, | ||
ObjectValueFunctor | value, | ||
ObjectSizeFunctor | size | ||
) |
detail
this version of algorithm might permute, the input range
Definition at line 83 of file knapsack_0_1_two_app.hpp.
detail::knapsack_base<Objects, ObjectSizeFunctor, ObjectValueFunctor>::return_type paal::knapsack_unbounded | ( | Objects && | objects, |
detail::FunctorOnRangePValue< ObjectSizeFunctor, Objects > | capacity, | ||
OutputIterator | out, | ||
ObjectSizeFunctor | size, | ||
ObjectValueFunctor | value = ObjectValueFunctor() |
||
) |
Solution to the knapsack problem.
Objects | |
OutputIterator | |
ObjectSizeFunctor | |
ObjectValueFunctor |
oBegin | given objects |
oEnd | |
out | the result is returned using output iterator |
size | functor that for given object returns its size |
value | functor that for given object returns its value |
Definition at line 171 of file knapsack_unbounded.hpp.
detail::knapsack_base<Objects, ObjectSizeFunctor, ObjectValueFunctor>::return_type paal::knapsack_unbounded_two_app | ( | Objects && | objects, |
typename detail::FunctorOnRangePValue< ObjectSizeFunctor, Objects > | capacity, | ||
OutputIterator | out, | ||
ObjectValueFunctor | value, | ||
ObjectSizeFunctor | size | ||
) |
detail
this version of algorithm might permute, the input range
Definition at line 71 of file knapsack_unbounded_two_app.hpp.
void paal::lcp | ( | std::vector< int > const & | suffix_array, |
std::vector< int > const & | rank, | ||
std::vector< int > & | lcp, | ||
std::vector< Letter > const & | sumWords | ||
) |
FloatType paal::likelihood | ( | Probs && | probs, |
TestResults && | test_results | ||
) |
FloatType | |
Probs | |
TestResults |
probs | |
test_results |
Definition at line 82 of file performance_measures.hpp.
FloatType paal::likelihood_from_log_loss | ( | FloatType | log_loss | ) |
FloatType |
log_loss |
Definition at line 66 of file performance_measures.hpp.
FloatType paal::log_loss | ( | Probs && | probs, |
TestResults && | test_results | ||
) |
FloatType | |
Probs | |
TestResults |
probs | |
test_results |
Definition at line 41 of file performance_measures.hpp.
density<Value, Size> paal::make_density | ( | Value | value, |
Size | size | ||
) |
make for density
Value | |
Size |
value | |
size |
Definition at line 63 of file knapsack_utils.hpp.
distance_oracle_thorup2kminus1approximation<Graph, VertexIndexMap, EdgeWeightMap, Rand> paal::make_distance_oracle_thorup2kminus1approximation | ( | const Graph & | g, |
const int | k, | ||
VertexIndexMap | index, | ||
EdgeWeightMap | edge_weight, | ||
Rand && | random_engine = Rand(5426u) |
||
) |
Graph | |
EdgeWeightMap | |
VertexIndexMap | |
Rand |
g | - given graph |
k | - approximation parameter |
index | - graph index map |
edge_weight | - graph edge weight map |
random_engine | - random engine |
Definition at line 484 of file thorup_2kminus1.hpp.
auto paal::make_distance_oracle_thorup2kminus1approximation | ( | const Graph & | g, |
const int | k, | ||
const boost::bgl_named_params< P, T, R > & | params = boost::no_named_parameters() , |
||
Rand && | random_engine = Rand(5426u) |
||
) | -> distance_oracle_thorup2kminus1approximation<Graph, decltype(choose_const_pmap(get_param(params, boost::vertex_index), g, boost::vertex_index)), decltype(choose_const_pmap(get_param(params, boost::edge_weight), g, boost::edge_weight)), Rand> |
Graph | |
P | |
T | |
R | |
Rand |
g | - given graph |
k | - approximation parameter |
params | - named parameters |
random_engine | - random engine |
Definition at line 518 of file thorup_2kminus1.hpp.
dreyfus_wagner<Metric, Terminals, NonTerminals, TerminalsLimit> paal::make_dreyfus_wagner | ( | const Metric & | metric, |
const Terminals & | terminals, | ||
const NonTerminals & | non_terminals | ||
) |
Creates a dreyfus_wagner object.
TerminalsLimit | |
Metric | |
Terminals | |
NonTerminals |
Definition at line 309 of file dreyfus_wagner.hpp.
auto paal::make_hash_function_tuple_generator | ( | FunctionGenerator && | function_generator, |
unsigned | hash_functions_per_point | ||
) |
FunctionGenerator |
function_generator | functor generating hash functions |
hash_functions_per_point | number of hash functions in single tuple |
Definition at line 156 of file lsh_nearest_neighbors_regression.hpp.
less_pointees_t<Comparator> paal::make_less_pointees_t | ( | Comparator | compare | ) |
make function for less_pointees_t
Comparator |
compare |
Definition at line 48 of file less_pointees.hpp.
auto paal::make_lsh_nearest_neighbors_regression | ( | TrainingPoints && | training_points, |
TrainingResults && | training_results, | ||
unsigned | passes, | ||
LshFunctionGenerator && | lsh_function_generator, | ||
unsigned | threads_count = std::thread::hardware_concurrency() |
||
) |
this is the most general version of the make_lsh_nearest_neighbors_regression, It takes any hash function generator.
TrainingPoints | |
TrainingResults | |
LshFunctionGenerator |
training_points | |
training_results | |
passes | number of used LSH functions |
lsh_function_generator | functor generating proper LSH functions |
threads_count |
Definition at line 359 of file lsh_nearest_neighbors_regression.hpp.
auto paal::make_lsh_nearest_neighbors_regression_tuple_hash | ( | TrainingPoints && | training_points, |
TrainingResults && | training_results, | ||
unsigned | passes, | ||
FunctionGenerator && | function_generator, | ||
unsigned | hash_functions_per_point, | ||
unsigned | threads_count = std::thread::hardware_concurrency() |
||
) |
This is the special version of make_lsh_nearest_neighbors_regression. This version assumes that hash function is concatenation (tuple) of several hash functions. In this function user provide Function generator for the inner functions only.
TrainingPoints | |
TrainingResults | |
FunctionGenerator |
training_points | |
training_results | |
passes | |
function_generator | |
hash_functions_per_point | |
threads_count |
Definition at line 399 of file lsh_nearest_neighbors_regression.hpp.
pretty_stream<Stream> paal::make_pretty_stream | ( | Stream & | s, |
double | epsilon = 1e-9 |
||
) |
make for pretty_stream
Stream |
s | |
epsilon |
Definition at line 134 of file pretty_stream.hpp.
FloatType paal::mean_absolute_error | ( | Probs && | probs, |
TestResults && | test_results | ||
) |
FloatType | |
Probs | |
TestResults |
probs | |
test_results |
Definition at line 99 of file performance_measures.hpp.
auto paal::multiway_cut | ( | const Graph & | g, |
OutputIterator | out, | ||
const boost::bgl_named_params< P, T, R > & | params, | ||
Rand && | random_engine = std::default_random_engine(5426u) |
||
) | -> typename boost::property_traits<puretype( boost::choose_const_pmap(get_param(params, boost::edge_weight), g, boost::edge_weight))>::value_type |
detail
this is solve multiway_cut problem and return cut_cost example:
Graph | graph |
OutputIterator | result pairs of vertex descriptor and number form (1,2, ... ,k) id of part |
random_engine | |
params |
Graph | |
OutputIterator | |
Rand | random engine |
Distribution | used to chose random radius |
LP | |
P | |
T | |
R |
Definition at line 254 of file multiway_cut.hpp.
auto paal::multiway_cut | ( | const Graph & | graph, |
OutputIterator | result, | ||
Rand | random_engine = std::default_random_engine(5426u) |
||
) | -> detail::CostType<Graph> |
this is solve multiway_cut problem and return cut_cost example:
example file is multiway_cut_example.cpp
Graph | graph |
int | repeats number of sets of radius |
OutputIterator | result pairs of vertex descriptor and number form (1,2, ... ,k) id of part |
Rand | random engine |
Distribution | used to chose random radius |
LP | |
Graph | |
OutputIterator |
Definition at line 290 of file multiway_cut.hpp.
void paal::parse | ( | std::istream & | input_stream, |
Functor | f | ||
) |
parses stream ignoring empty lines or beginning with '#'
Functor |
input_stream | |
f | functor called on each line with params: first token of line and stream after reading that token |
Definition at line 33 of file parse_file.hpp.
void paal::parse | ( | const std::string & | filename, |
Functor | f | ||
) |
additional version of parse function
Functor |
filename | |
f |
Definition at line 56 of file parse_file.hpp.
|
inline |
pretty_to_string prints double which is close to int as int
x | |
epsilon |
Definition at line 32 of file pretty_stream.hpp.
std::string paal::pretty_to_string | ( | T && | t | ) |
generic version of pretty_to_string
T |
t |
Definition at line 51 of file pretty_stream.hpp.
void paal::print_collection | ( | Stream & | o, |
Range && | r, | ||
const std::string & | del | ||
) |
prints collection with delimiters without trailing delimiter
Range | |
Stream |
o | |
r | |
del |
Definition at line 34 of file print_collection.hpp.
void paal::print_matrix | ( | Stream & | o, |
Matrix && | m, | ||
const std::string & | del | ||
) |
prints matrix with delimiters
Matrix | |
Stream |
o | |
m | |
del |
Definition at line 56 of file print_collection.hpp.
RestrictionsVector paal::prune_restrictions_to_tree | ( | Restrictions | res, |
int | N | ||
) |
Returns a list of restrictions, made of the edges of a maximum spanning tree in a clique with edge weights equal to restriction values between the edges.
Restrictions |
res | restrictions |
N | number of vertices |
Definition at line 41 of file prune_restrictions_to_tree.hpp.
void paal::read_rows | ( | std::istream & | input_stream, |
std::vector< RowType > & | rows, | ||
std::size_t | row_size, | ||
std::size_t | max_rows_to_read, | ||
ShouldIgnoreBadRow && | should_ignore_bad_row = ShouldIgnoreBadRow{} |
||
) |
reads up to max_rows_to_read rows of size row_size
RowType | |
ShouldIgnoreBadRow |
input_stream | |
rows | |
row_size | |
max_rows_to_read | |
should_ignore_bad_row |
Definition at line 48 of file read_rows.hpp.
void paal::read_rows_first_row_size | ( | std::istream & | input_stream, |
std::vector< RowType > & | rows, | ||
std::size_t | max_rows_to_read, | ||
ShouldIgnoreBadRow && | should_ignore_bad_row = ShouldIgnoreBadRow{} , |
||
FailureMessage && | failure_message = FailureMessage{} |
||
) |
reads up to max_rows_to_read rows, size is determine by first row
CoordinateType | |
RowType | |
ShouldIgnoreBadRow | |
FailureMessage |
input_stream | |
rows | |
max_rows_to_read | |
should_ignore_bad_row | |
failure_message |
Definition at line 87 of file read_rows.hpp.
void paal::read_svm | ( | std::istream & | input_stream, |
std::size_t & | max_dimensions, | ||
std::vector< std::tuple< RowType, ResultType >> & | points, | ||
std::size_t | max_points_to_read, | ||
ShouldIgnoreBadRow && | should_ignore_bad_row = ShouldIgnoreBadRow{} |
||
) |
detail
reads up to max_points_to_read svm rows, updating max_dimensions on each row
RowType | |
ResultType | |
ShouldIgnoreBadRow |
input_stream | |
max_dimensions | |
points | |
max_points_to_read | |
should_ignore_bad_row |
Definition at line 206 of file read_svm.hpp.
auto paal::read_svm | ( | std::istream & | input_stream | ) |
Function parses svm stream of format:
RowType | |
ResultType |
input_stream |
Definition at line 238 of file read_svm.hpp.
auto paal::steiner_tree_greedy | ( | const Graph & | g, |
OutputIterator | out, | ||
EdgeWeightMap | edge_weight, | ||
ColorMap | color_map | ||
) | -> typename std::pair< typename boost::property_traits<EdgeWeightMap>::value_type, typename boost::property_traits<EdgeWeightMap>::value_type> |
non-named version of steiner_tree_greedy
Graph | |
OutputIterator | |
EdgeWeightMap | |
ColorMap |
g | - given graph |
out | - edge output iterator |
edge_weight | |
color_map |
Definition at line 97 of file steiner_tree_greedy.hpp.
auto paal::steiner_tree_greedy | ( | const Graph & | g, |
OutputIterator | out, | ||
const boost::bgl_named_params< P, T, R > & | params | ||
) |
named version of steiner_tree_greedy
Graph | |
OutputIterator | |
P | |
T | |
R |
g | - given graph |
out | - edge output iterator |
params |
Definition at line 213 of file steiner_tree_greedy.hpp.
auto paal::steiner_tree_greedy | ( | const Graph & | g, |
OutputIterator | out | ||
) |
version of steiner_tree_greedy with all default parameters
Graph | |
OutputIterator |
g | - given graph |
out | - edge output iterator |
Definition at line 231 of file steiner_tree_greedy.hpp.
void paal::steiner_tree_zelikovsky11per6approximation | ( | const Metric & | m, |
const Voronoi & | v, | ||
OutputIterator | out | ||
) |
11/6 approximation for steiner_tree problem
Metric | |
Voronoi | |
OutputIterator |
m | |
v | |
out |
Definition at line 360 of file zelikovsky_11_per_6.hpp.
void paal::suffix_array | ( | std::vector< Letter > & | text, |
std::vector< int > & | SA, | ||
Letter | max_letter = 0 |
||
) |
detail
require text.size()>=2 fill suffix_array suffix_array[i] contains the starting position of the i-1'th smallest suffix in Word
Letter |
text | - text |
SA | place for suffix_array |
max_letter | optional parameter max_letter in alphabet |
Definition at line 227 of file suffix_array.hpp.