Commit 9273a47d authored by Damien Leroux's avatar Damien Leroux
Browse files

Fixed some race conditions and tasking stuff. Fixed constraints (further testing needed).

parent b64128cd
This diff is collapsed.
......@@ -127,7 +127,7 @@ template <typename Ret, typename... Args>
*/
auto ret = func(*args...);
// active_settings->thread_stacks[this_id].pop_back();
msg_handler_t::run_hooks();
// msg_handler_t::run_hooks();
unregister_task_in_progress(func, {*args}...);
TaskPool::release_slot();
// TaskPool::remove_task(m_thread->get_id());
......
......@@ -1034,7 +1034,7 @@ struct search_lg_type {
local_selections,
all_positions,
active_loci);
MSG_DEBUG("Computing dominance probabilities");
// MSG_DEBUG("Computing dominance probabilities");
dominance_blocks
= compute_dominance_multipop(
all_pops,
......@@ -1236,9 +1236,9 @@ struct search_lg_type {
MSG_DEBUG((*last_computation));
MSG_QUEUE_FLUSH();
*/
MSG_DEBUG("LOCUS BLOCK");
MSG_DEBUG("" << locus_blocks[i_max]);
MSG_QUEUE_FLUSH();
// MSG_DEBUG("LOCUS BLOCK");
// MSG_DEBUG("" << locus_blocks[i_max]);
// MSG_QUEUE_FLUSH();
return {
this, chrom,
......@@ -2380,13 +2380,13 @@ void analysis_report::report_final_model(model_manager& mm)
/* FIXME use actual full Y instead of un-projecting the traits? */
MatrixXd all_residuals = mm.vMcurrent->residuals() * Pt;
VectorXd all_rss = all_residuals.array().square().colwise().sum();
MSG_DEBUG(MATRIX_SIZE(mm.vMcurrent->rss().transpose()));
MSG_DEBUG(MATRIX_SIZE(Pt));
// MSG_DEBUG(MATRIX_SIZE(mm.vMcurrent->rss().transpose()));
// MSG_DEBUG(MATRIX_SIZE(Pt));
MSG_QUEUE_FLUSH();
VectorXd pseudo_variances = (mm.vMcurrent->rss().transpose() * Pt.array().square().matrix()).transpose() / (mm.vMcurrent->n_obs() - mm.vMcurrent->dof() - 1);
MSG_DEBUG("Pseudo variances " << pseudo_variances.transpose());
// MSG_DEBUG("Pseudo variances " << pseudo_variances.transpose());
// VectorXd empiric_residual_variance = all_rss / (mm.vMcurrent->n_obs() - mm.vMcurrent->dof() - 1);
MSG_DEBUG(__FILE__ << ':' << __LINE__ << " keys " << mm.vMcurrent->keys());
// MSG_DEBUG(__FILE__ << ':' << __LINE__ << " keys " << mm.vMcurrent->keys());
for (int i = 0; i < (int) TM.dim_names.size(); ++i) {
// auto it_single = std::find(active_settings->with_traits.begin(), active_settings->with_traits.end(), mm.trait_name);
if (TM.dim_names.size() > 1) {
......
......@@ -202,14 +202,14 @@ init_connected_block_builder(
index.insert({l, sz});
}
#if 0
MSG_DEBUG("index size " << index.size());
// MSG_DEBUG("index size " << index.size());
std::stringstream s;
s << '{';
for (auto& kv: index) {
s << " (" << kv.first << ')';
}
s << " }";
MSG_DEBUG("index: " << s.str());
// MSG_DEBUG("index: " << s.str());
#endif
ret.n_rows = 0;
......@@ -553,10 +553,10 @@ compute_along_interval(int i0, computation_along_chromosome& ret,
}
for (auto& k: joiner) {
DUMP_FILE_LINE();
// DUMP_FILE_LINE();
(void) *k; /* join them all */
MSG_DEBUG("Block" << std::endl << (*k));
MSG_QUEUE_FLUSH();
// MSG_DEBUG("Block" << std::endl << (*k));
// MSG_QUEUE_FLUSH();
}
}
......
......@@ -92,8 +92,7 @@ struct locus_key_struc {
bool has(double loc) const
{
return loc == locus
|| (parent && parent->has(loc));
return !!this && (loc == locus || (parent && parent->has(loc)));
}
void _fill_vec(std::vector<double>& vec) const
......
......@@ -976,10 +976,12 @@ struct model {
/*} else if (mbk.selection.size() == 1) {*/
} else if (mbk->type == mbk_POP) {
size_t n_qtl = mb.column_labels.front().size();
if (n_qtl == 1) {
// if (n_qtl == 1) {
if (1) {
/* only one chromosome: do the contrast groups trick */
ret = {{{mbk, contrast_groups(m_all_pops, mbk->loci)}}};
} else {
MSG_DEBUG("Creating constraints for " << mbk);
std::vector<std::set<char>> uniq_letters_per_qtl(mb.column_labels.front().size());
/* need the epistasis magic here */
for (const auto& vec: mb.column_labels) {
......@@ -996,15 +998,15 @@ struct model {
bool flat = (variant >> i) & 1;
MatrixXd tmp;
if (flat) {
tmp = kroneckerProduct(constraint, MatrixXd::Identity(letter_counts[i], letter_counts[i]));
tmp = kroneckerProduct(constraint, MatrixXd::Ones(1, letter_counts[i]));
} else {
tmp = kroneckerProduct(constraint, MatrixXd::Identity(letter_counts[i], letter_counts[i]));
}
constraint = tmp;
}
ret.emplace_back();
/*MSG_DEBUG("Created constraint");*/
/*MSG_DEBUG("" << constraint);*/
MSG_DEBUG("Created constraint for " << mbk);
MSG_DEBUG(constraint);
ret.back().insert({{mbk, constraint}});
}
}
......@@ -1253,7 +1255,7 @@ struct model {
void compute()
{
// MSG_DEBUG("Recomputing model with selection " << keys());
MSG_DEBUG('[' << std::this_thread::get_id() << "] Recomputing model with selection " << keys());
if (m_computed) {
return;
}
......@@ -1270,7 +1272,7 @@ struct model {
}
}
}
// MSG_DEBUG("Filtered selection " << keys());
MSG_DEBUG('[' << std::this_thread::get_id() << "] Filtered selection " << keys());
m_computed = true;
m_X = new immediate_value<MatrixXd>(MatrixXd());
......@@ -1303,8 +1305,6 @@ struct model {
}
/**m_X = MatrixXd(n_rows, n_cols);*/
*m_X = MatrixXd::Zero(n_rows, n_cols);
// MSG_DEBUG("n_rows=" << n_rows << " n_cols=" << n_cols);
/*MSG_DEBUG("DEBUG X" << std::endl << (*m_X));*/
/* now fill the matrix */
n_rows = 0;
n_cols = 0;
......@@ -1316,15 +1316,27 @@ struct model {
n_cols += mb.outerSize();
}
n_rows = n_pop_rows;
MSG_DEBUG("n_rows=" << n_rows << " n_cols=" << n_cols);
// MSG_DEBUG("DEBUG X" << std::endl << (*m_X));
{
/*os << "<model Y(" << m.m_Y->innerSize() << ',' << m.m_Y->outerSize() << "), " << m.m_blocks.size() << " blocks>";*/
MatrixXd big = MatrixXd::Zero(1, X().cols());
model_print::matrix_with_sections<std::string, void, std::string, std::vector<char>> mws(big);
/*model_print::matrix_with_sections<std::string, void, model_block_key, void> mws(m.X());*/
set_column_sections(mws);
MSG_DEBUG("DEBUG X" << std::endl << mws);
}
for (const auto& cmap: constraints) {
n_cols = 0;
size_t row_incr = 0;
// MSG_DEBUG("row=" << n_rows << " col=" << n_cols);
MSG_QUEUE_FLUSH();
// MSG_QUEUE_FLUSH();
for (const auto& b: m_blocks) {
auto it = cmap.find(b.first);
if (it != cmap.end()) {
const MatrixXd& constraint = it->second;
MSG_DEBUG('[' << std::this_thread::get_id() << "] Adding (" << constraint.innerSize() << ',' << constraint.outerSize() << ") constraint at " << n_rows << "," << n_cols << " within (" << m_X->rows() << ',' << m_X->cols() << ')');
MSG_DEBUG(constraint);
if (constraint.size()) {
m_X->block(n_rows, n_cols, constraint.innerSize(), constraint.outerSize()) = constraint;
row_incr = constraint.innerSize();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment