Develop and Download Open Source Software

Browse Subversion Repository

Contents of /Conograph/trunk/src/ControlParam.cc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6 - (show annotations) (download) (as text)
Wed Feb 27 00:58:34 2013 UTC (11 years ago) by rtomiyasu
File MIME type: text/x-c++src
File size: 26387 byte(s)
OpenMPに関する実装の修正。
1 /*
2 * The MIT License
3
4 Conograph (powder auto-indexing program)
5
6 Copyright (c) <2012> <Ryoko Oishi-Tomiyasu, KEK>
7
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 THE SOFTWARE.
25 *
26 */
27 #ifdef _OPENMP
28 #include <omp.h>
29 #endif
30 #include <string>
31 #include "ControlParam.hh"
32 #include "utility_data_structure/qdata.hh"
33 #include "utility_func/zstring.hh"
34 #include "utility_func/zmath.hh"
35 #include "zlog/zlog.hh"
36
37 const map<eABCaxis, string> ControlParam::ABCaxisLabel = putABCaxisLabel();
38 const map<eRHaxis, string> ControlParam::RHaxisLabel = putRHaxisLabel();
39
40 static Vec_DP putConvParamRange()
41 {
42 Vec_DP ans(2, 0.0);
43 ans[0] = -I_ReadData::MAX_DP();
44 return ans;
45 }
46
47 const pair<RWParamProperty, RWParamData<bool> > ControlParam::IsAngleDispersion_Data(
48 RWParamProperty(BOOLFLAG, "IsAngleDispersion"),
49 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) );
50 const pair<RWParamProperty, RWParamData<bool> > ControlParam::OutputSymmetry_Data[NUM_LS]
51 = {
52 pair<RWParamProperty, RWParamData<bool> >(
53 RWParamProperty(BOOLFLAG, "OutputTriclinic"),
54 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) ),
55 pair<RWParamProperty, RWParamData<bool> >(
56 RWParamProperty(BOOLFLAG, "OutputMonoclinicP"),
57 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) ),
58 pair<RWParamProperty, RWParamData<bool> >(
59 RWParamProperty(BOOLFLAG, "OutputMonoclinicB"),
60 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) ),
61 pair<RWParamProperty, RWParamData<bool> >(
62 RWParamProperty(BOOLFLAG, "OutputOrthorhombicP"),
63 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) ),
64 pair<RWParamProperty, RWParamData<bool> >(
65 RWParamProperty(BOOLFLAG, "OutputOrthorhombicB"),
66 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) ),
67 pair<RWParamProperty, RWParamData<bool> >(
68 RWParamProperty(BOOLFLAG, "OutputOrthorhombicI"),
69 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) ),
70 pair<RWParamProperty, RWParamData<bool> >(
71 RWParamProperty(BOOLFLAG, "OutputOrthorhombicF"),
72 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) ),
73 pair<RWParamProperty, RWParamData<bool> >(
74 RWParamProperty(BOOLFLAG, "OutputTetragonalP"),
75 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) ),
76 pair<RWParamProperty, RWParamData<bool> >(
77 RWParamProperty(BOOLFLAG, "OutputTetragonalI"),
78 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) ),
79 pair<RWParamProperty, RWParamData<bool> >(
80 RWParamProperty(BOOLFLAG, "OutputRhombohedral"),
81 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) ),
82 pair<RWParamProperty, RWParamData<bool> >(
83 RWParamProperty(BOOLFLAG, "OutputHexagonal"),
84 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) ),
85 pair<RWParamProperty, RWParamData<bool> >(
86 RWParamProperty(BOOLFLAG, "OutputCubicP"),
87 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) ),
88 pair<RWParamProperty, RWParamData<bool> >(
89 RWParamProperty(BOOLFLAG, "OutputCubicI"),
90 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) ),
91 pair<RWParamProperty, RWParamData<bool> >(
92 RWParamProperty(BOOLFLAG, "OutputCubicF"),
93 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) )
94 };
95
96 inline Vec_DP put_initial_conv_param()
97 {
98 Vec_DP ans(3,0.0);
99 ans[1] = 1.0;
100 return ans;
101 }
102
103 const pair<RWParamProperty, RWParamData<Vec_DP> > ControlParam::ConvParam_Data(
104 RWParamProperty(DARRAY, "ConversionParameters"),
105 RWParamData<Vec_DP>(put_initial_conv_param(), REPLACE_VECTOR_NONE<Double>, GTVec<Double>, putConvParamRange(), NULL, Vec_DP(), 2, 6) );
106 const pair<RWParamProperty, RWParamData<Vec_DP> > ControlParam::PeakShiftParam_Data(
107 RWParamProperty(DARRAY, "PeakShiftParameters"),
108 RWParamData<Vec_DP>(Vec_DP(1,0.0), REPLACE_VECTOR_NONE<Double>, NULL, Vec_DP(), NULL, Vec_DP(), 1, 1) );
109 const pair<RWParamProperty, RWParamData<Double> > ControlParam::WlengthX_Data(
110 RWParamProperty(DVALUE, "WaveLength"),
111 RWParamData<Double>(1.54056, REPLACE_NONE<Double>, GT<Double>, 0.0, NULL, MAX_DP(), -1, -1) );
112
113
114 const pair<RWParamProperty, RWParamData<string> > ControlParam::str_MaxPeakNum_Data(
115 RWParamProperty(STRVALUE, "MaxNumberOfPeaks"),
116 RWParamData<string>("AUTO", REPLACE_NONE<string>, NULL, "", NULL, "", -1, -1) );
117 const pair<RWParamProperty, RWParamData<Int4> > ControlParam::NumRefFigureOfMerit_Data(
118 RWParamProperty(INT4VALUE, "MaxNumberOfPeaksForFOM"),
119 RWParamData<Int4>(20, REPLACE_NONE<Int4>, GE<Int4>, 1, NULL, MAX_INT(), -1, -1) ); // 20 <= param < INF.
120 const pair<RWParamProperty, RWParamData<string> > ControlParam::str_MaxEdgeNum_Data(
121 RWParamProperty(STRVALUE, "MaxNumberOfTwoDimTopographs"),
122 RWParamData<string>("AUTO", REPLACE_NONE<string>, NULL, "", NULL, "", -1, -1) ); // 0 < param < INF.
123 const pair<RWParamProperty, RWParamData<string> > ControlParam::str_MaxNodeNum_Data(
124 RWParamProperty(STRVALUE, "MaxNumberOfLatticeCandidates"),
125 RWParamData<string>("AUTO", REPLACE_NONE<string>, NULL, "", NULL, "", -1, -1) ); // 0 < param < INF.
126 const pair<RWParamProperty, RWParamData<string> > ControlParam::str_MaxNumPeakInRange_Data(
127 RWParamProperty(STRVALUE, "MaxNumberOfMillerIndicesInRange"),
128 RWParamData<string>("AUTO", REPLACE_NONE<string>, NULL, "", NULL, "", -1, -1) );
129 const pair<RWParamProperty, RWParamData<string> > ControlParam::str_MinNumPeakInRange_Data(
130 RWParamProperty(STRVALUE, "MinNumberOfMillerIndicesInRange"),
131 RWParamData<string>("AUTO", REPLACE_NONE<string>, NULL, "", NULL, "", -1, -1) ); // 0.0 <= param <= 1.0.
132 const pair<RWParamProperty, RWParamData<Double> > ControlParam::MinFOM_Data(
133 RWParamProperty(DVALUE, "MinFOM"),
134 RWParamData<Double>(3.0, REPLACE_NONE<Double>, GE<Double>, 0.0, NULL, MAX_DP(), -1, -1) ); // 0 <= param < INF.
135 const pair<RWParamProperty, RWParamData<string> > ControlParam::str_MaxUnitCellVolume_Data(
136 RWParamProperty(STRVALUE, "MaxPrimitiveUnitCellVolume"),
137 RWParamData<string>("AUTO", REPLACE_NONE<string>, NULL, "", NULL, "", -1, -1) ); // 0 <= param < INF.
138 const pair<RWParamProperty, RWParamData<string> > ControlParam::str_MinUnitCellVolume_Data(
139 RWParamProperty(STRVALUE, "MinPrimitiveUnitCellVolume"),
140 RWParamData<string>("AUTO", REPLACE_NONE<string>, NULL, "", NULL, "", -1, -1) ); // 0 <= param < INF.
141 const pair<RWParamProperty, RWParamData<Double> > ControlParam::MinUnitCellEdgeABC_Data(
142 RWParamProperty(DVALUE, "MinUnitCellEdgeABC"),
143 RWParamData<Double>(0.0, REPLACE_NONE<Double>, GE<Double>, 0.0, NULL, MAX_DP(), -1, -1) ); // 0 <= param < INF.
144 const pair<RWParamProperty, RWParamData<Double> > ControlParam::MaxUnitCellEdgeABC_Data(
145 RWParamProperty(DVALUE, "MaxUnitCellEdgeABC"),
146 RWParamData<Double>(1000.0, REPLACE_MAX<Double>, GT<Double>, 0.0, NULL, MAX_DP(), -1, -1) ); // 0 <= param < INF.
147 const pair<RWParamProperty, RWParamData<Double> > ControlParam::CVForLinearSum_Data(
148 RWParamProperty(DVALUE, "CriticalValueForLinearSum"),
149 RWParamData<Double>(1.0, REPLACE_NONE<Double>, GT<Double>, 0.0, NULL, MAX_DP(), -1, -1) ); // 0 < param < INF.
150 const pair<RWParamProperty, RWParamData<Double> > ControlParam::Resol_Data(
151 RWParamProperty(DVALUE, "Resolution"),
152 RWParamData<Double>(0.03, REPLACE_NONE<Double>, GE<Double>, 0.0, LE<Double>, 0.25, -1, -1) ); // 0 <= param < INF.
153
154 const pair<RWParamProperty, RWParamData<Int4> > ControlParam::SearchLevel_Data(
155 RWParamProperty(INT4VALUE, "SearchLevel"),
156 RWParamData<Int4>((Int4)ConographQuickSearch, REPLACE_NONE<Int4>, GE<Int4>, (Int4)ConographQuickSearch, LE<Int4>, (Int4)ConographRegularSearch, -1, -1) );
157
158 const pair<RWParamProperty, RWParamData<string> > ControlParam::MonoBaseAxis_Data(
159 RWParamProperty(STRVALUE, "AxisForBaseCenteredSymmetry"),
160 RWParamData<string>("B", REPLACE_NONE<string>, NULL, "", NULL, "", -1, -1) );
161 const pair<RWParamProperty, RWParamData<string> > ControlParam::RhomAxis_Data(
162 RWParamProperty(STRVALUE, "AxisForRhombohedralSymmetry"),
163 RWParamData<string>("Hexagonal", REPLACE_NONE<string>, NULL, "", NULL, "", -1, -1) );
164 const pair<RWParamProperty, RWParamData<Double> > ControlParam::ThresholdNormM_Data(
165 RWParamProperty(DVALUE, "ThresholdOnNormM"),
166 RWParamData<Double>(1.9, REPLACE_NONE<Double>, GE<Double>, 0.0, NULL, MAX_DP(), -1, -1) ); // 0 <= param < INF.
167 const pair<RWParamProperty, RWParamData<Double> > ControlParam::ThresholdRevM_Data(
168 RWParamProperty(DVALUE, "ThresholdOnRevM"),
169 RWParamData<Double>(0.9, REPLACE_NONE<Double>, GE<Double>, 0.0, NULL, MAX_DP(), -1, -1) ); // 0 <= param < INF.
170 const pair<RWParamProperty, RWParamData<Double> > ControlParam::MinLatticePointDistance_Data(
171 RWParamProperty(DVALUE, "MinDistanceBetweenLatticePoints"),
172 RWParamData<Double>(2.0, REPLACE_NONE<Double>, GE<Double>, 0.0, NULL, MAX_DP(), -1, -1) ); // 0 <= param < INF.
173
174
175 ControlParam::ControlParam()
176 :
177 #ifdef _OPENMP
178 NumCores_Data(RWParamProperty(INT4VALUE, "NumberOfThreadsToUse"),
179 RWParamData<Int4>(max(1, omp_get_max_threads()-1), REPLACE_MAX_THREAD, GE<Int4>, 1, NULL, MAX_INT(), -1, -1) ),
180 #else
181 NumCores_Data(RWParamProperty(INT4VALUE, "NumberOfThreadsToUse"),
182 RWParamData<Int4>(1, REPLACE_MAX_THREAD, GE<Int4>, 1, NULL, MAX_INT(), -1, -1) ),
183 #endif
184 IsADorTOF(IsAngleDispersion_Data.second.initial_value),
185 ConvParam(ConvParam_Data.second.initial_value),
186 PeakShiftParam(PeakShiftParam_Data.second.initial_value),
187 WlengthX(WlengthX_Data.second.initial_value),
188 SearchLevel(SearchLevel_Data.second.initial_value),
189 MaxPeakNum(0),
190 MaxEdgeNum(0),
191 MaxNodeNum(0),
192 MinUnitCellVolume(0.0),
193 MaxUnitCellVolume(0.0),
194 CVForLinearSum(CVForLinearSum_Data.second.initial_value),
195 NumRefFigureOfMerit(NumRefFigureOfMerit_Data.second.initial_value),
196 MaxNumPeakInRange(0),
197 MinNumPeakInRange(0),
198 MinUnitCellEdgeABC(MinUnitCellEdgeABC_Data.second.initial_value),
199 MaxUnitCellEdgeABC(MaxUnitCellEdgeABC_Data.second.initial_value),
200 MinFOM(MinFOM_Data.second.initial_value),
201 Resol(Resol_Data.second.initial_value),
202 NumCores(NumCores_Data.second.initial_value),
203 MonoBaseAxis(MonoBaseAxis_Data.second.initial_value),
204 RhomAxis(RhomAxis_Data.second.initial_value),
205 ThresholdNormM(ThresholdNormM_Data.second.initial_value),
206 ThresholdRevM(ThresholdRevM_Data.second.initial_value),
207 MinLatticePointDistance(MinLatticePointDistance_Data.second.initial_value),
208 str_MaxPeakNum(str_MaxPeakNum_Data.second.initial_value),
209 str_MaxEdgeNum(str_MaxEdgeNum_Data.second.initial_value),
210 str_MaxNodeNum(str_MaxNodeNum_Data.second.initial_value),
211 str_MinUnitCellVolume(str_MinUnitCellVolume_Data.second.initial_value),
212 str_MaxUnitCellVolume(str_MaxUnitCellVolume_Data.second.initial_value),
213 str_MaxNumPeakInRange(str_MaxNumPeakInRange_Data.second.initial_value),
214 str_MinNumPeakInRange(str_MinNumPeakInRange_Data.second.initial_value)
215 {
216 for(Int4 i=0; i<NUM_LS; i++)
217 {
218 OutputSymmetry[i] = OutputSymmetry_Data[i].second.initial_value;
219 }
220 }
221
222
223 ControlParam::~ControlParam()
224 {
225 }
226
227
228 const string& ControlParam::putTagLabel() const
229 {
230 static const string label = "ConographParameters";
231 return label;
232 }
233
234
235 ZErrorMessageReadingFile ControlParam::readFile(const string& filename, const string& file_label)
236 {
237 ZErrorMessageReadingFile zerr = I_ReadData::readFile(filename, file_label);
238 if( IsAngleDispersion() ) ConvParam.clear();
239 else PeakShiftParam.clear();
240
241 if( zerr.putErrorType() != ZErrorNoError ) return zerr;
242 if( str_MaxPeakNum!="AUTO" )
243 {
244 if( str_MaxPeakNum=="MAX" )
245 {
246 MaxPeakNum = numeric_limits<Int4>::max();
247 }
248 else
249 {
250 istringstream iss( str_MaxPeakNum );
251 iss >> MaxPeakNum;
252 if( iss.fail() ) return ZErrorMessageReadingFile( filename, ZErrorMessage(ZErrorFileFormatBroken, "The string cannot be replaced for <" + str_MaxPeakNum_Data.first.putLabel() + ">:"+str_MaxPeakNum, __FILE__, __LINE__, __FUNCTION__) );
253 if( MaxPeakNum < 3 )
254 {
255 return ZErrorMessageReadingFile( filename, ZErrorMessage("<"+ str_MaxPeakNum_Data.first.putLabel() + "> is too small: "+num2str<Int4>(MaxPeakNum), __FILE__, __LINE__, __FUNCTION__) );
256 }
257 else if( MaxPeakNum > 2000 )
258 {
259 return ZErrorMessageReadingFile( filename, ZErrorMessage("<"+ str_MaxPeakNum_Data.first.putLabel() + "> is too large: "+num2str<Int4>(MaxPeakNum), __FILE__, __LINE__, __FUNCTION__) );
260 }
261 }
262 }
263
264 if( str_MaxEdgeNum != "AUTO" )
265 {
266 if( str_MaxEdgeNum=="MAX" )
267 {
268 MaxEdgeNum = numeric_limits<Int4>::max();
269 }
270 else
271 {
272 istringstream iss( str_MaxEdgeNum );
273 iss >> MaxEdgeNum;
274 if( iss.fail() ) return ZErrorMessageReadingFile(filename, ZErrorMessage(ZErrorFileFormatBroken, "The string cannot be replaced for <" + str_MaxEdgeNum_Data.first.putLabel() + ">: "+str_MaxEdgeNum, __FILE__, __LINE__, __FUNCTION__) );
275 if( MaxEdgeNum < 1 )
276 {
277 return ZErrorMessageReadingFile(filename, nerror_arg("<"+ str_MaxEdgeNum_Data.first.putLabel() + "> is too small: "+num2str<Int4>(MaxEdgeNum), __FILE__, __LINE__, __FUNCTION__) );
278 }
279 }
280 }
281
282 if( str_MaxNodeNum != "AUTO" )
283 {
284 if( str_MaxNodeNum=="MAX" )
285 {
286 MaxNodeNum = numeric_limits<Int4>::max();
287 }
288 else
289 {
290 istringstream iss( str_MaxNodeNum );
291 iss >> MaxNodeNum;
292 if( iss.fail() ) return ZErrorMessageReadingFile(filename, ZErrorMessage(ZErrorFileFormatBroken, "The string in <" + str_MaxNodeNum_Data.first.putLabel() + "> is not replaced: "+str_MaxNodeNum, __FILE__, __LINE__, __FUNCTION__) );
293 if( MaxNodeNum < 1 )
294 {
295 return ZErrorMessageReadingFile(filename, nerror_arg("<"+ str_MaxNodeNum_Data.first.putLabel() + "> is too small: "+num2str<Int4>(MaxNodeNum), __FILE__, __LINE__, __FUNCTION__) );
296 }
297 }
298 }
299
300 if( str_MinUnitCellVolume != "AUTO" )
301 {
302 istringstream iss( str_MinUnitCellVolume );
303 iss >> MinUnitCellVolume;
304 if( iss.fail() ) return ZErrorMessageReadingFile(filename, ZErrorMessage(ZErrorFileFormatBroken, "The string cannot be replaced for <" + putMinUnitCellVolumeLabel() + ">: "+str_MinUnitCellVolume, __FILE__, __LINE__, __FUNCTION__) );
305 if( MinUnitCellVolume < 1.0 )
306 {
307 return ZErrorMessageReadingFile(filename, nerror_arg("<"+ putMinUnitCellVolumeLabel() + "> is less than 1: "+num2str<Double>(MinUnitCellVolume), __FILE__, __LINE__, __FUNCTION__) );
308 }
309 }
310
311 if( str_MaxUnitCellVolume != "AUTO" )
312 {
313 istringstream iss( str_MaxUnitCellVolume );
314 iss >> MaxUnitCellVolume;
315 if( iss.fail() ) return ZErrorMessageReadingFile(filename, ZErrorMessage(ZErrorFileFormatBroken, "The string cannot be replaced for <" + putMaxUnitCellVolumeLabel() + ">: "+str_MaxUnitCellVolume, __FILE__, __LINE__, __FUNCTION__) );
316 if( MaxUnitCellVolume <= MinUnitCellVolume )
317 {
318 return ZErrorMessageReadingFile(filename, nerror_arg("<"+ putMaxUnitCellVolumeLabel() + "> is not larger than <"+ putMinUnitCellVolumeLabel() + "> : "+num2str<Double>(MaxUnitCellVolume), __FILE__, __LINE__, __FUNCTION__) );
319 }
320 }
321
322 if( str_MaxNumPeakInRange != "AUTO" )
323 {
324 if( str_MaxNumPeakInRange =="MAX" )
325 {
326 MaxNumPeakInRange = numeric_limits<Int4>::max();
327 }
328 else
329 {
330 istringstream iss( str_MaxNumPeakInRange );
331 iss >> MaxNumPeakInRange;
332 if( iss.fail() ) return ZErrorMessageReadingFile(filename, ZErrorMessage(ZErrorFileFormatBroken, "The string cannot be replaced for <" + str_MaxNumPeakInRange_Data.first.putLabel() + ">: "+str_MaxNumPeakInRange, __FILE__, __LINE__, __FUNCTION__) );
333 if( MaxNumPeakInRange < 1 )
334 {
335 return ZErrorMessageReadingFile(filename, ZErrorMessage("<"+ str_MaxNumPeakInRange_Data.first.putLabel() + "> is less than 1: "+num2str<Double>(MaxNumPeakInRange), __FILE__, __LINE__, __FUNCTION__) );
336 }
337 }
338 }
339
340 if( str_MinNumPeakInRange != "AUTO" )
341 {
342 istringstream iss( str_MinNumPeakInRange );
343 iss >> MinNumPeakInRange;
344 if( iss.fail() ) return ZErrorMessageReadingFile(filename, ZErrorMessage(ZErrorFileFormatBroken, "The string cannot be replaced for <" + str_MinNumPeakInRange_Data.first.putLabel() + ">: "+str_MinNumPeakInRange, __FILE__, __LINE__, __FUNCTION__) );
345 if( MinNumPeakInRange < 1 )
346 {
347 return ZErrorMessageReadingFile(filename, ZErrorMessage("<"+ str_MinNumPeakInRange_Data.first.putLabel() + "> is less than 1: "+num2str<Double>(MinNumPeakInRange), __FILE__, __LINE__, __FUNCTION__) );
348 }
349
350 if( str_MaxNumPeakInRange != "AUTO" && MaxNumPeakInRange < MinNumPeakInRange )
351 {
352 return ZErrorMessageReadingFile(filename, ZErrorMessage( "<" + str_MaxNumPeakInRange_Data.first.putLabel() + "> is less than <" + str_MinNumPeakInRange_Data.first.putLabel() + ">",
353 __FILE__, __LINE__, __FUNCTION__) );
354 }
355 }
356
357 return ZErrorMessageReadingFile();
358 }
359
360
361
362 void ControlParam::setData(const RWParamProperty& parent_prop,
363 vector<RWParam_void>& tray)
364 {
365 if( parent_prop.putLabel() == this->putTagLabel() )
366 {
367 tray.push_back( RWParam_void(IsAngleDispersion_Data, &IsADorTOF) );
368 for(Int4 i=0; i<NUM_LS; i++)
369 {
370 tray.push_back( RWParam_void(OutputSymmetry_Data[i], &OutputSymmetry[i]) );
371 }
372 tray.push_back( RWParam_void(ConvParam_Data, &ConvParam) );
373 tray.push_back( RWParam_void(PeakShiftParam_Data, &PeakShiftParam) );
374 tray.push_back( RWParam_void(WlengthX_Data, &WlengthX) );
375 tray.push_back( RWParam_void(Resol_Data, &Resol) );
376 tray.push_back( RWParam_void(CVForLinearSum_Data, &CVForLinearSum) );
377 tray.push_back( RWParam_void(str_MaxPeakNum_Data, &str_MaxPeakNum) );
378 tray.push_back( RWParam_void(str_MaxEdgeNum_Data, &str_MaxEdgeNum) );
379 tray.push_back( RWParam_void(str_MaxNodeNum_Data, &str_MaxNodeNum) );
380 tray.push_back( RWParam_void(str_MinUnitCellVolume_Data, &str_MinUnitCellVolume) );
381 tray.push_back( RWParam_void(str_MaxUnitCellVolume_Data, &str_MaxUnitCellVolume) );
382
383 tray.push_back( RWParam_void(MinUnitCellEdgeABC_Data, &MinUnitCellEdgeABC) );
384 tray.push_back( RWParam_void(MaxUnitCellEdgeABC_Data, &MaxUnitCellEdgeABC) );
385 tray.push_back( RWParam_void(MinFOM_Data, &MinFOM) );
386 tray.push_back( RWParam_void(str_MaxNumPeakInRange_Data, &str_MaxNumPeakInRange) );
387 tray.push_back( RWParam_void(str_MinNumPeakInRange_Data, &str_MinNumPeakInRange) );
388 tray.push_back( RWParam_void(NumRefFigureOfMerit_Data, &NumRefFigureOfMerit) );
389
390 tray.push_back( RWParam_void(SearchLevel_Data, &SearchLevel) );
391 tray.push_back( RWParam_void(NumCores_Data, &NumCores) );
392 tray.push_back( RWParam_void(MonoBaseAxis_Data, &MonoBaseAxis) );
393 tray.push_back( RWParam_void(RhomAxis_Data, &RhomAxis) );
394 tray.push_back( RWParam_void(ThresholdNormM_Data, &ThresholdNormM) );
395 tray.push_back( RWParam_void(ThresholdRevM_Data, &ThresholdRevM) );
396 tray.push_back( RWParam_void(MinLatticePointDistance_Data, &MinLatticePointDistance) );
397 }
398 }
399
400
401 ZErrorMessage ControlParam::checkData(const RWParam_void& param) const
402 {
403 const string Label = param.putLabel();
404 if( IsEqualTag(param.putProperty(), ConvParam_Data.first ) )
405 {
406 if( IsADorTOF )
407 {
408 return ZErrorMessage();
409 }
410 }
411 else if( IsEqualTag(param.putProperty(), PeakShiftParam_Data.first)
412 || IsEqualTag(param.putProperty(), WlengthX_Data.first) )
413 {
414 if( !IsADorTOF )
415 {
416 return ZErrorMessage();
417 }
418 }
419 else if( IsEqualTag(param.putProperty(), MonoBaseAxis_Data.first) )
420 {
421 if( find_key(ABCaxisLabel, MonoBaseAxis) == eABCaxis(-1) )
422 {
423 return nerror_out_range(param.putLabel(), MonoBaseAxis, __FILE__, __LINE__, __FUNCTION__ );
424 }
425 else return ZErrorMessage();
426 }
427 else if( IsEqualTag(param.putProperty(), RhomAxis_Data.first) )
428 {
429 if( find_key(RHaxisLabel, RhomAxis) == eRHaxis(-1) )
430 {
431 return nerror_out_range(param.putLabel(), RhomAxis, __FILE__, __LINE__, __FUNCTION__ );
432 }
433 else return ZErrorMessage();
434 }
435 return I_ReadData::checkData(param);
436 }
437
438
439
440 ZErrorMessage ControlParam::checkIfDataAreSet(const RWParam_void& param, const Int4& num) const
441 {
442 const string Label = param.putLabel();
443 if( IsEqualTag(param.putProperty(), ConvParam_Data.first) )
444 {
445 if( IsADorTOF )
446 {
447 return ZErrorMessage();
448 }
449 }
450 else if( IsEqualTag(param.putProperty(), PeakShiftParam_Data.first)
451 || IsEqualTag(param.putProperty(), WlengthX_Data.first) )
452 {
453 if( !IsADorTOF )
454 {
455 return ZErrorMessage();
456 }
457 }
458 else if( IsEqualTag(param.putProperty(), MaxUnitCellEdgeABC_Data.first) )
459 {
460 if( MaxUnitCellEdgeABC < MinUnitCellEdgeABC )
461 {
462 return ZErrorMessage( "<" + MaxUnitCellEdgeABC_Data.first.putLabel() + "> is less than <" + MinUnitCellEdgeABC_Data.first.putLabel() + ">",
463 __FILE__, __LINE__, __FUNCTION__);
464 }
465 }
466
467 return I_ReadData::checkIfDataAreSet(param, num);
468 }
469
470
471 inline Int4 put_automatic_peak_num(const eConographAnalysisMode& search_level, const vector<QData>& qdata,
472 const Int4& num_ref_figure_of_merit, const Double& min_length_edge)
473 {
474 assert( num_ref_figure_of_merit <= (Int4)qdata.size() );
475 if( qdata.empty() ) return 0;
476 return max(num_ref_figure_of_merit, min(48, (Int4)distance( qdata.begin(),
477 upper_bound( qdata.begin(), qdata.end(), QData( 10.0 /(min_length_edge*min_length_edge), 0.0 ) ) ) ) );
478 }
479
480
481 inline Int4 put_automatic_edge_num(const eConographAnalysisMode& search_level, const Int4& MaxPeakNum)
482 {
483 if( search_level == ConographQuickSearch ) return MaxPeakNum * (MaxPeakNum+1) / 3;
484 return MaxPeakNum * (MaxPeakNum+1) / 2;
485 }
486
487
488 inline Int4 put_automatic_node_num(const eConographAnalysisMode& search_level, const Int4& MaxPeakNum)
489 {
490 if( search_level == ConographQuickSearch ) return min(MaxPeakNum * (MaxPeakNum+1) * MaxPeakNum * (MaxPeakNum+1) / 9, 64000);
491 return min(MaxPeakNum * (MaxPeakNum+1) * (MaxPeakNum+2) * 2 / 3, 32000);
492 }
493
494
495 inline pair<Double, Double> put_automatic_unit_cell_volume(const vector<QData>& qData, const Int4& MaxPeakNum)
496 {
497 Double ans = 1.0/put_maximum_counitcell_volume(qData, 20);
498 return pair<Double, Double>(max(5.0, ans), ans*30.0);
499 }
500
501
502 ZErrorMessage ControlParam::setAutomaticallyComputedParam(const vector<QData>& qData)
503 {
504 // Set the automatically calculated number of peaks to utilize for indexing.
505 if( this->putNumberOfReflectionsForFigureOfMerit() > (Int4)qData.size() )
506 {
507 this->setNumberOfReflectionsForFigureOfMerit(qData.size());
508 ZLOG_INFO( "\"" + ControlParam::putNumberOfReflectionsForFigureOfMeritLabel() + "\" is more than the number of peaks. It is replaced by the number of peaks.\n" );
509 }
510
511 if( this->putStrMaxPeakNum()=="AUTO" )
512 {
513 MaxPeakNum = put_automatic_peak_num( this->putSearchLevel(), qData, NumRefFigureOfMerit, MinLatticePointDistance);
514 ZLOG_INFO( "<" + str_MaxPeakNum_Data.first.putLabel() + "> is set to " + num2str<Int4>(MaxPeakNum) + "\n" );
515 }
516 else
517 {
518 if( this->putMaxPeakNum() > (Int4)qData.size() )
519 {
520 this->setMaxPeakNum(qData.size());
521 ZLOG_INFO( "\"" + str_MaxPeakNum_Data.first.putLabel() + "\" is more than the number of peaks. It is replaced by the number of peaks.\n" );
522 }
523 }
524
525 if( str_MaxEdgeNum == "AUTO" )
526 {
527 MaxEdgeNum = put_automatic_edge_num( this->putSearchLevel(), this->putMaxPeakNum() );
528 ZLOG_INFO( "<" + str_MaxEdgeNum_Data.first.putLabel() + "> is set to " + num2str(MaxEdgeNum) + ".\n" );
529 }
530
531 if( str_MaxNodeNum == "AUTO" )
532 {
533 MaxNodeNum = put_automatic_node_num( this->putSearchLevel(), this->putMaxPeakNum() );
534 ZLOG_INFO( "<" + str_MaxNodeNum_Data.first.putLabel() + "> is set to " + num2str(MaxNodeNum) + ".\n" );
535 }
536
537 if( str_MinUnitCellVolume == "AUTO" || str_MaxUnitCellVolume == "AUTO" )
538 {
539 pair<Double, Double> unit_cell_vol_range = put_automatic_unit_cell_volume(qData, this->putMaxPeakNum());
540 if( str_MinUnitCellVolume == "AUTO" )
541 {
542 MinUnitCellVolume = unit_cell_vol_range.first;
543 ZLOG_INFO( "<" + putMinUnitCellVolumeLabel() + "> is set to " + num2str(MinUnitCellVolume) + ".\n" );
544 }
545 if( str_MaxUnitCellVolume == "AUTO" )
546 {
547 MaxUnitCellVolume = unit_cell_vol_range.second;
548 ZLOG_INFO( "<" + putMaxUnitCellVolumeLabel() + "> is set to " + num2str(MaxUnitCellVolume) + ".\n" );
549 }
550 }
551
552 if( str_MaxNumPeakInRange == "AUTO" )
553 {
554 MaxNumPeakInRange = ifloor( pow(this->putNumberOfReflectionsForFigureOfMerit(), 1.6) );
555 ZLOG_INFO( "<" + str_MaxNumPeakInRange_Data.first.putLabel() + "> is set to " + num2str(MaxNumPeakInRange) + ".\n" );
556 }
557
558 if( str_MinNumPeakInRange == "AUTO" )
559 {
560 MinNumPeakInRange = this->putNumberOfReflectionsForFigureOfMerit() * 3 / 5;
561 ZLOG_INFO( "<" + str_MinNumPeakInRange_Data.first.putLabel() + "> is set to " + num2str(MinNumPeakInRange) + ".\n" );
562 }
563
564 if( MaxNumPeakInRange < MinNumPeakInRange )
565 {
566 return ZErrorMessage("<" + str_MinNumPeakInRange_Data.first.putLabel() + "> : " + num2str<Int4>(MinNumPeakInRange) +'\n'
567 + str_MaxNumPeakInRange_Data.first.putLabel() + "> : " + num2str<Int4>(MaxNumPeakInRange) +'\n'
568 + "<" + str_MaxNumPeakInRange_Data.first.putLabel() + "> is less than <" + str_MinNumPeakInRange_Data.first.putLabel() + ">", __FILE__, __LINE__, __FUNCTION__);
569 }
570
571 return ZErrorMessage();
572 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26