21 #include <utility/vector1.hh>
25 namespace optimize_weights {
46 Size const num_energy_dofs,
55 Real boundE = 0, unboundE = 0;
56 for (
Size ii = 1; ii <= num_energy_dofs; ++ii ) {
57 boundE += vars[ ii ] *
bound_->free_data()[ ii ];
58 unboundE += vars[ ii ] *
unbound_->free_data()[ ii ];
60 for (
Size ii = 1; ii <= fixed_score_list.size(); ++ii ) {
61 boundE += fixed_terms[ fixed_score_list[ ii ] ] *
bound_->fixed_data()[ ii ];
62 unboundE += fixed_terms[ fixed_score_list[ ii ] ] *
unbound_->fixed_data()[ ii ];
70 Real const pred_dG = (boundE - unboundE) - TdS;
72 Real const sq_err = diff_dG * diff_dG;
74 for (
Size ii = 1; ii <= num_energy_dofs; ++ii ) {
75 dE_dvars[ ii ] += component_weights[
type() ] * 2 * diff_dG * (
bound_->free_data()[ ii ] -
unbound_->free_data()[ ii ] );
79 ostr <<
"DGBindOptEData bound[ " << boundE <<
" ] - unbound[ " << unboundE <<
" ] = predicted[ " << pred_dG <<
" ], "
80 <<
"predicted[ " << pred_dG <<
" ] - experimental[ " << deltaG_bind_ <<
" ] = error[ " << diff_dG <<
" ], "
81 <<
"error^2[ " << sq_err <<
" ], weighted error^2[ " << component_weights[
type() ]*sq_err <<
" ]" << std::endl;
85 return component_weights[
type() ] * sq_err;
111 total +=
sizeof(
Real) * (
bound_->free_data().size()+
bound_->fixed_data().size()) * 1;
119 DGBindOptEData::send_to_node(
int const destination_node,
int const tag )
const
123 MPI_Send( & deltaG_bind, 1, MPI_DOUBLE, destination_node, tag, MPI_COMM_WORLD );
128 MPI_Send( & n_free, 1, MPI_UNSIGNED_LONG, destination_node, tag, MPI_COMM_WORLD );
133 MPI_Send( & n_fixed, 1, MPI_UNSIGNED_LONG, destination_node, tag, MPI_COMM_WORLD );
136 Real * free_data =
new Real[ n_free ];
137 Real * fixed_data =
new Real[ n_fixed ];
138 for (
Size jj = 1; jj <= n_free; ++jj ) {
139 free_data[ ( jj - 1 ) ] =
bound_->free_data()[ jj ];
141 for (
Size jj = 1; jj <= n_fixed; ++jj ) {
142 fixed_data[ ( jj - 1 ) ] =
bound_->fixed_data()[ jj ];
147 MPI_Send( free_data, n_free, MPI_DOUBLE, destination_node, tag, MPI_COMM_WORLD );
151 MPI_Send( fixed_data, n_fixed, MPI_DOUBLE, destination_node, tag, MPI_COMM_WORLD );
156 Real * decoy_free_data =
new Real[ n_free ];
157 Real * decoy_fixed_data =
new Real[ n_fixed ];
158 for (
Size jj = 1; jj <= n_free; ++jj ) {
159 decoy_free_data[ ( jj - 1 ) ] =
unbound_->free_data()[ jj ];
161 for (
Size jj = 1; jj <= n_fixed; ++jj ) {
162 decoy_fixed_data[ ( jj - 1 ) ] =
unbound_->fixed_data()[ jj ];
166 MPI_Send( decoy_free_data, n_free, MPI_DOUBLE, destination_node, tag, MPI_COMM_WORLD );
170 MPI_Send( decoy_fixed_data, n_fixed, MPI_DOUBLE, destination_node, tag, MPI_COMM_WORLD );
173 delete [] fixed_data;
175 delete [] decoy_free_data;
176 delete [] decoy_fixed_data;
178 OptEPositionData::send_to_node( destination_node, tag );
184 DGBindOptEData::receive_from_node(
int const source_node,
int const tag )
190 MPI_Recv( &
deltaG_bind_, 1, MPI_DOUBLE, source_node, tag, MPI_COMM_WORLD, &stat );
194 MPI_Recv( & n_free, 1, MPI_UNSIGNED_LONG, source_node, tag, MPI_COMM_WORLD, &stat );
198 MPI_Recv( & n_fixed, 1, MPI_UNSIGNED_LONG, source_node, tag, MPI_COMM_WORLD, &stat );
201 Real * free_data =
new Real[ n_free ];
202 Real * fixed_data =
new Real[ n_fixed ];
205 MPI_Recv( free_data, n_free, MPI_DOUBLE, source_node, tag, MPI_COMM_WORLD, &stat );
208 MPI_Recv( fixed_data, n_fixed, MPI_DOUBLE, source_node, tag, MPI_COMM_WORLD, &stat );
212 for (
Size jj = 1; jj <= n_free; ++jj ) {
213 free_data_v[ jj ] = free_data[ ( jj - 1 ) ];
215 for (
Size jj = 1; jj <= n_fixed; ++jj ) {
216 fixed_data_v[ jj ] = fixed_data[ ( jj - 1 ) ];
218 bound_ =
new SingleStructureData( free_data_v, fixed_data_v );
221 delete [] free_data; free_data = 0;
222 delete [] fixed_data; fixed_data = 0;
225 free_data =
new Real[ n_free ];
226 fixed_data =
new Real[ n_fixed ];
229 MPI_Recv( free_data, n_free, MPI_DOUBLE, source_node, tag, MPI_COMM_WORLD, &stat );
232 MPI_Recv( fixed_data, n_fixed, MPI_DOUBLE, source_node, tag, MPI_COMM_WORLD, &stat );
234 for (
Size jj = 1; jj <= n_free; ++jj ) {
235 free_data_v[ jj ] = free_data[ ( jj - 1 ) ];
237 for (
Size jj = 1; jj <= n_fixed; ++jj ) {
238 fixed_data_v[ jj ] = fixed_data[ ( jj - 1 ) ];
240 unbound_ =
new SingleStructureData( free_data_v, fixed_data_v );
244 delete [] fixed_data;
246 OptEPositionData::receive_from_node( source_node, tag );