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 25 - (show annotations) (download) (as text)
Mon Jul 7 02:35:51 2014 UTC (9 years, 8 months ago) by rtomiyasu
File MIME type: text/x-c++src
File size: 27932 byte(s)
Source codes of version 0.9.99
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, "OutputOrthorhombicC"),
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, "ZeroPointShiftParameter"),
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, "AxisForMonoclinicSymmetry"),
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 const pair<RWParamProperty, RWParamData<Double> > ControlParam::ResoltoCheckComputedLines_Data(
174 RWParamProperty(DVALUE, "ResolutionToCheckCoincidenceofComputedLines", NULL, 1, 0),
175 RWParamData<Double>(0.03, REPLACE_NONE<Double>, GE<Double>, 0.0, LE<Double>, 0.05, -1, -1) ); // 0 <= param < INF.
176 const pair<RWParamProperty, RWParamData<Double> > ControlParam::MaxQtoCheckComputedLines_Data(
177 RWParamProperty(DVALUE, "MaxQToCheckCoincidenceofComputedLines", NULL, 1, 0),
178 RWParamData<Double>(3.0, REPLACE_NONE<Double>, GE<Double>, 0.0, NULL, MAX_DP(), -1, -1) ); // 0 <= param < INF.
179 const pair<RWParamProperty, RWParamData<Int4> > ControlParam::MaxSizeForEachBRAVAIS_Data(
180 RWParamProperty(INT4VALUE, "MaxNumberOfSolutionsForEachBravaisLattice", NULL, 1, 0),
181 RWParamData<Int4>(1000, REPLACE_NONE<Int4>, GE<Int4>, 1, NULL, MAX_INT(), -1, -1) );
182
183 ControlParam::ControlParam()
184 :
185 #ifdef _OPENMP
186 NumCores_Data(RWParamProperty(INT4VALUE, "NumberOfThreadsToUse"),
187 RWParamData<Int4>(max(1, omp_get_num_procs()-1), REPLACE_NUM_THREAD, GE<Int4>, 1, NULL, MAX_INT(), -1, -1) ),
188 #else
189 NumCores_Data(RWParamProperty(INT4VALUE, "NumberOfThreadsToUse"),
190 RWParamData<Int4>(1, REPLACE_NUM_THREAD, GE<Int4>, 1, NULL, MAX_INT(), -1, -1) ),
191 #endif
192 ReadConfigurationParameters(true),
193 IsADorTOF(IsAngleDispersion_Data.second.initial_value),
194 ConvParam(ConvParam_Data.second.initial_value),
195 PeakShiftParam(PeakShiftParam_Data.second.initial_value),
196 WlengthX(WlengthX_Data.second.initial_value),
197 SearchLevel(SearchLevel_Data.second.initial_value),
198 MaxPeakNum(0),
199 MaxEdgeNum(0),
200 MaxNodeNum(0),
201 MinUnitCellVolume(0.0),
202 MaxUnitCellVolume(0.0),
203 CVForLinearSum(CVForLinearSum_Data.second.initial_value),
204 NumRefFigureOfMerit(NumRefFigureOfMerit_Data.second.initial_value),
205 MaxNumPeakInRange(0),
206 MinNumPeakInRange(0),
207 MinUnitCellEdgeABC(MinUnitCellEdgeABC_Data.second.initial_value),
208 MaxUnitCellEdgeABC(MaxUnitCellEdgeABC_Data.second.initial_value),
209 MinFOM(MinFOM_Data.second.initial_value),
210 Resol(Resol_Data.second.initial_value),
211 NumCores(NumCores_Data.second.initial_value),
212 MaxSizeForEachBRAVAIS(MaxSizeForEachBRAVAIS_Data.second.initial_value),
213 MonoBaseAxis(MonoBaseAxis_Data.second.initial_value),
214 RhomAxis(RhomAxis_Data.second.initial_value),
215 ThresholdNormM(ThresholdNormM_Data.second.initial_value),
216 ThresholdRevM(ThresholdRevM_Data.second.initial_value),
217 MinLatticePointDistance(MinLatticePointDistance_Data.second.initial_value),
218 ResoltoCheckComputedLines(ResoltoCheckComputedLines_Data.second.initial_value),
219 MaxQtoCheckComputedLines(MaxQtoCheckComputedLines_Data.second.initial_value),
220 str_MaxPeakNum(str_MaxPeakNum_Data.second.initial_value),
221 str_MaxEdgeNum(str_MaxEdgeNum_Data.second.initial_value),
222 str_MaxNodeNum(str_MaxNodeNum_Data.second.initial_value),
223 str_MinUnitCellVolume(str_MinUnitCellVolume_Data.second.initial_value),
224 str_MaxUnitCellVolume(str_MaxUnitCellVolume_Data.second.initial_value),
225 str_MaxNumPeakInRange(str_MaxNumPeakInRange_Data.second.initial_value),
226 str_MinNumPeakInRange(str_MinNumPeakInRange_Data.second.initial_value)
227 {
228 for(Int4 i=0; i<NUM_LS; i++)
229 {
230 OutputSymmetry[i] = OutputSymmetry_Data[i].second.initial_value;
231 }
232 }
233
234
235 ControlParam::~ControlParam()
236 {
237 }
238
239
240 const string& ControlParam::putTagLabel() const
241 {
242 static const string label = "ConographParameters";
243 return label;
244 }
245
246
247 ZErrorMessageReadingFile ControlParam::readFile(const string& filename, const string& file_label)
248 {
249 ZErrorMessageReadingFile zerr = I_ReadData::readFile(filename, file_label);
250 if( IsAngleDispersion() ) ConvParam.clear();
251 else PeakShiftParam.clear();
252
253 if( zerr.putErrorType() != ZErrorNoError ) return zerr;
254 if( str_MaxPeakNum!="AUTO" )
255 {
256 if( str_MaxPeakNum=="MAX" )
257 {
258 MaxPeakNum = numeric_limits<Int4>::max();
259 }
260 else
261 {
262 istringstream iss( str_MaxPeakNum );
263 iss >> MaxPeakNum;
264 if( iss.fail() ) return ZErrorMessageReadingFile( filename, ZErrorMessage(ZErrorFileFormatBroken, "The string cannot be replaced for <" + str_MaxPeakNum_Data.first.putLabel() + ">:"+str_MaxPeakNum, __FILE__, __LINE__, __FUNCTION__) );
265 if( MaxPeakNum < 3 )
266 {
267 return ZErrorMessageReadingFile( filename, ZErrorMessage("<"+ str_MaxPeakNum_Data.first.putLabel() + "> is too small: "+num2str<Int4>(MaxPeakNum), __FILE__, __LINE__, __FUNCTION__) );
268 }
269 else if( MaxPeakNum > 2000 )
270 {
271 return ZErrorMessageReadingFile( filename, ZErrorMessage("<"+ str_MaxPeakNum_Data.first.putLabel() + "> is too large: "+num2str<Int4>(MaxPeakNum), __FILE__, __LINE__, __FUNCTION__) );
272 }
273 }
274 }
275
276 if( str_MaxEdgeNum != "AUTO" )
277 {
278 if( str_MaxEdgeNum=="MAX" )
279 {
280 MaxEdgeNum = numeric_limits<Int4>::max();
281 }
282 else
283 {
284 istringstream iss( str_MaxEdgeNum );
285 iss >> MaxEdgeNum;
286 if( iss.fail() ) return ZErrorMessageReadingFile(filename, ZErrorMessage(ZErrorFileFormatBroken, "The string cannot be replaced for <" + str_MaxEdgeNum_Data.first.putLabel() + ">: "+str_MaxEdgeNum, __FILE__, __LINE__, __FUNCTION__) );
287 if( MaxEdgeNum < 1 )
288 {
289 return ZErrorMessageReadingFile(filename, nerror_arg("<"+ str_MaxEdgeNum_Data.first.putLabel() + "> is too small: "+num2str<Int4>(MaxEdgeNum), __FILE__, __LINE__, __FUNCTION__) );
290 }
291 }
292 }
293
294 if( str_MaxNodeNum != "AUTO" )
295 {
296 if( str_MaxNodeNum=="MAX" )
297 {
298 MaxNodeNum = numeric_limits<Int4>::max();
299 }
300 else
301 {
302 istringstream iss( str_MaxNodeNum );
303 iss >> MaxNodeNum;
304 if( iss.fail() ) return ZErrorMessageReadingFile(filename, ZErrorMessage(ZErrorFileFormatBroken, "The string in <" + str_MaxNodeNum_Data.first.putLabel() + "> is not replaced: "+str_MaxNodeNum, __FILE__, __LINE__, __FUNCTION__) );
305 if( MaxNodeNum < 1 )
306 {
307 return ZErrorMessageReadingFile(filename, nerror_arg("<"+ str_MaxNodeNum_Data.first.putLabel() + "> is too small: "+num2str<Int4>(MaxNodeNum), __FILE__, __LINE__, __FUNCTION__) );
308 }
309 }
310 }
311
312 if( str_MinUnitCellVolume != "AUTO" )
313 {
314 istringstream iss( str_MinUnitCellVolume );
315 iss >> MinUnitCellVolume;
316 if( iss.fail() ) return ZErrorMessageReadingFile(filename, ZErrorMessage(ZErrorFileFormatBroken, "The string cannot be replaced for <" + putMinUnitCellVolumeLabel() + ">: "+str_MinUnitCellVolume, __FILE__, __LINE__, __FUNCTION__) );
317 if( MinUnitCellVolume < 1.0 )
318 {
319 return ZErrorMessageReadingFile(filename, nerror_arg("<"+ putMinUnitCellVolumeLabel() + "> is less than 1: "+num2str<Double>(MinUnitCellVolume), __FILE__, __LINE__, __FUNCTION__) );
320 }
321 }
322
323 if( str_MaxUnitCellVolume != "AUTO" )
324 {
325 istringstream iss( str_MaxUnitCellVolume );
326 iss >> MaxUnitCellVolume;
327 if( iss.fail() ) return ZErrorMessageReadingFile(filename, ZErrorMessage(ZErrorFileFormatBroken, "The string cannot be replaced for <" + putMaxUnitCellVolumeLabel() + ">: "+str_MaxUnitCellVolume, __FILE__, __LINE__, __FUNCTION__) );
328 if( MaxUnitCellVolume <= MinUnitCellVolume )
329 {
330 return ZErrorMessageReadingFile(filename, nerror_arg("<"+ putMaxUnitCellVolumeLabel() + "> is not larger than <"+ putMinUnitCellVolumeLabel() + "> : "+num2str<Double>(MaxUnitCellVolume), __FILE__, __LINE__, __FUNCTION__) );
331 }
332 }
333
334 if( str_MaxNumPeakInRange != "AUTO" )
335 {
336 if( str_MaxNumPeakInRange =="MAX" )
337 {
338 MaxNumPeakInRange = numeric_limits<Int4>::max();
339 }
340 else
341 {
342 istringstream iss( str_MaxNumPeakInRange );
343 iss >> MaxNumPeakInRange;
344 if( iss.fail() ) return ZErrorMessageReadingFile(filename, ZErrorMessage(ZErrorFileFormatBroken, "The string cannot be replaced for <" + str_MaxNumPeakInRange_Data.first.putLabel() + ">: "+str_MaxNumPeakInRange, __FILE__, __LINE__, __FUNCTION__) );
345 if( MaxNumPeakInRange < 1 )
346 {
347 return ZErrorMessageReadingFile(filename, ZErrorMessage("<"+ str_MaxNumPeakInRange_Data.first.putLabel() + "> is less than 1: "+num2str<Double>(MaxNumPeakInRange), __FILE__, __LINE__, __FUNCTION__) );
348 }
349 }
350 }
351
352 if( str_MinNumPeakInRange != "AUTO" )
353 {
354 istringstream iss( str_MinNumPeakInRange );
355 iss >> MinNumPeakInRange;
356 if( iss.fail() ) return ZErrorMessageReadingFile(filename, ZErrorMessage(ZErrorFileFormatBroken, "The string cannot be replaced for <" + str_MinNumPeakInRange_Data.first.putLabel() + ">: "+str_MinNumPeakInRange, __FILE__, __LINE__, __FUNCTION__) );
357 if( MinNumPeakInRange < 1 )
358 {
359 return ZErrorMessageReadingFile(filename, ZErrorMessage("<"+ str_MinNumPeakInRange_Data.first.putLabel() + "> is less than 1: "+num2str<Double>(MinNumPeakInRange), __FILE__, __LINE__, __FUNCTION__) );
360 }
361
362 if( str_MaxNumPeakInRange != "AUTO" && MaxNumPeakInRange < MinNumPeakInRange )
363 {
364 return ZErrorMessageReadingFile(filename, ZErrorMessage( "<" + str_MaxNumPeakInRange_Data.first.putLabel() + "> is less than <" + str_MinNumPeakInRange_Data.first.putLabel() + ">",
365 __FILE__, __LINE__, __FUNCTION__) );
366 }
367 }
368
369 return ZErrorMessageReadingFile();
370 }
371
372
373
374 void ControlParam::setData(const RWParamProperty& parent_prop,
375 vector<RWParam_void>& tray)
376 {
377 if( parent_prop.putLabel() == this->putTagLabel() )
378 {
379 tray.push_back( RWParam_void(IsAngleDispersion_Data, &IsADorTOF) );
380 for(Int4 i=0; i<NUM_LS; i++)
381 {
382 tray.push_back( RWParam_void(OutputSymmetry_Data[i], &OutputSymmetry[i]) );
383 }
384 tray.push_back( RWParam_void(ConvParam_Data, &ConvParam) );
385 tray.push_back( RWParam_void(PeakShiftParam_Data, &PeakShiftParam) );
386 tray.push_back( RWParam_void(WlengthX_Data, &WlengthX) );
387 tray.push_back( RWParam_void(Resol_Data, &Resol) );
388 tray.push_back( RWParam_void(CVForLinearSum_Data, &CVForLinearSum) );
389 tray.push_back( RWParam_void(str_MaxPeakNum_Data, &str_MaxPeakNum) );
390 tray.push_back( RWParam_void(str_MaxEdgeNum_Data, &str_MaxEdgeNum) );
391 tray.push_back( RWParam_void(str_MaxNodeNum_Data, &str_MaxNodeNum) );
392 tray.push_back( RWParam_void(str_MinUnitCellVolume_Data, &str_MinUnitCellVolume) );
393 tray.push_back( RWParam_void(str_MaxUnitCellVolume_Data, &str_MaxUnitCellVolume) );
394
395 tray.push_back( RWParam_void(MinUnitCellEdgeABC_Data, &MinUnitCellEdgeABC) );
396 tray.push_back( RWParam_void(MaxUnitCellEdgeABC_Data, &MaxUnitCellEdgeABC) );
397 tray.push_back( RWParam_void(MinFOM_Data, &MinFOM) );
398 tray.push_back( RWParam_void(str_MaxNumPeakInRange_Data, &str_MaxNumPeakInRange) );
399 tray.push_back( RWParam_void(str_MinNumPeakInRange_Data, &str_MinNumPeakInRange) );
400 tray.push_back( RWParam_void(NumRefFigureOfMerit_Data, &NumRefFigureOfMerit) );
401
402 tray.push_back( RWParam_void(SearchLevel_Data, &SearchLevel) );
403
404 if( ReadConfigurationParameters )
405 {
406 tray.push_back( RWParam_void(NumCores_Data, &NumCores) );
407 MaxSizeForEachBRAVAIS = MaxSizeForEachBRAVAIS_Data.second.initial_value;
408 tray.push_back( RWParam_void(MaxSizeForEachBRAVAIS_Data, &MaxSizeForEachBRAVAIS) );
409
410 tray.push_back( RWParam_void(MonoBaseAxis_Data, &MonoBaseAxis) );
411 tray.push_back( RWParam_void(RhomAxis_Data, &RhomAxis) );
412 tray.push_back( RWParam_void(ThresholdNormM_Data, &ThresholdNormM) );
413 tray.push_back( RWParam_void(ThresholdRevM_Data, &ThresholdRevM) );
414 tray.push_back( RWParam_void(MinLatticePointDistance_Data, &MinLatticePointDistance) );
415 tray.push_back( RWParam_void(ResoltoCheckComputedLines_Data, &ResoltoCheckComputedLines) );
416 tray.push_back( RWParam_void(MaxQtoCheckComputedLines_Data, &MaxQtoCheckComputedLines) );
417 }
418 }
419 }
420
421
422 ZErrorMessage ControlParam::checkData(const RWParam_void& param) const
423 {
424 const string Label = param.putLabel();
425 if( IsEqualTag(param.putProperty(), ConvParam_Data.first ) )
426 {
427 if( IsADorTOF )
428 {
429 return ZErrorMessage();
430 }
431 }
432 else if( IsEqualTag(param.putProperty(), PeakShiftParam_Data.first)
433 || IsEqualTag(param.putProperty(), WlengthX_Data.first) )
434 {
435 if( !IsADorTOF )
436 {
437 return ZErrorMessage();
438 }
439 }
440 else if( IsEqualTag(param.putProperty(), MonoBaseAxis_Data.first) )
441 {
442 if( find_key(ABCaxisLabel, MonoBaseAxis) == eABCaxis(-1) )
443 {
444 return nerror_out_range(param.putLabel(), MonoBaseAxis, __FILE__, __LINE__, __FUNCTION__ );
445 }
446 else return ZErrorMessage();
447 }
448 else if( IsEqualTag(param.putProperty(), RhomAxis_Data.first) )
449 {
450 if( find_key(RHaxisLabel, RhomAxis) == eRHaxis(-1) )
451 {
452 return nerror_out_range(param.putLabel(), RhomAxis, __FILE__, __LINE__, __FUNCTION__ );
453 }
454 else return ZErrorMessage();
455 }
456 return I_ReadData::checkData(param);
457 }
458
459
460
461 ZErrorMessage ControlParam::checkIfDataAreSet(const RWParam_void& param, const Int4& num) const
462 {
463 const string Label = param.putLabel();
464 if( IsEqualTag(param.putProperty(), ConvParam_Data.first) )
465 {
466 if( IsADorTOF )
467 {
468 return ZErrorMessage();
469 }
470 }
471 else if( IsEqualTag(param.putProperty(), PeakShiftParam_Data.first)
472 || IsEqualTag(param.putProperty(), WlengthX_Data.first) )
473 {
474 if( !IsADorTOF )
475 {
476 return ZErrorMessage();
477 }
478 }
479 else if( IsEqualTag(param.putProperty(), MaxUnitCellEdgeABC_Data.first) )
480 {
481 if( MaxUnitCellEdgeABC < MinUnitCellEdgeABC )
482 {
483 return ZErrorMessage( "<" + MaxUnitCellEdgeABC_Data.first.putLabel() + "> is less than <" + MinUnitCellEdgeABC_Data.first.putLabel() + ">",
484 __FILE__, __LINE__, __FUNCTION__);
485 }
486 }
487
488 return I_ReadData::checkIfDataAreSet(param, num);
489 }
490
491
492 inline Int4 put_automatic_peak_num(const eConographAnalysisMode& search_level, const vector<QData>& qdata,
493 const Int4& num_ref_figure_of_merit, const Double& min_length_edge)
494 {
495 assert( num_ref_figure_of_merit <= (Int4)qdata.size() );
496 if( qdata.empty() ) return 0;
497 return max(num_ref_figure_of_merit, min(48, (Int4)distance( qdata.begin(),
498 upper_bound( qdata.begin(), qdata.end(), QData( 10.0 /(min_length_edge*min_length_edge), 0.0 ) ) ) ) );
499 }
500
501
502 inline Int4 put_automatic_edge_num(const eConographAnalysisMode& search_level, const Int4& MaxPeakNum)
503 {
504 if( search_level == ConographQuickSearch ) return MaxPeakNum * (MaxPeakNum+1) / 3;
505 return MaxPeakNum * (MaxPeakNum+1) / 2;
506 }
507
508
509 inline Int4 put_automatic_node_num(const eConographAnalysisMode& search_level, const Int4& MaxPeakNum)
510 {
511 if( search_level == ConographQuickSearch ) return min(MaxPeakNum * (MaxPeakNum+1) * MaxPeakNum * (MaxPeakNum+1) / 9, 64000);
512 return min(MaxPeakNum * (MaxPeakNum+1) * (MaxPeakNum+2) * 2 / 3, 32000);
513 }
514
515
516 inline pair<Double, Double> put_automatic_unit_cell_volume(const vector<QData>& qData, const Int4& MaxPeakNum)
517 {
518 Double ans = 1.0/put_maximum_counitcell_volume(qData, 20);
519 return pair<Double, Double>(max(5.0, ans), ans*30.0);
520 }
521
522
523 ZErrorMessage ControlParam::setAutomaticallyComputedParam(const vector<QData>& qData)
524 {
525 // Set the automatically calculated number of peaks to utilize for indexing.
526 if( this->putNumberOfReflectionsForFigureOfMerit() > (Int4)qData.size() )
527 {
528 this->setNumberOfReflectionsForFigureOfMerit(qData.size());
529 ZLOG_INFO( "\"" + ControlParam::putNumberOfReflectionsForFigureOfMeritLabel() + "\" is more than the number of peaks. It is replaced by the number of peaks.\n" );
530 }
531
532 if( this->putStrMaxPeakNum()=="AUTO" )
533 {
534 MaxPeakNum = put_automatic_peak_num( this->putSearchLevel(), qData, NumRefFigureOfMerit, MinLatticePointDistance);
535 ZLOG_INFO( "<" + str_MaxPeakNum_Data.first.putLabel() + "> is set to " + num2str<Int4>(MaxPeakNum) + "\n" );
536 }
537 else
538 {
539 if( this->putMaxPeakNum() > (Int4)qData.size() )
540 {
541 this->setMaxPeakNum(qData.size());
542 ZLOG_INFO( "\"" + str_MaxPeakNum_Data.first.putLabel() + "\" is more than the number of peaks. It is replaced by the number of peaks.\n" );
543 }
544 }
545
546 if( str_MaxEdgeNum == "AUTO" )
547 {
548 MaxEdgeNum = put_automatic_edge_num( this->putSearchLevel(), this->putMaxPeakNum() );
549 ZLOG_INFO( "<" + str_MaxEdgeNum_Data.first.putLabel() + "> is set to " + num2str(MaxEdgeNum) + ".\n" );
550 }
551
552 if( str_MaxNodeNum == "AUTO" )
553 {
554 MaxNodeNum = put_automatic_node_num( this->putSearchLevel(), this->putMaxPeakNum() );
555 ZLOG_INFO( "<" + str_MaxNodeNum_Data.first.putLabel() + "> is set to " + num2str(MaxNodeNum) + ".\n" );
556 }
557
558 if( str_MinUnitCellVolume == "AUTO" || str_MaxUnitCellVolume == "AUTO" )
559 {
560 pair<Double, Double> unit_cell_vol_range = put_automatic_unit_cell_volume(qData, this->putMaxPeakNum());
561 if( str_MinUnitCellVolume == "AUTO" )
562 {
563 MinUnitCellVolume = unit_cell_vol_range.first;
564 ZLOG_INFO( "<" + putMinUnitCellVolumeLabel() + "> is set to " + num2str(MinUnitCellVolume) + ".\n" );
565 }
566 if( str_MaxUnitCellVolume == "AUTO" )
567 {
568 MaxUnitCellVolume = unit_cell_vol_range.second;
569 ZLOG_INFO( "<" + putMaxUnitCellVolumeLabel() + "> is set to " + num2str(MaxUnitCellVolume) + ".\n" );
570 }
571 }
572
573 if( str_MaxNumPeakInRange == "AUTO" )
574 {
575 MaxNumPeakInRange = ifloor( pow(this->putNumberOfReflectionsForFigureOfMerit(), 1.62) );
576 ZLOG_INFO( "<" + str_MaxNumPeakInRange_Data.first.putLabel() + "> is set to " + num2str(MaxNumPeakInRange) + ".\n" );
577 }
578
579 if( str_MinNumPeakInRange == "AUTO" )
580 {
581 MinNumPeakInRange = this->putNumberOfReflectionsForFigureOfMerit() * 3 / 5;
582 ZLOG_INFO( "<" + str_MinNumPeakInRange_Data.first.putLabel() + "> is set to " + num2str(MinNumPeakInRange) + ".\n" );
583 }
584
585 if( MaxNumPeakInRange < MinNumPeakInRange )
586 {
587 return ZErrorMessage("<" + str_MinNumPeakInRange_Data.first.putLabel() + "> : " + num2str<Int4>(MinNumPeakInRange) +'\n'
588 + str_MaxNumPeakInRange_Data.first.putLabel() + "> : " + num2str<Int4>(MaxNumPeakInRange) +'\n'
589 + "<" + str_MaxNumPeakInRange_Data.first.putLabel() + "> is less than <" + str_MinNumPeakInRange_Data.first.putLabel() + ">", __FILE__, __LINE__, __FUNCTION__);
590 }
591
592 return ZErrorMessage();
593 }

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