Exemplo n.º 1
0
    void sample(int iterations, int burn, int adapt, int thin) {
      double logp_value,old_logp_value;

      // tuning phase
      tune(adapt,static_cast<int>(adapt/100));

      logp_value  = -std::numeric_limits<double>::infinity();
      old_logp_value = -std::numeric_limits<double>::infinity();
      for(int i = 1; i <= (iterations + burn); i++) {
        old_logp_value = logp_value;
        preserve_all(mcmcObjects);
        jump_all(jumping_stochastics);
        update();
        logp_value = logp();
        if(reject(logp_value, old_logp_value)) {
          revert_all(mcmcObjects);
          logp_value = old_logp_value;
          rejected_ += 1;
        } else {
          accepted_ += 1;
        }
        if(i > burn && (i % thin == 0)) {
          tally_all(mcmcObjects);
        }
      }
    }
bool db_tab_widget::set_model(db_relational_model *model)
{
  // Init the model
  pv_table_model = model;
  pv_table_model->set_user_headers();
  //pv_table_model->setEditStrategy(QSqlTableModel::OnManualSubmit);
  lb_user_table_name->setText(pv_table_model->get_user_table_name());

  // Init the view
  pv_tab_view = new db_tab_view(this);
  pv_tab_view->setModel(pv_table_model);
  //pv_tab_view->display_nav();
  if(pv_table_model->editStrategy() == QSqlTableModel::OnManualSubmit){
    pv_tab_view->set_auto_submit(false);
    std::cout << "****  Auto submit OFF, edit strategy: " << pv_table_model->editStrategy() << std::endl;
  }else{
    pv_tab_view->set_auto_submit(true);
    std::cout << "****  Auto submit ON, edit strategy: " << pv_table_model->editStrategy() << std::endl;
  }

  pv_layout->addWidget(pv_tab_view);

  // Signal from tab_view whenn selected
  connect( pv_tab_view,
    SIGNAL(current_row_changed(int)),
    this, SLOT(current_row_changed(int)) );

  connect( this,
    SIGNAL(sig_current_row_changed(const QModelIndex&)),
    pv_table_model, SLOT(current_row_changed(const QModelIndex&)) );

  //connect( 
/*
  connect(myTableView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
         mapper, SLOT(setCurrentModelIndex(QModelIndex)));
*/
/*
  connect(
    pv_table_model, SIGNAL(beforeInsert(QSqlRecord&)),
    this, SLOT(as_child_before_insert(QSqlRecord&) )
  );
*/
  connect( pv_tab_view, SIGNAL(sig_delete_row(int)), this, SLOT(delete_record(int)));
  connect( pv_tab_view, SIGNAL(sig_insert_row()), this, SLOT(insert_record()));
  connect( pv_tab_view, SIGNAL(sig_submit(int)), this, SLOT(submit_all(int)));
  connect( pv_tab_view, SIGNAL(sig_revert()), this, SLOT(revert_all()));

  pv_table_model->setSort(0, Qt::AscendingOrder);
  select();

  return true;
}