コード例 #1
0
ParticleIndexes DummyPairContainer::get_all_possible_indexes() const {
  ParticleIndexes ret = c_->get_all_possible_indexes();
  ModelObjectsTemp mos =
      cpf_->get_inputs(get_model(), c_->get_indexes());
  for (unsigned int i = 0; i < mos.size(); ++i) {
    ModelObject *o = mos[i];
    Particle *p = dynamic_cast<Particle *>(o);
    if (p) ret.push_back(p->get_index());
  }
  return ret;
}
コード例 #2
0
ファイル: ModelObject.cpp プロジェクト: j-ma-bu-l-l-ock/imp
void ModelObject::validate_outputs() const {
  if (!get_has_dependencies()) return;
  IMP_IF_CHECK(USAGE_AND_INTERNAL) {
    IMP_CHECK_OBJECT(this);
    ModelObjectsTemp ret = do_get_outputs();
    std::sort(ret.begin(), ret.end());
    ret.erase(std::unique(ret.begin(), ret.end()), ret.end());
    ModelObjectsTemp saved = get_model()->get_dependency_graph_outputs(this);
    std::sort(saved.begin(), saved.end());
    ModelObjectsTemp intersection;
    std::set_intersection(saved.begin(), saved.end(), ret.begin(), ret.end(),
                          std::back_inserter(intersection));
    IMP_USAGE_CHECK(
        intersection.size() == ret.size(),
        "Dependencies changed without invalidating dependencies."
            << " Make sure you call set_has_dependencies(false) any "
            << "time the list of dependencies changed. Object is " << get_name()
            << " of type " << get_type_name());
  }
}
コード例 #3
0
ファイル: MonteCarlo.cpp プロジェクト: AljGaber/imp
ParticleIndexes MonteCarlo::get_movable_particles() const {
    ParticleIndexes movable;
    for (unsigned int i = 0; i < get_number_of_movers(); ++i) {
        ModelObjectsTemp t = get_mover(i)->get_outputs();
        for (unsigned int j = 0; j < t.size(); ++j) {
            ModelObject *mo = t[j];
            if (dynamic_cast<Particle *>(mo)) {
                movable.push_back(dynamic_cast<Particle *>(mo)->get_index());
            }
        }
    }
    return movable;
}
コード例 #4
0
ファイル: ModelObject.cpp プロジェクト: j-ma-bu-l-l-ock/imp
ContainersTemp get_output_containers(const ModelObjectsTemp &mo) {
  ContainersTemp ret;
  for (unsigned int i = 0; i < mo.size(); ++i) {
    ModelObject *o = mo[i];
    Container *p = dynamic_cast<Container *>(o);
    if (p)
      ret.push_back(p);
    else {
      ret += get_output_containers(o->get_inputs());
    }
  }
  return ret;
}
コード例 #5
0
ファイル: ModelObject.cpp プロジェクト: j-ma-bu-l-l-ock/imp
ParticlesTemp get_output_particles(const ModelObjectsTemp &mo) {
  ParticlesTemp ret;
  for (unsigned int i = 0; i < mo.size(); ++i) {
    ModelObject *o = mo[i];
    Particle *p = dynamic_cast<Particle *>(o);
    if (p)
      ret.push_back(p);
    else {
      ret += get_output_particles(o->get_inputs());
    }
  }
  return ret;
}
コード例 #6
0
ScoreStatesTemp get_required_score_states(const ModelObjectsTemp &mos,
                                          ScoreStatesTemp exclude) {
  if (mos.empty()) return ScoreStatesTemp();
  ScoreStatesTemp ret;
  for (unsigned int i = 0; i < mos.size(); ++i) {
    mos[0]->get_model()->do_set_has_required_score_states(mos[i], true);
    ret += mos[i]->get_required_score_states();
  }
  std::sort(ret.begin(), ret.end());
  std::sort(exclude.begin(), exclude.end());
  ScoreStatesTemp diff;
  std::set_difference(ret.begin(), ret.end(), exclude.begin(), exclude.end(),
                      std::back_inserter(diff));
  return get_update_order(diff);
}
コード例 #7
0
ファイル: HybridMonteCarlo.cpp プロジェクト: drussel/imp
void HybridMonteCarlo::do_step()
{
    //gibbs sampler on x and v
    //persistence=p samples p times x and once v
    //However because it's constant E, a rejected move
    //will result in recalculating the same move up to p times
    //until it is either accepted or the velocities are redrawn
    //since p has to be independent of the outcome (markov property)
    //we avoid recalculating the trajectory on rejection by just trying
    //it over and over without doing the md again.
    persistence_counter_ += 1;
    if (persistence_counter_ == persistence_)
    {
        persistence_counter_ = 0;
        //boltzmann constant in kcal/mol
        static const double kB = 8.31441 / 4186.6;
        md_->assign_velocities(get_kt() / kB);
    }
    ParticleIndexes all_optimized_particles;
    {
      ModelObjectsTemp op = get_model()->get_optimized_particles();
      for (unsigned int i = 0; i< op.size(); ++i) {
        all_optimized_particles.push_back(dynamic_cast<Particle*>(op[i].get())
                                          ->get_index());
      }
    }
    double last = do_evaluate(all_optimized_particles);
    core::MonteCarloMoverResult moved = do_move();

    double energy = do_evaluate(all_optimized_particles);
    bool accepted = do_accept_or_reject_move(energy, last,
                                             moved.get_proposal_ratio());
    while ((!accepted) && (persistence_counter_ < persistence_-1))
    {
        persistence_counter_ += 1;
        accepted = do_accept_or_reject_move(energy, last,
                                            moved.get_proposal_ratio());
    }

    /*std::cout << "hmc"
        << " old " << last
        << " new " << energy
        << " delta " << energy-last
        << " accepted " << accepted
        <<std::endl;*/
}