diff --git a/fastlib/trunk/contrib/dongryel/thesis_research/core/parallel/table_exchange.h b/fastlib/trunk/contrib/dongryel/thesis_research/core/parallel/table_exchange.h index 28bda29063..02f2a7427c 100644 --- a/fastlib/trunk/contrib/dongryel/thesis_research/core/parallel/table_exchange.h +++ b/fastlib/trunk/contrib/dongryel/thesis_research/core/parallel/table_exchange.h @@ -9,14 +9,41 @@ #define CORE_PARALLEL_TABLE_EXCHANGE_H #include +#include "core/table/memory_mapped_file.h" +#include "core/table/dense_matrix.h" + +namespace core { +namespace table { +extern core::table::MemoryMappedFile *global_m_file_; +}; +}; namespace core { namespace parallel { class TableExchange { + private: + std::vector< core::table::DenseMatrix > point_cache_; + public: + template + void Init( + boost::mpi::communicator &world, + const DistributedTableType &distributed_table) { + + // Preallocate the point cache. + point_cache_.resize(world.size()); + for(int i = 0; i < world.size(); i++) { + if(i != world.rank()) { + point_cache_[i].Init( + distributed_table.n_attributes(), + distributed_table.local_n_entries(i)); + } + } + } + template - static void AllToAll( + void AllToAll( boost::mpi::communicator &world, int max_num_levels_to_serialize, TableType &local_table, @@ -47,7 +74,8 @@ class TableExchange { received_subtables->resize(world.size()); for(unsigned int j = 0; j < receive_requests.size(); j++) { for(unsigned int i = 0; i < receive_requests[j].size(); i++) { - (*received_subtables)[j].push_back(j, max_num_levels_to_serialize); + (*received_subtables)[j].push_back( + j, point_cache_[j], max_num_levels_to_serialize); } } boost::mpi::all_to_all(world, send_subtables, *received_subtables); diff --git a/fastlib/trunk/contrib/dongryel/thesis_research/core/table/sub_table.h b/fastlib/trunk/contrib/dongryel/thesis_research/core/table/sub_table.h index ca6d84713b..018a35f1a8 100644 --- a/fastlib/trunk/contrib/dongryel/thesis_research/core/table/sub_table.h +++ b/fastlib/trunk/contrib/dongryel/thesis_research/core/table/sub_table.h @@ -244,10 +244,14 @@ class SubTable { return tree_; } - void Init(int rank_in, int max_num_levels_to_serialize_in) { + void Init( + int rank_in, core::table::DenseMatrix &data_alias_in, + int max_num_levels_to_serialize_in) { table_ = (core::table::global_m_file_) ? core::table::global_m_file_->Construct() : new TableType(); + table_->data().Alias( + data_alias_in.ptr(), data_alias_in.n_rows(), data_alias_in.n_cols()); is_alias_ = false; table_->set_rank(rank_in); this->Init(table_, (TreeType *) NULL, max_num_levels_to_serialize_in); diff --git a/fastlib/trunk/contrib/dongryel/thesis_research/core/table/sub_table_list.h b/fastlib/trunk/contrib/dongryel/thesis_research/core/table/sub_table_list.h index 298909deaf..0bd631430e 100644 --- a/fastlib/trunk/contrib/dongryel/thesis_research/core/table/sub_table_list.h +++ b/fastlib/trunk/contrib/dongryel/thesis_research/core/table/sub_table_list.h @@ -35,9 +35,12 @@ class SubTableList { } } - void push_back(int rank_in, int max_num_levels_to_serialize_in) { + void push_back( + int rank_in, core::table::DenseMatrix &data_alias_in, + int max_num_levels_to_serialize_in) { list_.resize(list_.size() + 1); - list_[list_.size() - 1].Init(rank_in, max_num_levels_to_serialize_in); + list_[list_.size() - 1].Init( + rank_in, data_alias_in, max_num_levels_to_serialize_in); } template diff --git a/fastlib/trunk/contrib/dongryel/thesis_research/core/tree/tree.test.cc b/fastlib/trunk/contrib/dongryel/thesis_research/core/tree/tree.test.cc index f27225ba10..42d51862bb 100644 --- a/fastlib/trunk/contrib/dongryel/thesis_research/core/tree/tree.test.cc +++ b/fastlib/trunk/contrib/dongryel/thesis_research/core/tree/tree.test.cc @@ -43,10 +43,8 @@ class TestTree { while(node_it.HasNext()); if(node->is_leaf() == false) { - return TestTreeIterator_( - table.get_node_left_child(node), table) && - TestTreeIterator_( - table.get_node_right_child(node), table); + return TestTreeIterator_(node->left(), table) && + TestTreeIterator_(node->right(), table); } return true; } diff --git a/fastlib/trunk/contrib/dongryel/thesis_research/mlpack/mixed_logit_dcm/mixed_logit_dcm.h b/fastlib/trunk/contrib/dongryel/thesis_research/mlpack/mixed_logit_dcm/mixed_logit_dcm.h index 03716ce81f..778f0ac803 100644 --- a/fastlib/trunk/contrib/dongryel/thesis_research/mlpack/mixed_logit_dcm/mixed_logit_dcm.h +++ b/fastlib/trunk/contrib/dongryel/thesis_research/mlpack/mixed_logit_dcm/mixed_logit_dcm.h @@ -26,12 +26,18 @@ class MixedLogitDCM { private: - /** @brief Computes the sample data error (Section 3.1) + /** @brief Computes the sample data error (Section 3.1). */ double SampleDataError_( const SamplingType &first_sample, const SamplingType &second_sample) const; + /** @brief Computes the simulation error (Section 3.2). + */ + double SimulationError_( + const SamplingType &first_sample, + const SamplingType &second_sample) const; + public: TableType *attribute_table(); diff --git a/fastlib/trunk/contrib/dongryel/thesis_research/mlpack/mixed_logit_dcm/mixed_logit_dcm_dev.h b/fastlib/trunk/contrib/dongryel/thesis_research/mlpack/mixed_logit_dcm/mixed_logit_dcm_dev.h index a060908614..1d47d68e25 100644 --- a/fastlib/trunk/contrib/dongryel/thesis_research/mlpack/mixed_logit_dcm/mixed_logit_dcm_dev.h +++ b/fastlib/trunk/contrib/dongryel/thesis_research/mlpack/mixed_logit_dcm/mixed_logit_dcm_dev.h @@ -12,6 +12,13 @@ namespace mlpack { namespace mixed_logit_dcm { +template +double MixedLogitDCM::SimulationError_( + const SamplingType &first_sample, + const SamplingType &second_sample) const { + +} + template double MixedLogitDCM::SampleDataError_( const SamplingType &first_sample,