-
Notifications
You must be signed in to change notification settings - Fork 3
/
call_ls.cc
165 lines (129 loc) · 4.96 KB
/
call_ls.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*
$Id: call_ls.cc,v 1.11 2014/06/12 01:44:07 mp Exp $
AutoDock
Copyright (C) 2009 The Scripps Research Institute. All rights reserved.
AutoDock is a Trade Mark of The Scripps Research Institute.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
/********************************************************************
Call_ls: Invokes a local searcher on a docking to try and
find the locally optimal solution. So, the docking
must be specified BEFORE calling this routine.
rsh 2/5/96
********************************************************************/
// possibly unnecessary // #include <iostream.h>
#include "ls.h"
#include "support.h"
#include "eval.h"
#include "constants.h"
#include "structs.h"
#include "qmultiply.h"
Representation **cnv_state_to_rep(const State &state)
{
register int i;
Representation **retval;
retval = new Representation *[5];
retval[0] = new RealVector(1);
retval[0]->write(state.T.x, 0);
retval[1] = new RealVector(1);
retval[1]->write(state.T.y, 0);
retval[2] = new RealVector(1);
retval[2]->write(state.T.z, 0);
retval[3] = new RealVector(4);
retval[3]->write(state.Q.x, 0);
retval[3]->write(state.Q.y, 1);
retval[3]->write(state.Q.z, 2);
retval[3]->write(state.Q.w, 3);
retval[4] = new RealVector(state.ntor);
for(i=0; i<state.ntor; i++) {
retval[4]->write(state.tor[i], i);
}
return(retval);
}
Individual cnv_state_to_ind(const State &original, Eval *evaluate)
{
// BEGIN DELETION
// return(Individual(Genotype(5, cnv_state_to_rep(original)), Phenotype(5, cnv_state_to_rep(original))));
// END DELETION
// BEGIN ADDITION
// Added by gmm, 27-MAR-97, to solve these compiler warnings:
//
// call_ls.cc:59: warning: In this statement, the initialization of a non-const reference requires a temporary for "Genotype(5,cnv_state_to_rep(original))". (reftemporary)
// call_ls.cc:59: warning: In this statement, the initialization of a non-const reference requires a temporary for "Phenotype(5,cnv_state_to_rep(original))". (reftemporary)
// call_ls.cc:59: warning: In this statement, the initialization of a non-const reference requires a temporary for "(Individual(Genotype(5,cnv_state_to_rep(original)),Phenotype(5,cnv_state_to_rep(original))))". (reftemporary)
Genotype temp_Gtype;
Phenotype temp_Ptype;
temp_Gtype = Genotype(5, cnv_state_to_rep(original));
temp_Ptype = Phenotype(5, cnv_state_to_rep(original), evaluate);
Individual temp(temp_Gtype, temp_Ptype);
return(temp);
// END ADDITION
}
State
call_ls(Local_Search *const local_method, const State& now,
const unsigned int pop_size, Molecule *const mol,
Eval *evaluate, const int outlev, FILE *logFile)
{
unsigned int i;
evaluate->reset();
local_method->reset();
//MP Individual prototype;
//MP prototype = cnv_state_to_ind(now, evaluate);
//MPPopulation thisPop(pop_size, evaluate, &prototype); // MPique TODO this evaluate is redundant
Population thisPop(pop_size, evaluate);
// MPique 2013:
// for thread-safety, each population must have its own local search workspaces
// MP TODO how know if SW or PSW? Ask Ruth
/*
Real (*ibias)[pop_size], (*irho)[pop_size], (*idev)[pop_size];
local_method (*iSearch)[pop_size];
ibias = new *Real[pop_size];
irho= new *Real[pop_size];
idev= new *Real[pop_size];
iSearch= new *local_method[pop_size];
*/
for(i=0;i<pop_size;i++)
{
thisPop[i] = cnv_state_to_ind(now, evaluate); // MP 2014 need this ??
thisPop[i].mol = mol;
}
#ifdef DEBUG0
// MP Sept 2011
double e_start;
#endif
for(i=0; i<pop_size; i++)
{
#ifdef DEBUG0
// MP Sept 2011
if(i==0)fprintf(logFile, "LS:: ->call_ls(thisPop[%3d]) %10.6f\n", i,
e_start=thisPop[i].value(Normal_Eval));
#endif
local_method->search( thisPop[i], evaluate, outlev, logFile );
#ifdef DEBUG0
fprintf(logFile, "LS:: <-call_ls(thisPop[%3d]) %10.6f\n", i,
thisPop[i].value(Normal_Eval));
#endif
}
if (pop_size > 1)
thisPop.msort(1);
(void)fprintf(logFile,"Final-Value: %.3f\n", thisPop[0].value(Normal_Eval));
#ifdef DEBUG0
double e_final = thisPop[0].value(Normal_Eval);
fprintf(logFile, "LS:: orig %10.6f best %10.6f (improvement %10.6f) \n",
e_start, e_final, e_start-e_final);
#endif
return(thisPop[0].state(now.ntor));
}