Rosetta 3.5
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
protocols
simple_moves
rational_mc
RationalMonteCarlo.cc
Go to the documentation of this file.
1
// -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2
// vi: set ts=2 noet:
3
//
4
// (c) Copyright Rosetta Commons Member Institutions.
5
// (c) This file is part of the Rosetta software suite and is made available under license.
6
// (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7
// (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8
// (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9
10
/// @file protocols/simple_moves/rational_mc/RationalMonteCarlo.cc
11
/// @author Christopher Miles (cmiles@uw.edu)
12
13
// Unit header
14
#include <
protocols/simple_moves/rational_mc/RationalMonteCarlo.hh
>
15
16
// C/C++ headers
17
#include <iostream>
18
#include <string>
19
20
// External headers
21
#include <boost/bind.hpp>
22
#include <boost/function.hpp>
23
#include <boost/unordered/unordered_map.hpp>
24
25
// Utility headers
26
#include <basic/Tracer.hh>
27
28
// Project headers
29
#include <
core/scoring/ScoreFunction.hh
>
30
#include <
core/pose/Pose.hh
>
31
#include <
protocols/viewer/viewers.hh
>
32
33
// Package headers
34
#include <
protocols/moves/MonteCarlo.hh
>
35
#include <
protocols/moves/Mover.hh
>
36
37
namespace
protocols {
38
namespace
simple_moves {
39
namespace
rational_mc {
40
41
using
core::Real
;
42
using
core::Size
;
43
using
core::pose::Pose
;
44
using
core::scoring::ScoreFunction
;
45
using
core::scoring::ScoreFunctionOP
;
46
using
protocols::moves::Mover
;
47
using
protocols::moves::MoverOP
;
48
49
static
basic::Tracer
TR
(
"protocols.simple_moves.RationalMonteCarlo"
);
50
51
RationalMonteCarlo::RationalMonteCarlo
(
MoverOP
mover,
ScoreFunctionOP
score,
Size
num_trials,
Real
temperature,
bool
recover_low)
52
:
Mover
(
"RationalMonteCarlo"
), mover_(mover), num_trials_(num_trials), recover_low_(recover_low), next_trigger_id_(0) {
53
mc_
=
new
protocols::moves::MonteCarlo
(*score, temperature);
54
protocols::viewer::add_monte_carlo_viewer
(*
mc_
,
"RationalMonteCarlo"
);
55
}
56
57
void
RationalMonteCarlo::apply
(
Pose
& pose) {
58
mc_
->reset(pose);
59
mc_
->reset_counters();
60
61
for
(
Size
i = 1; i <=
num_trials
(); ++i) {
62
Pose
copy(pose);
63
mover_
->apply(pose);
64
65
if
(
mc_
->boltzmann(pose)) {
// accept
66
fire_all_triggers
(pose);
67
}
else
{
// reject
68
pose = copy;
69
}
70
}
71
72
if
(
recover_low
())
73
mc_
->recover_low(pose);
74
75
// Show simulation statistics
76
mc_
->show_counters();
77
mc_
->score_function().show(TR, pose);
78
TR.flush();
79
}
80
81
std::string
RationalMonteCarlo::get_name
()
const
{
82
return
"RationalMonteCarlo"
;
83
}
84
85
Size
RationalMonteCarlo::add_trigger
(
const
RationalMonteCarloTrigger
& trigger) {
86
Size
tid = ++
next_trigger_id_
;
87
triggers_
[tid] = trigger;
88
return
tid;
89
}
90
91
void
RationalMonteCarlo::remove_trigger
(
Size
trigger_id) {
92
Triggers::const_iterator i =
triggers_
.find(trigger_id);
93
if
(i ==
triggers_
.end()) {
94
TR.Warning <<
"Attempt to remove invalid trigger_id => "
<< trigger_id << std::endl;
95
return
;
96
}
97
triggers_
.erase(i);
98
}
99
100
void
RationalMonteCarlo::fire_all_triggers
(
const
Pose
& pose) {
101
for
(Triggers::iterator i =
triggers_
.begin(); i !=
triggers_
.end(); ++i) {
102
RationalMonteCarloTrigger
&
t
= i->second;
103
t
(pose);
104
}
105
}
106
107
// -- Accessors -- //
108
Size
RationalMonteCarlo::num_trials
()
const
{
109
return
num_trials_
;
110
}
111
112
bool
RationalMonteCarlo::recover_low
()
const
{
113
return
recover_low_
;
114
}
115
116
MoverOP
RationalMonteCarlo::mover
()
const
{
117
return
mover_
;
118
}
119
120
Real
RationalMonteCarlo::temperature
()
const
{
121
return
mc_
->temperature();
122
}
123
124
const
ScoreFunction
&
RationalMonteCarlo::score_function
()
const
{
125
return
mc_
->score_function();
126
}
127
128
const
Pose
&
RationalMonteCarlo::lowest_score_pose
()
const
{
129
return
mc_
->lowest_score_pose();
130
}
131
132
const
Pose
&
RationalMonteCarlo::last_accepted_pose
()
const
{
133
return
mc_
->last_accepted_pose();
134
}
135
136
// -- Mutators -- //
137
void
RationalMonteCarlo::set_num_trials
(
Size
num_trials) {
138
num_trials_
=
num_trials
;
139
}
140
141
void
RationalMonteCarlo::set_recover_low
(
bool
recover_low) {
142
recover_low_
=
recover_low
;
143
}
144
145
void
RationalMonteCarlo::set_mover
(
MoverOP
mover) {
146
mover_
=
mover
;
147
}
148
149
void
RationalMonteCarlo::set_temperature
(
Real
temperature) {
150
mc_
->set_temperature(temperature);
151
}
152
153
void
RationalMonteCarlo::set_score_function
(
ScoreFunctionOP
score) {
154
mc_
->score_function(*score);
155
}
156
157
void
RationalMonteCarlo::reset
(
const
Pose
& pose) {
158
mc_
->reset(pose);
159
}
160
161
void
RationalMonteCarlo::enable_autotemp
(
core::Real
quench) {
162
mc_
->set_autotemp(
true
, quench);
163
}
164
165
void
RationalMonteCarlo::disable_autotemp
() {
166
mc_
->set_autotemp(
false
, 0);
167
}
168
169
}
// namespace rational_mc
170
}
// namespace simple_moves
171
}
// namespace protocols
Generated on Sat Jun 1 2013 12:16:40 for Rosetta 3.5 by
1.8.4