Branch data Line data Source code
1 : : /**
2 : : * @author: Abed Yassine
3 : : * @date: September 26th, 2019
4 : : * \brief implementation of the wrapper class of FullMonteSW
5 : : */
6 : :
7 : : #include "read_mesh.h"
8 : : #include "src_placer.h"
9 : :
10 : : #include "file_parser.h"
11 : : #include "run_fullmonte.h"
12 : :
13 : : #include <sstream>
14 : :
15 : : using namespace std;
16 : :
17 : : //! Default constructor
18 : 0 : WrapperFullMonteSW::WrapperFullMonteSW() :
19 : 0 : _mesh(nullptr), _materials(nullptr), _kernel(nullptr), _tetraCache(nullptr), _enclosing(nullptr)
20 : : {
21 : 0 : }
22 : :
23 : : /**
24 : : * Regular constructor
25 : : * @param mesh_file [in] input file of the mesh to read
26 : : * @param fparser [in] pointer to XML parser
27 : : * @param read_vtk [in] specifies if the input file is in .mesh or .vtk format
28 : : */
29 : 756 : WrapperFullMonteSW::WrapperFullMonteSW(string mesh_file, Parser* fparser, bool read_vtk, bool use_cuda) :
30 [ + - ]: 756 : _mesh_file(mesh_file), _fparser(fparser), _read_vtk(read_vtk), _use_cuda(use_cuda)
31 : : {
32 [ + + ]: 756 : if (read_vtk) {
33 [ + - ]: 546 : VTKMeshReader R;
34 [ + - ][ + - ]: 273 : R.filename(mesh_file);
35 [ + - ]: 273 : R.read();
36 [ + - ]: 273 : _mesh = R.mesh();
37 : : }
38 : : else {
39 [ + - ]: 966 : TIMOSMeshReader R;
40 [ + - ][ + - ]: 483 : R.filename(mesh_file);
41 [ + - ]: 483 : R.read();
42 [ + - ]: 483 : _mesh = R.mesh();
43 : : }
44 : :
45 [ + - ]: 756 : create_material_set();
46 [ + - ]: 756 : read_parameters();
47 : :
48 [ - + ]: 756 : if (use_cuda && !USE_CUDA) {
49 [ # # ]: 0 : fprintf(stderr, "\033[1;%dmWrapperFullMonteSW::CUDA not supported. Exiting...\033[0m\n", 31);
50 : 0 : std::exit(-1);
51 : : }
52 : 756 : _kernel = nullptr;
53 : :
54 : : #if USE_CUDA
55 : : _kernel_cuda = nullptr;
56 : : if (!use_cuda) {
57 : : _kernel = new TetraVolumeKernel();
58 : : _kernel->geometry(_mesh);
59 : : _kernel->materials(_materials);
60 : :
61 : : _kernel->roulettePrWin(_roulette_pr_win);
62 : : _kernel->rouletteWMin(_roulette_w_min);
63 : : _kernel->maxSteps(_max_steps);
64 : : _kernel->maxHits(_max_hits);
65 : : _kernel->packetCount(1000000);
66 : : _kernel->threadCount(MAX_THREAD_COUNT);
67 : : _kernel->randSeed(_rand_seed);
68 : : _EVF.kernel(_kernel);
69 : : } else {
70 : : _kernel_cuda = new TetraCUDAVolumeKernel();
71 : : _kernel_cuda->geometry(_mesh);
72 : : _kernel_cuda->materials(_materials);
73 : :
74 : : _kernel_cuda->roulettePrWin(_roulette_pr_win);
75 : : _kernel_cuda->rouletteWMin(_roulette_w_min);
76 : : _kernel_cuda->maxSteps(_max_steps);
77 : : _kernel_cuda->maxHits(_max_hits);
78 : : _kernel_cuda->packetCount(1000000);
79 : : _kernel_cuda->randSeed(_rand_seed);
80 : : _EVF.kernel(_kernel_cuda);
81 : : }
82 : : #else
83 [ + - ][ + - ]: 756 : _kernel = new TetraVolumeKernel();
84 [ + - ]: 756 : _kernel->geometry(_mesh);
85 [ + - ]: 756 : _kernel->materials(_materials);
86 : :
87 : 756 : _kernel->roulettePrWin(_roulette_pr_win);
88 : 756 : _kernel->rouletteWMin(_roulette_w_min);
89 : 756 : _kernel->maxSteps(_max_steps);
90 : 756 : _kernel->maxHits(_max_hits);
91 : 756 : _kernel->packetCount(1000000);
92 : 756 : _kernel->threadCount(MAX_THREAD_COUNT);
93 : 756 : _kernel->randSeed(_rand_seed);
94 [ + - ]: 756 : _EVF.kernel(_kernel);
95 : : #endif
96 : :
97 [ + - ]: 756 : _EVF.inputEnergy();
98 [ + - ]: 756 : _EVF.outputFluence();
99 : :
100 : : //_mesh_writer.mesh(_mesh);
101 : 756 : _mesh_writer = nullptr;
102 : :
103 [ + - ]: 756 : _tetraCache = new TetraLookupCache();
104 [ + - ][ + - ]: 756 : _enclosing = new TetraEnclosingPointByLinearSearch(); // TODO: update this to use rtree
105 [ + - ]: 756 : _enclosing->mesh(_mesh);
106 : 756 : }
107 : :
108 : : /**
109 : : * Runs FullMonteSW with a composite source consisting of <sources>
110 : : * @param sources [in] the sources to pass to FullMonte
111 : : * @param fluence [output] the resulting fluence vector from FullMonte
112 : : * @param dump_data_to_File [in] specifies whether to dump the results to a file or not
113 : : * @param file_name [in] if dump_data_to_file is true, specify the output file name with this parameter
114 : : * @param num_packets [in] number of packets to run
115 : : */
116 : 0 : void WrapperFullMonteSW::run_composite_fullmonte(const vector<Source::Abstract*>& sources,
117 : : vector<float>& fluence, bool dump_data_to_file, std::string file_name,
118 : : long long unsigned num_packets)
119 : : {
120 : : // _kernel->packetCount(num_packets);
121 : : //_kernel->packetCount(1000000*sources.size());
122 : 0 : Source::Composite composite_source;
123 : :
124 : : // Add all sources to the composite source
125 [ # # ]: 0 : for (auto & source : sources) {
126 [ # # ]: 0 : composite_source.add(source);
127 : : }
128 : :
129 : : OutputDataCollection* ODC;
130 : : #if USE_CUDA
131 : : if (!_use_cuda) {
132 : : start_fullmonte_async(&composite_source, num_packets);
133 : : ODC = get_fm_result();
134 : : } else {
135 : : start_fullmonte_async_cuda(&composite_source, num_packets);
136 : : ODC = get_fm_result_cuda();
137 : : }
138 : : #else
139 [ # # ]: 0 : start_fullmonte_async(&composite_source, num_packets);
140 [ # # ]: 0 : ODC = get_fm_result();
141 : : #endif
142 : : // _kernel->source(&composite_source);
143 : :
144 : : // // Running the kernel
145 : : // cout << "Async start" << endl;
146 : : // _kernel->startAsync();
147 : :
148 : : // while(!_kernel->done())
149 : : // {
150 : : // cout << "Progress: " << setw(8) << fixed << setprecision(3) << 100.0f*_kernel->progressFraction() << "%" << endl << flush;
151 : : // usleep(1000000);
152 : : // }
153 : :
154 : : // _kernel->finishAsync();
155 : : // cout << "Async Finished." << endl;
156 : :
157 : : // OutputDataCollection* ODC = _kernel->results();
158 : :
159 : : // conversion from energy to fluence
160 [ # # ][ # # ]: 0 : _EVF.data(ODC->getByName("VolumeEnergy"));
[ # # ]
161 [ # # ]: 0 : _EVF.update();
162 : :
163 [ # # ]: 0 : const OutputData* result = _EVF.result();
164 : :
165 [ # # ]: 0 : const SpatialMap<float>* sMap = dynamic_cast<const SpatialMap<float>*>(result);
166 [ # # ]: 0 : if (!sMap)
167 : : {
168 [ # # ]: 0 : fprintf(stderr, "\033[1;%dmrun_composite_fullmonte::failed to cast results....\033[0m\n", 31);
169 : 0 : std::exit(-1);
170 : : }
171 [ # # ][ # # ]: 0 : for (unsigned i = 0; i < sMap->dim(); i++)
172 : : {
173 [ # # ]: 0 : fluence.push_back(sMap->get(i));
174 : : }
175 : :
176 [ # # ]: 0 : if (dump_data_to_file)
177 : : {
178 [ # # ]: 0 : if (_mesh_writer)
179 [ # # ]: 0 : delete _mesh_writer;
180 : :
181 [ # # ][ # # ]: 0 : _mesh_writer = new VTKMeshWriter();
182 [ # # ]: 0 : _mesh_writer->mesh(_mesh);
183 : :
184 [ # # ][ # # ]: 0 : if (file_name == "") {
185 [ # # ][ # # ]: 0 : _mesh_writer->filename(_mesh_file+"_composite.vtk");
186 : : } else {
187 [ # # ][ # # ]: 0 : _mesh_writer->filename(file_name);
188 : : }
189 : :
190 : 0 : int randd = rand();
191 [ # # ]: 0 : stringstream ss;
192 [ # # ][ # # ]: 0 : ss << "Fluence_" << randd;
193 [ # # ][ # # ]: 0 : _mesh_writer->addData(ss.str().c_str(), _EVF.result());
[ # # ]
194 [ # # ]: 0 : _mesh_writer->write();
195 : : }
196 : 0 : }
197 : :
198 : : /**
199 : : * Runs the sources if FullMonteSW one at a time with unit power to generate a dose matrix
200 : : * @param sources [in] sources to run in FullMonteSW
201 : : * @param fluences [out] Results dose matrix of fluence values
202 : : * @param dump_data_to_file [in] if true, the results will be written to a file
203 : : * @param file_name [in] if dump_data_to_file is true, specify the output file name with this
204 : : * @param num_packets [in] number of packets to run
205 : : */
206 : 200 : void WrapperFullMonteSW::run_multiple_fullmonte(const vector<Source::Abstract*>& sources,
207 : : vector<vector<float>> & fluences,
208 : : bool dump_data_to_file, std::string file_name,
209 : : long long unsigned num_packets)
210 : : {
211 : :
212 : : // clear fluences
213 [ - + ]: 200 : for (unsigned i = 0; i < fluences.size(); i++)
214 : : {
215 : 0 : fluences[i].clear();
216 : 0 : fluences[i].resize(0);
217 : : }
218 : 200 : fluences.clear();
219 : 200 : fluences.resize(0);
220 : :
221 : :
222 : : // _kernel->packetCount(num_packets);
223 : 200 : unsigned idx = 0;
224 [ - + ]: 200 : if (dump_data_to_file) {
225 [ # # ]: 0 : if (_mesh_writer)
226 [ # # ]: 0 : delete _mesh_writer;
227 : :
228 [ # # ]: 0 : _mesh_writer = new VTKMeshWriter();
229 : 0 : _mesh_writer->mesh(_mesh);
230 : :
231 [ # # ]: 0 : if (file_name == "") {
232 [ # # ]: 0 : _mesh_writer->filename(_mesh_file+"_multiple.vtk");
233 : : } else {
234 [ # # ]: 0 : _mesh_writer->filename(file_name);
235 : : }
236 : : }
237 : :
238 [ + + ]: 800 : for (auto & source : sources)
239 : : {
240 [ + - ][ + - ]: 600 : cout << "Currently running source number: " << idx << endl;
[ + - ]
241 : :
242 : : OutputDataCollection* ODC;
243 : : #if USE_CUDA
244 : : if (!_use_cuda) {
245 : : start_fullmonte_async(source, num_packets);
246 : : ODC = get_fm_result();
247 : : } else {
248 : : start_fullmonte_async_cuda(source, num_packets);
249 : : ODC = get_fm_result_cuda();
250 : : }
251 : : #else
252 [ + - ]: 600 : start_fullmonte_async(source, num_packets);
253 [ + - ]: 600 : ODC = get_fm_result();
254 : : #endif
255 : : // _kernel->source(source);
256 : :
257 : : // // Running the kernel
258 : : // cout << "Async start" << endl;
259 : :
260 : : // _kernel->startAsync();
261 : :
262 : : // while(!_kernel->done())
263 : : // {
264 : : // cout << "Progress: " << setw(8) << fixed << setprecision(3) << 100.0f*_kernel->progressFraction() << "%" << endl << flush;
265 : : // usleep(1000000);
266 : : // }
267 : :
268 : : // _kernel->finishAsync();
269 : : // cout << "Async Finished." << endl;
270 : :
271 : : // OutputDataCollection* ODC = _kernel->results();
272 : :
273 : : // conversion from energy to fluence
274 [ + - ][ + - ]: 600 : _EVF.data(ODC->getByName("VolumeEnergy"));
[ + - ]
275 [ + - ]: 600 : _EVF.update();
276 : :
277 [ + - ]: 1200 : stringstream fluence_name;
278 [ + - ][ + - ]: 600 : fluence_name << "Fluence" << idx;
279 : :
280 [ + - ]: 600 : const OutputData* result = _EVF.result();
281 : :
282 [ - + ]: 600 : const SpatialMap<float>* sMap = dynamic_cast<const SpatialMap<float>*>(result);
283 [ - + ]: 600 : if (!sMap)
284 : : {
285 [ # # ]: 0 : fprintf(stderr, "\033[1;%dmrun_multiple_fullmonte::failed to cast results....\033[0m\n", 31);
286 : 0 : std::exit(-1);
287 : : }
288 : 1200 : vector<float> fluence;
289 [ + - ][ + + ]: 254026200 : for (unsigned i = 0; i < sMap->dim(); i++)
290 : : {
291 [ + - ]: 254025600 : fluence.push_back(sMap->get(i));
292 : : }
293 [ + - ]: 600 : fluences.push_back(fluence);
294 : :
295 [ - + ]: 600 : if (dump_data_to_file)
296 : : {
297 [ # # ][ # # ]: 0 : _mesh_writer->addData(fluence_name.str().c_str(), _EVF.result()->clone());
[ # # ][ # # ]
298 : : }
299 : 600 : idx++;
300 : : }
301 : :
302 [ - + ]: 200 : if (dump_data_to_file) {
303 : 0 : _mesh_writer->write();
304 : : }
305 : 200 : }
306 : :
307 : : /**
308 : : * Returns the ID of the tetra that encloses the point with the given coordinates
309 : : */
310 : 1008 : unsigned WrapperFullMonteSW::get_tetra_enclosing_point(float xcoord, float ycoord, float zcoord)
311 : : {
312 : : // create a point
313 : : const std::array<float, 3> point {
314 : : xcoord,
315 : : ycoord,
316 : : zcoord
317 : 1008 : };
318 : :
319 : 1008 : unsigned id = 0;
320 [ + - ][ + - ]: 1008 : _enclosing->point(point);
321 : :
322 : :
323 : : // search cache first
324 [ + - ]: 1008 : bool in_cache = _enclosing->searchCache(_tetraCache);
325 : :
326 [ + + ]: 1008 : if (!in_cache)
327 : : {
328 [ + - ]: 743 : _enclosing->update();
329 : : }
330 : :
331 [ + - ]: 1008 : id = _enclosing->tetra().value();
332 : :
333 [ + - ][ + - ]: 1008 : _tetraCache->update(_enclosing->tetra());
334 : :
335 : 1008 : return id;
336 : : }
337 : :
338 : : //! Returns a cloned object of the wrapper class
339 : 0 : WrapperFullMonteSW* WrapperFullMonteSW::clone() const
340 : : {
341 [ # # ][ # # ]: 0 : WrapperFullMonteSW* fm_clone = new WrapperFullMonteSW(_mesh_file, _fparser, _read_vtk, _use_cuda);
342 : 0 : return fm_clone;
343 : : }
344 : :
345 : : //! writes the mesh to a file in a .vtk format
346 : 0 : void WrapperFullMonteSW::write_mesh(string file_name)
347 : : {
348 [ # # ]: 0 : if (_mesh_writer)
349 [ # # ]: 0 : delete _mesh_writer;
350 : :
351 [ # # ]: 0 : _mesh_writer = new VTKMeshWriter();
352 : 0 : _mesh_writer->mesh(_mesh);
353 : :
354 [ # # ]: 0 : if (file_name == "") {
355 [ # # ]: 0 : _mesh_writer->filename(_mesh_file+"_out.vtk");
356 : : } else {
357 [ # # ]: 0 : _mesh_writer->filename(file_name);
358 : : }
359 : :
360 : 0 : _mesh_writer->write();
361 : 0 : }
362 : :
363 : 600 : void WrapperFullMonteSW::start_fullmonte_async(const Source::Abstract* source, long long unsigned num_packets)
364 : : {
365 : 600 : _kernel->packetCount(num_packets);
366 : :
367 : 600 : _kernel->source(source);
368 : :
369 : : // Running the kernel
370 : 600 : cout << "Async start" << endl;
371 : 600 : _kernel->startAsync();
372 : :
373 [ + + ]: 104477 : while(!_kernel->done())
374 : : {
375 : 103877 : cout << "Progress: " << setw(8) << fixed << setprecision(3) <<
376 : 207754 : 100.0f*_kernel->progressFraction() << "%" << endl << flush;
377 : 103877 : usleep(1000000);
378 : : }
379 : :
380 : 600 : _kernel->finishAsync();
381 : 600 : cout << "Async Finished." << endl;
382 : 600 : }
383 : : #if USE_CUDA
384 : : // TODO: running GPU means CPU is idle
385 : : void WrapperFullMonteSW::start_fullmonte_async_cuda(const Source::Abstract* source, long long unsigned num_packets)
386 : : {
387 : : _kernel_cuda->packetCount(num_packets);
388 : :
389 : : _kernel_cuda->source(source);
390 : :
391 : : // Running the kernel
392 : : cout << "Async start" << endl;
393 : : _kernel_cuda->startAsync();
394 : :
395 : : while(!_kernel_cuda->done())
396 : : {
397 : : cout << "Progress: " << setw(8) << fixed << setprecision(3) <<
398 : : 100.0f*_kernel_cuda->progressFraction() << "%" << endl << flush;
399 : : usleep(1000000);
400 : : }
401 : :
402 : : _kernel_cuda->finishAsync();
403 : : cout << "Async Finished." << endl;
404 : : }
405 : : #endif
406 : :
407 : 600 : OutputDataCollection* WrapperFullMonteSW::get_fm_result()
408 : : {
409 : 600 : return _kernel->results();
410 : : }
411 : : #if USE_CUDA
412 : : OutputDataCollection* WrapperFullMonteSW::get_fm_result_cuda()
413 : : {
414 : : return _kernel_cuda->results();
415 : : }
416 : : #endif
417 : :
418 : 0 : void WrapperFullMonteSW::run_multiple_fullmonte_with_detectors(const vector<Source::Abstract*>& sources,
419 : : std::vector<std::vector<float>> & detected_weights,
420 : : float detector_radius, float detector_na,
421 : : long long unsigned num_packets)
422 : : {
423 : : /**
424 : : * Go over sources one by one and launch a kernel with the others being detectors
425 : : *
426 : : */
427 : :
428 : : // _kernel->packetCount(num_packets);
429 : :
430 : 0 : detected_weights.clear();
431 : 0 : detected_weights.resize(sources.size());
432 [ # # ]: 0 : for (unsigned s = 0; s < sources.size(); s++)
433 : : {
434 [ # # ]: 0 : detected_weights[s].resize(sources.size());
435 : :
436 : 0 : Source::Composite composite_source;
437 : :
438 : : // Current source is the light source and rest are detectors (if they are only line sources)
439 [ # # ]: 0 : composite_source.add(sources[s]);
440 : :
441 [ # # ]: 0 : std::vector<Source::CylDetector *> detectors(sources.size());
442 : :
443 [ # # ]: 0 : for (unsigned j = 0; j < sources.size(); j++)
444 : : {
445 [ # # ][ # # ]: 0 : if (j == s || dynamic_cast<Source::Point*>(sources[j]) != nullptr)
[ # # ][ # # ]
446 : : {
447 : 0 : detected_weights[s][j] = 0.0f; // can't detect from self and from point sources (as they are not modeled in FullMonte)
448 : 0 : continue;
449 : : }
450 [ # # ]: 0 : Source::Line* curr_line = dynamic_cast<Source::Line*>(sources[j]);
451 : :
452 [ # # ]: 0 : detectors[j] = new Source::CylDetector();
453 : 0 : detectors[j]->endpoint(0, curr_line->endpoint(0));
454 : 0 : detectors[j]->endpoint(1, curr_line->endpoint(1));
455 [ # # ]: 0 : detectors[j]->radius(detector_radius);
456 [ # # ]: 0 : detectors[j]->numericalAperture(detector_na);
457 : :
458 [ # # ][ # # ]: 0 : detectors[j]->detectionType("ODE");
459 : :
460 [ # # ]: 0 : composite_source.add(detectors[j]);
461 : : }
462 : :
463 [ # # ]: 0 : if (!_use_cuda) {
464 [ # # ]: 0 : start_fullmonte_async(&composite_source, num_packets);
465 : : } else {
466 : : #if USE_CUDA
467 : : start_fullmonte_async_cuda(&composite_source, num_packets);
468 : : #endif
469 : : }
470 : : // _kernel->source(&composite_source);
471 : :
472 : : // // Running the kernel
473 : : // cout << "Async start" << endl;
474 : : // _kernel->startAsync();
475 : :
476 : : // while(!_kernel->done())
477 : : // {
478 : : // cout << "Progress: " << setw(8) << fixed << setprecision(3) <<
479 : : // 100.0f*_kernel->progressFraction() << "%" << endl << flush;
480 : : // usleep(1000000);
481 : : // }
482 : :
483 : : // _kernel->finishAsync();
484 : : // cout << "Async Finished." << endl;
485 : :
486 [ # # ]: 0 : for (unsigned j = 0; j < sources.size(); j++)
487 : : {
488 [ # # ][ # # ]: 0 : if (j != s && dynamic_cast<Source::Point*>(sources[j]) == nullptr)
[ # # ][ # # ]
489 : : {
490 : 0 : detected_weights[s][j] = detectors[j]->detectedWeight();
491 : :
492 [ # # ]: 0 : delete detectors[j];
493 : : }
494 : : }
495 : : }
496 : 0 : }
497 : :
498 : 756 : void WrapperFullMonteSW::create_material_set() {
499 : : bool matched_boundary;
500 [ + - ]: 1512 : const vector <Parser_material> materials = _fparser->get_materials(matched_boundary);
501 [ - + ]: 756 : if (matched_boundary) {
502 [ # # ]: 0 : fprintf(stderr, "\033[1;%dmWarning: FullMonte may not support matched boundary correctly.\033[0m\n", 33);
503 : : }
504 : :
505 [ - + ][ # # ]: 756 : if (_materials) delete _materials;
506 : :
507 [ + - ][ + - ]: 756 : _materials = new MaterialSet();
508 [ + - ]: 756 : _materials->resize((unsigned) materials.size());
509 [ + - ]: 756 : _materials->matchedBoundary(matched_boundary);
510 : :
511 [ + + ]: 5292 : for (const auto& m : materials) {
512 [ + - ][ + - ]: 4536 : Material* p = new Material();
513 : :
514 [ + - ]: 4536 : p->scatteringCoeff((float) m.mu_s);
515 [ + - ]: 4536 : p->absorptionCoeff((float) m.mu_a);
516 [ + - ]: 4536 : p->anisotropy((float) m.g);
517 [ + - ]: 4536 : p->refractiveIndex((float) m.n);
518 : :
519 [ + - ]: 4536 : _materials->set(m.id, p);
520 : : }
521 : 756 : }
522 : :
523 : 756 : void WrapperFullMonteSW::read_parameters() {
524 [ + - ][ + - ]: 1512 : unordered_map <string, string> parameters_map = _fparser->get_fm_params();
525 : :
526 [ + - ][ + - ]: 756 : if (parameters_map.find("use_cuda") != parameters_map.end()) {
[ + - ]
527 [ + - ][ + - ]: 756 : _use_cuda = (parameters_map["use_cuda"] == "true");
[ + - ]
528 : : } else {
529 : 0 : _use_cuda = false; // Default power allocation value / 10
530 : : }
531 : :
532 [ + - ][ + - ]: 756 : if (parameters_map.find("max_hits") != parameters_map.end()) {
[ + - ]
533 [ + - ][ + - ]: 756 : _max_hits = atoi(parameters_map["max_hits"].c_str());
534 : : } else {
535 : 0 : _max_hits = 1000;
536 : : }
537 : :
538 [ + - ][ + - ]: 756 : if (parameters_map.find("roulette_pr_win") != parameters_map.end()) {
[ + - ]
539 [ + - ][ + - ]: 756 : _roulette_pr_win = (float) atof(parameters_map["roulette_pr_win"].c_str());
540 : : } else {
541 : 0 : _roulette_pr_win = 0.1f;
542 : : }
543 : :
544 [ + - ][ + - ]: 756 : if (parameters_map.find("roulette_w_min") != parameters_map.end()) {
[ + - ]
545 [ + - ][ + - ]: 756 : _roulette_w_min = (float) atof(parameters_map["roulette_w_min"].c_str());
546 : : } else {
547 : 0 : _roulette_w_min = 0.00001f;
548 : : }
549 : :
550 [ + - ][ + - ]: 756 : if (parameters_map.find("max_steps") != parameters_map.end()) {
[ + - ]
551 [ + - ][ + - ]: 756 : _max_steps = atoi(parameters_map["max_steps"].c_str());
552 : : } else {
553 : 0 : _max_steps = 100000;
554 : : }
555 : :
556 [ + - ][ + - ]: 756 : if (parameters_map.find("rand_seed") != parameters_map.end()) {
[ + - ]
557 [ + - ][ + - ]: 756 : _rand_seed = atoi(parameters_map["rand_seed"].c_str());
558 : : } else {
559 : 0 : _rand_seed = 2;
560 : : }
561 [ + - ][ + - ]: 840 : }
|