Docs
Loading...
Searching...
No Matches
spatial_module_cache.hpp
Go to the documentation of this file.
1
5
6#pragma once
7
11
23class SpatialModuleCache : public Module {
24protected:
26 const double spatial_weight = 1.0;
27
29
30public:
44 SpatialModuleCache(const Data &data_, SpatialCache &spatial_cache_, double spatial_coeff,
45 const Eigen::VectorXi *old_alloc_provider = nullptr,
46 const std::unordered_map<int, std::vector<int>> *old_cluster_members_provider_ = nullptr)
47 : data_module(data_), cache(spatial_cache_), spatial_weight(spatial_coeff),
48 Module(old_alloc_provider, old_cluster_members_provider_) {
49 cache.set_allocation_ptr(&data_module.get_allocations());
50 }
51
56
66 Eigen::VectorXd compute_similarity_obs(int obs_idx) const override;
67
81 double compute_similarity_cls(int cls_idx, bool old_allo = false) const override;
82
94 double compute_similarity_obs(int obs_idx, int cls_idx) const override;
96};
Data structure for managing point distances and cluster allocations.
Base class for modules used in processes.
Manages distance matrices and cluster allocations for points.
Definition Data.hpp:27
Module(const Eigen::VectorXi *old_allocations_provider_=nullptr, const std::unordered_map< int, std::vector< int > > *old_cluster_members_provider_=nullptr)
Definition Module.hpp:31
Cache for spatial model with spatial covariates.
Definition spatial_cache.hpp:18
double compute_similarity_cls(int cls_idx, bool old_allo=false) const override
Counts internal edges within a cluster.
Definition spatial_module_cache.cpp:23
const double spatial_weight
Weighting factor for spatial similarity.
Definition spatial_module_cache.hpp:26
SpatialModuleCache(const Data &data_, SpatialCache &spatial_cache_, double spatial_coeff, const Eigen::VectorXi *old_alloc_provider=nullptr, const std::unordered_map< int, std::vector< int > > *old_cluster_members_provider_=nullptr)
Constructs a SpatialModuleCache with parameter and data references.
Definition spatial_module_cache.hpp:44
const Data & data_module
Reference to data object with cluster assignments.
Definition spatial_module_cache.hpp:25
Eigen::VectorXd compute_similarity_obs(int obs_idx) const override
Counts neighbors of an observation grouped by cluster membership.
Definition spatial_module_cache.cpp:45
SpatialCache & cache
Spatial cache for additional optimizations.
Definition spatial_module_cache.hpp:28
Cache for spatial model with spatial covariates.