10#include <unordered_map>
14#ifndef VERBOSITY_LEVEL
15#define VERBOSITY_LEVEL 0
59 const Eigen::VectorXi &initial_allocations = Eigen::VectorXi());
72 double get_data(
int i,
int j = 0)
const;
104 if (cluster_index >=
static_cast<unsigned>(
K)) {
109 return (it !=
cluster_members.end()) ?
static_cast<int>(it->second.size())
120 if (index < 0 || index >=
p.n) {
121 throw std::out_of_range(
"Index out of bounds in get_cluster_assignment");
140 Eigen::Map<const Eigen::VectorXi>
185 std::unordered_map<
int, std::vector<int>> &old_cluster_members,
virtual void set_allocation(int index, int cluster)
Setters.
Definition Data.cpp:200
int get_cluster_assignment(int index) const
Gets the cluster assignment of a specific point.
Definition Data.hpp:119
const std::unordered_map< int, std::vector< int > > & get_cluster_map() const
Gets the full mapping of clusters to their member points.
Definition Data.hpp:192
void compact_cluster(int old_cluster)
Removes an empty cluster and compacts cluster indices.
Definition Data.cpp:90
double get_data(int i, int j=0) const
Getters.
Definition Data.cpp:34
int get_n() const
Gets the total number of points.
Definition Data.hpp:78
int get_cluster_size(unsigned cluster_index) const
Gets the size of a specific cluster.
Definition Data.hpp:103
std::unordered_map< int, std::vector< int > > get_cluster_map_copy() const
Gets the full mapping of clusters to their member points.
Definition Data.hpp:147
int get_p() const
Gets the number of columns in the data.
Definition Data.hpp:90
void set_allocation_wo_compaction(int index, int cluster)
Assigns a point to a cluster without compaction.
Definition Data.cpp:129
std::unordered_map< int, std::vector< int > > cluster_members
Maps cluster indices to vectors of point indices in that cluster.
Definition Data.hpp:34
const Eigen::VectorXi & get_allocations() const
Gets the cluster allocations vector.
Definition Data.hpp:96
virtual void restore_state(Eigen::VectorXi &old_allocations, std::unordered_map< int, std::vector< int > > &old_cluster_members, int old_K)
Restores allocations, cluster memberships, and cluster count from a saved state.
Definition Data.cpp:231
Eigen::VectorXi allocations
Cluster allocation for each point.
Definition Data.hpp:30
Data(const utils_params &p, const Eigen::VectorXi &initial_allocations=Eigen::VectorXi())
Constructs a Data object with a distance matrix.
Definition Data.cpp:10
Eigen::Map< const Eigen::VectorXi > get_cluster_assignments_ref(int cluster) const
Gets all point indices assigned to a specific cluster (map form).
Definition Data.cpp:67
virtual void set_allocations(const Eigen::VectorXi &new_allocations)
Sets all cluster allocations at once.
Definition Data.cpp:212
int get_K() const
Gets the current number of clusters.
Definition Data.hpp:84
int K
Current number of clusters.
Definition Data.hpp:31
Eigen::VectorXi get_cluster_assignments(int cluster) const
Gets all point indices assigned to a specific cluster.
Definition Data.cpp:44
const utils_params & p
Reference to model parameters.
Definition Data.hpp:28
Parameter struct for utility parameters and data structures.
Definition utils-params.hpp:17
Parameter management for useful parameters and data structures.