Bertini 2 - C++ Core
Software for Numerical Algebraic Geometry
Loading...
Searching...
No Matches
algorithm.hpp
Go to the documentation of this file.
1//This file is part of Bertini 2.
2//
3//bertini2/io/parsing/settings_parsers/algorithm.hpp is free software: you can redistribute it and/or modify
4//it under the terms of the GNU General Public License as published by
5//the Free Software Foundation, either version 3 of the License, or
6//(at your option) any later version.
7//
8//bertini2/io/parsing/settings_parsers/algorithm.hpp is distributed in the hope that it will be useful,
9//but WITHOUT ANY WARRANTY; without even the implied warranty of
10//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11//GNU General Public License for more details.
12//
13//You should have received a copy of the GNU General Public License
14//along with bertini2/io/parsing/settings_parsers/algorithm.hpp. If not, see <http://www.gnu.org/licenses/>.
15//
16// Copyright(C) 2015 - 2017 by Bertini2 Development Team
17//
18// See <http://www.gnu.org/licenses/> for a copy of the license,
19// as well as COPYING. Bertini2 is provided with permitted
20// additional terms in the b2/licenses/ directory.
21
22
28
29#pragma once
30
31
33#include "bertini2/nag_algorithms/common/config.hpp"
34
35namespace bertini {
36 namespace parsing {
37 namespace classic {
38
39
40
44 template<typename Iterator, typename Skipper>
45 struct ConfigSettingParser<Iterator, algorithm::TolerancesConfig, Skipper> : qi::grammar<Iterator, algorithm::TolerancesConfig(), Skipper>
46 {
47 using T = double;
48
49 ConfigSettingParser() : ConfigSettingParser::base_type(root_rule_, "config::TolerancesType")
50 {
51 namespace phx = boost::phoenix;
52 using qi::_1;
53 using qi::_2;
54 using qi::_3;
55 using qi::_4;
56 using qi::_val;
57 using qi::eps;
58 using qi::lit;
59 using qi::char_;
60 using qi::omit;
61 using boost::spirit::lexeme;
62 using boost::spirit::as_string;
63 using boost::spirit::ascii::no_case;
64
65
66
67 std::string newton_before_name = "tracktolbeforeeg";
68 std::string newton_during_name = "tracktolduringeg";
69 std::string final_tol_name = "finaltol";
70 std::string path_trunc_name = "pathtruncationthreshold";
71
72
73 root_rule_.name("config::Tolerances");
74
75 root_rule_ = ((newton_before_endgame_[phx::bind( [this](algorithm::TolerancesConfig & S, T l)
76 {
77 S.newton_before_endgame = l;
78 }, _val, _1 )]
79 ^ newton_during_endgame_[phx::bind( [this](algorithm::TolerancesConfig & S, T num)
80 {
81 S.newton_during_endgame = num;
82 }, _val, _1 )]
83 ^ final_tol_[phx::bind( [this](algorithm::TolerancesConfig & S, T num)
84 {
85 S.final_tolerance = num;
86 }, _val, _1 )]
87 ^ path_trunc_threshold_[phx::bind( [this](algorithm::TolerancesConfig & S, T num)
88 {
89 S.path_truncation_threshold = num;
90 }, _val, _1 )])
91
92 >> -no_setting_)
93 | no_setting_;
94
95
96 all_names_ = (no_case[newton_before_name] >> ':') | (no_case[newton_during_name] >> ':')| (no_case[final_tol_name] >> ':')
97 | (no_case[path_trunc_name] >> ':');
98
99 newton_before_endgame_.name("newton_before_endgame_");
100 newton_before_endgame_ = *(char_ - all_names_) >> (no_case[newton_before_name] >> ':')
101 >> mpfr_rules.number_string_[phx::bind( [this](T & num, std::string str)
102 {
103 num = bertini::NumTraits<T>::FromString(str);
104 }, _val, _1 )] >> ';';
105
106 newton_during_endgame_.name("newton_during_endgame_");
107 newton_during_endgame_ = *(char_ - all_names_) >> (no_case[newton_during_name] >>':')
108 >> mpfr_rules.number_string_[phx::bind( [this](T & num, std::string str)
109 {
110 num = bertini::NumTraits<T>::FromString(str);
111 }, _val, _1 )] >> ';';
112
113 final_tol_.name("final_tol_");
114 final_tol_ = *(char_ - all_names_) >> (no_case[final_tol_name] >> ':')
115 >> mpfr_rules.number_string_[phx::bind( [this](T & num, std::string str)
116 {
117 num = bertini::NumTraits<T>::FromString(str);
118 }, _val, _1 )] >> ';';
119
120 path_trunc_threshold_.name("path_trunc_threshold_");
121 path_trunc_threshold_ = *(char_ - all_names_) >> (no_case[path_trunc_name] >> ':')
122 >> mpfr_rules.number_string_[phx::bind( [this](T & num, std::string str)
123 {
124 num = bertini::NumTraits<T>::FromString(str);
125 }, _val, _1 )] >> ';';
126
127 no_setting_.name("no_setting_");
128 no_setting_ = *(char_ - all_names_);
129
130 no_decl_.name("no_decl_");
131 no_decl_ = *(char_);
132
133
134
135
136
137 using phx::val;
138 using phx::construct;
139 using namespace qi::labels;
140 qi::on_error<qi::fail>
141 ( root_rule_ ,
142 std::cout<<
143 val("config parser could not complete parsing. Expecting ")<<
144 _4<<
145 val(" here: ")<<
146 construct<std::string>(_3,_2)<<
147 std::endl
148 );
149
150
151
152 }
153
154
155 private:
156 qi::rule<Iterator, algorithm::TolerancesConfig(), ascii::space_type > root_rule_;
157 qi::rule<Iterator, T(), ascii::space_type > newton_before_endgame_, newton_during_endgame_,
158 final_tol_, path_trunc_threshold_;
159 qi::rule<Iterator, ascii::space_type, std::string()> no_decl_, no_setting_, all_names_;
160 rules::LongNum<Iterator> mpfr_rules;
161
162
163
164 }; //re: Tolerances
165
166
167
168
169
170
171
172
173
174 template<typename Iterator, typename ComplexT, typename Skipper>
175 struct ConfigSettingParser<Iterator, algorithm::ZeroDimConfig<ComplexT>, Skipper> : qi::grammar<Iterator, algorithm::ZeroDimConfig<ComplexT>(), Skipper>
176 {
177
178 ConfigSettingParser() : ConfigSettingParser::base_type(root_rule_, "algorithm::ZeroDimConfig")
179 {
180 namespace phx = boost::phoenix;
181 using qi::_1;
182 using qi::_2;
183 using qi::_3;
184 using qi::_4;
185 using qi::_val;
186 using qi::eps;
187 using qi::lit;
188 using qi::char_;
189 using qi::omit;
190 using boost::spirit::lexeme;
191 using boost::spirit::as_string;
192 using boost::spirit::ascii::no_case;
193
194
195
196 std::string init_prec_name = "initialprec";
197 std::string max_cross_resolve_name = "maxcrossedpathresolves";
198 std::string start_time_name = "starttime";
199 std::string endgame_boundary_name = "endgamebdry";
200 std::string target_time_name = "targettime";
201 std::string path_variable_name_name = "pathvarname";
202
203
204 root_rule_.name("config::ZeroDim");
205
206 root_rule_ = ((init_prec_[phx::bind( [this](algorithm::ZeroDimConfig<ComplexT> & S, int num)
207 {
208 S.initial_ambient_precision = num;
209 }, _val, _1 )]
210 ^ path_variable_name_[phx::bind( [this](algorithm::ZeroDimConfig<ComplexT> & S, std::string omnom)
211 {
212 S.path_variable_name = omnom;
213 }, _val, _1 )]
214 ^ max_cross_resolve_[phx::bind( [this](algorithm::ZeroDimConfig<ComplexT> & S, int num)
215 {
216 S.max_num_crossed_path_resolve_attempts = num;
217 }, _val, _1 )]
218 ^ start_time_[phx::bind( [this](algorithm::ZeroDimConfig<ComplexT> & S, ComplexT num)
219 {
220 S.start_time = num;
221 }, _val, _1 )]
222 ^ endgame_boundary_[phx::bind( [this](algorithm::ZeroDimConfig<ComplexT> & S, ComplexT num)
223 {
224 S.endgame_boundary = num;
225 }, _val, _1 )]
226 ^ target_time_[phx::bind( [this](algorithm::ZeroDimConfig<ComplexT> & S, ComplexT num)
227 {
228 S.target_time = num;
229 }, _val, _1 )]
230 )
231 >> -no_setting_) | no_setting_;
232
233 all_names_ = (no_case[init_prec_name] >> ':') |
234 (no_case[target_time_name] >> ':') |
235 (no_case[path_variable_name_name] >> ':') |
236 (no_case[max_cross_resolve_name] >> ':') |
237 (no_case[start_time_name] >> ':') |
238 (no_case[endgame_boundary_name] >> ':')
239 ;
240
241
242 auto str_to_ComplexT = [this](ComplexT & num, std::string str)
243 {
244 num = bertini::NumTraits<ComplexT>::FromString(str);
245 };
246
247
248
249 valid_variable_name_.name("valid_variable_name_");
250 valid_variable_name_ = +qi::alpha >> *(qi::alnum | qi::char_("[]_") );
251
252
253 path_variable_name_.name("path_variable_name_");
254 path_variable_name_ = *(char_ - all_names_) >> (no_case[path_variable_name_name] >> ':') >> valid_variable_name_ >> ';';
255
256 init_prec_.name("init_prec_");
257 init_prec_ = *(char_ - all_names_) >> (no_case[init_prec_name] >> ':') >> qi::int_[_val=_1] >> ';';
258
259 max_cross_resolve_.name("max_cross_resolve_");
260 max_cross_resolve_ = *(char_ - all_names_) >> (no_case[max_cross_resolve_name] >> ':') >> qi::int_[_val=_1] >> ';';
261
262 start_time_.name("start_time_");
263 start_time_ = *(char_ - all_names_) >> (no_case[start_time_name] >> ':')
264 >> mpfr_rules.number_string_[phx::bind( str_to_ComplexT, _val, _1 )] >> ';';
265
266 endgame_boundary_.name("endgame_boundary_");
267 endgame_boundary_ = *(char_ - all_names_) >> (no_case[endgame_boundary_name] >> ':')
268 >> mpfr_rules.number_string_[phx::bind( str_to_ComplexT, _val, _1 )] >> ';';
269
270 target_time_.name("target_time_");
271 target_time_ = *(char_ - all_names_) >> (no_case[target_time_name] >> ':')
272 >> mpfr_rules.number_string_[phx::bind( str_to_ComplexT, _val, _1 )] >> ';';
273
274
275
276 no_setting_.name("no_setting_");
277 no_setting_ = *(char_ - all_names_);
278
279 no_decl_.name("no_decl_");
280 no_decl_ = *(char_);
281
282
283
284
285 using phx::val;
286 using phx::construct;
287 using namespace qi::labels;
288 qi::on_error<qi::fail>
289 ( root_rule_ ,
290 std::cout<<
291 val("config parser could not complete parsing. Expecting ")<<
292 _4<<
293 val(" here: ")<<
294 construct<std::string>(_3,_2)<<
295 std::endl
296 );
297
298
299
300 }
301
302
303 private:
304 qi::rule<Iterator, algorithm::ZeroDimConfig<ComplexT>(), ascii::space_type > root_rule_;
305
306 qi::rule<Iterator, ComplexT(), ascii::space_type > start_time_, target_time_, endgame_boundary_;
307 qi::rule<Iterator, int(), ascii::space_type > init_prec_, max_cross_resolve_;
308 qi::rule<Iterator, std::string(), ascii::space_type > valid_variable_name_, path_variable_name_;
309
310
311 qi::rule<Iterator, ascii::space_type, std::string()> no_decl_, no_setting_, all_names_;
312 rules::LongNum<Iterator> mpfr_rules;
313
314
315
316 }; //re: ZeroDim
317
318 template<typename Iterator, typename Skipper>
319 struct ConfigSettingParser<Iterator, algorithm::MidPathConfig, Skipper> : qi::grammar<Iterator, algorithm::MidPathConfig(), Skipper>
320 {
321 using T = double;
322
323 ConfigSettingParser() : ConfigSettingParser::base_type(root_rule_, "config::MidPath")
324 {
325 namespace phx = boost::phoenix;
326 using qi::_1;
327 using qi::_2;
328 using qi::_3;
329 using qi::_4;
330 using qi::_val;
331 using qi::eps;
332 using qi::lit;
333 using qi::char_;
334 using qi::omit;
335 using boost::spirit::lexeme;
336 using boost::spirit::as_string;
337 using boost::spirit::ascii::no_case;
338
339
340
341 std::string same_point_tol_name = "midpathtol";
342
343
344 root_rule_.name("config::MidPath");
345
346 root_rule_ = ((same_point_tol_[phx::bind( [this](algorithm::MidPathConfig & S, T num)
347 {
348 S.same_point_tolerance = num;
349 }, _val, _1 )]
350 )
351 >> -no_setting_) | no_setting_;
352
353 all_names_ = (no_case[same_point_tol_name] >> ':');
354
355 auto str_to_T = [this](T & num, std::string str)
356 {
357 num = bertini::NumTraits<T>::FromString(str);
358 };
359
360
361 same_point_tol_.name("same_point_tol_");
362 same_point_tol_ = *(char_ - all_names_) >> (no_case[same_point_tol_name] >> ':')
363 >> mpfr_rules.number_string_[phx::bind( str_to_T, _val, _1 )] >> ';';
364
365
366 no_setting_.name("no_setting_");
367 no_setting_ = *(char_ - all_names_);
368
369 no_decl_.name("no_decl_");
370 no_decl_ = *(char_);
371
372
373
374
375 using phx::val;
376 using phx::construct;
377 using namespace qi::labels;
378 qi::on_error<qi::fail>
379 ( root_rule_ ,
380 std::cout<<
381 val("config parser could not complete parsing. Expecting ")<<
382 _4<<
383 val(" here: ")<<
384 construct<std::string>(_3,_2)<<
385 std::endl
386 );
387
388
389
390 }
391
392
393 private:
394 qi::rule<Iterator, algorithm::MidPathConfig(), ascii::space_type > root_rule_;
395 qi::rule<Iterator, T(), ascii::space_type > same_point_tol_;
396 qi::rule<Iterator, ascii::space_type, std::string()> no_decl_, no_setting_, all_names_;
397 rules::LongNum<Iterator> mpfr_rules;
398
399 }; //re: MidPath
400
401
402 template<typename Iterator, typename Skipper>
403 struct ConfigSettingParser<Iterator, algorithm::AutoRetrackConfig, Skipper> : qi::grammar<Iterator, algorithm::AutoRetrackConfig(), Skipper>
404 {
405 using T = double;
406
407 ConfigSettingParser() : ConfigSettingParser::base_type(root_rule_, "config::AutoRetrack")
408 {
409 namespace phx = boost::phoenix;
410 using qi::_1;
411 using qi::_2;
412 using qi::_3;
413 using qi::_4;
414 using qi::_val;
415 using qi::eps;
416 using qi::lit;
417 using qi::char_;
418 using qi::omit;
419 using boost::spirit::lexeme;
420 using boost::spirit::as_string;
421 using boost::spirit::ascii::no_case;
422
423
424
425 std::string decrease_factor_name = "retracktolfactor";
426
427
428 root_rule_.name("config::AutoRetrack");
429
430 root_rule_ = ((decrease_factor[phx::bind( [this](algorithm::AutoRetrackConfig & S, T num)
431 {
432 S.midpath_decrease_tolerance_factor = num;
433 }, _val, _1 )]
434 )
435 >> -no_setting_) | no_setting_;
436
437 all_names_ = (no_case[decrease_factor_name] >> ':');
438
439 auto str_to_T = [this](T & num, std::string str)
440 {
441 num = bertini::NumTraits<T>::FromString(str);
442 };
443
444
445 decrease_factor.name("decrease_factor");
446 decrease_factor = *(char_ - all_names_) >> (no_case[decrease_factor_name] >> ':')
447 >> mpfr_rules.number_string_[phx::bind( str_to_T, _val, _1 )] >> ';';
448
449
450 no_setting_.name("no_setting_");
451 no_setting_ = *(char_ - all_names_);
452
453 no_decl_.name("no_decl_");
454 no_decl_ = *(char_);
455
456
457
458
459 using phx::val;
460 using phx::construct;
461 using namespace qi::labels;
462 qi::on_error<qi::fail>
463 ( root_rule_ ,
464 std::cout<<
465 val("config parser could not complete parsing. Expecting ")<<
466 _4<<
467 val(" here: ")<<
468 construct<std::string>(_3,_2)<<
469 std::endl
470 );
471
472
473
474 }
475
476
477 private:
478 qi::rule<Iterator, algorithm::AutoRetrackConfig(), ascii::space_type > root_rule_;
479 qi::rule<Iterator, T(), ascii::space_type > decrease_factor;
480 qi::rule<Iterator, ascii::space_type, std::string()> no_decl_, no_setting_, all_names_;
481 rules::LongNum<Iterator> mpfr_rules;
482
483 }; //re: AutoRetrack
484
485
486 template<typename Iterator, typename Skipper>
487 struct ConfigSettingParser<Iterator, algorithm::SharpeningConfig, Skipper> : qi::grammar<Iterator, algorithm::SharpeningConfig(), Skipper>
488 {
489 using T = double;
490
491 ConfigSettingParser() : ConfigSettingParser::base_type(root_rule_, "algorithm::config::Sharpening")
492 {
493 namespace phx = boost::phoenix;
494 using qi::_1;
495 using qi::_2;
496 using qi::_3;
497 using qi::_4;
498 using qi::_val;
499 using qi::eps;
500 using qi::lit;
501 using qi::char_;
502 using qi::omit;
503 using boost::spirit::lexeme;
504 using boost::spirit::as_string;
505 using boost::spirit::ascii::no_case;
506
507
508
509 std::string sharpen_digits_name = "sharpendigits";
510 std::string func_res_tol_name = "functiontolerance";
511 std::string ratio_tol_name = "ratiotolerance";
512
513
514 root_rule_.name("config::Sharpening");
515
516 root_rule_ = ((sharpen_digits_[phx::bind( [this](algorithm::SharpeningConfig & S, unsigned num)
517 {
518 S.sharpendigits = num;
519 }, _val, _1 )]
520 ^ func_res_tol_[phx::bind( [this](algorithm::SharpeningConfig & S, T num)
521 {
522 S.function_residual_tolerance = num;
523 }, _val, _1 )]
524 ^ ratio_tol_[phx::bind( [this](algorithm::SharpeningConfig & S, T num)
525 {
526 S.ratio_tolerance = num;
527 }, _val, _1 )]
528 )
529 >> -no_setting_) | no_setting_;
530
531 all_names_ = (no_case[sharpen_digits_name] >> ':') |
532 (no_case[func_res_tol_name] >> ':') |
533 (no_case[ratio_tol_name] >> ':')
534 ;
535
536
537 auto str_to_T = [this](T & num, std::string str)
538 {
539 num = bertini::NumTraits<T>::FromString(str);
540 };
541
542
543 func_res_tol_.name("func_res_tol_");
544 func_res_tol_ = *(char_ - all_names_) >> (no_case[func_res_tol_name] >> ':')
545 >> mpfr_rules.number_string_[phx::bind( str_to_T, _val, _1 )] >> ';';
546
547 ratio_tol_.name("ratio_tol_");
548 ratio_tol_ = *(char_ - all_names_) >> (no_case[ratio_tol_name] >> ':')
549 >> mpfr_rules.number_string_[phx::bind( str_to_T, _val, _1 )] >> ';';
550
551 sharpen_digits_.name("sharpen_digits_");
552 sharpen_digits_ = *(char_ - all_names_) >> (no_case[sharpen_digits_name] >> ':') >> qi::uint_[_val=_1] >> ';';
553
554
555
556 no_setting_.name("no_setting_");
557 no_setting_ = *(char_ - all_names_);
558
559 no_decl_.name("no_decl_");
560 no_decl_ = *(char_);
561
562
563
564
565 using phx::val;
566 using phx::construct;
567 using namespace qi::labels;
568 qi::on_error<qi::fail>
569 ( root_rule_ ,
570 std::cout<<
571 val("config parser could not complete parsing. Expecting ")<<
572 _4<<
573 val(" here: ")<<
574 construct<std::string>(_3,_2)<<
575 std::endl
576 );
577
578
579
580 }
581
582
583 private:
584 qi::rule<Iterator, algorithm::SharpeningConfig(), ascii::space_type > root_rule_;
585
586 qi::rule<Iterator, T(), ascii::space_type > func_res_tol_, ratio_tol_;
587 qi::rule<Iterator, unsigned int(), ascii::space_type > sharpen_digits_;
588
589 qi::rule<Iterator, ascii::space_type, std::string()> no_decl_, no_setting_, all_names_;
590 rules::LongNum<Iterator> mpfr_rules;
591
592
593
594 }; //re: Sharpening
595
596 template<typename Iterator, typename Skipper>
597 struct ConfigSettingParser<Iterator, algorithm::RegenerationConfig, Skipper> : qi::grammar<Iterator, algorithm::RegenerationConfig(), Skipper>
598 {
599 using T = double;
600
601 ConfigSettingParser() : ConfigSettingParser::base_type(root_rule_, "algorithm::config::Regeneration")
602 {
603 namespace phx = boost::phoenix;
604 using qi::_1;
605 using qi::_2;
606 using qi::_3;
607 using qi::_4;
608 using qi::_val;
609 using qi::eps;
610 using qi::lit;
611 using qi::char_;
612 using qi::omit;
613 using boost::spirit::lexeme;
614 using boost::spirit::as_string;
615 using boost::spirit::ascii::no_case;
616
617
618
619 std::string regen_remove_inf_name = "regenremoveinf";
620 std::string slice_before_name = "slicetolbeforeeg";
621 std::string slice_during_name = "slicetolduringeg";
622 std::string slice_final_name = "slicefinaltol";
623 std::string higher_dim_check_name = "regenhigherdimtest";
624 std::string start_level_name = "regenstartlevel";
625
626
627 root_rule_.name("config::Regeneration");
628
629 root_rule_ = ((regen_remove_inf_[phx::bind( [this](algorithm::RegenerationConfig & S, int num)
630 {
631 S.remove_infinite_endpoints = static_cast<bool>(num);
632 }, _val, _1 )]
633 ^ higher_dim_check_[phx::bind( [this](algorithm::RegenerationConfig & S, int num)
634 {
635 S.higher_dimension_check = static_cast<bool>(num);
636 }, _val, _1 )]
637 ^ start_level_[phx::bind( [this](algorithm::RegenerationConfig & S, int num)
638 {
639 S.start_level = num;
640 }, _val, _1 )]
641 ^ slice_before_[phx::bind( [this](algorithm::RegenerationConfig & S, T num)
642 {
643 S.newton_before_endgame = num;
644 }, _val, _1 )]
645 ^ slice_during_[phx::bind( [this](algorithm::RegenerationConfig & S, T num)
646 {
647 S.newton_during_endgame = num;
648 }, _val, _1 )]
649 ^ slice_final_[phx::bind( [this](algorithm::RegenerationConfig & S, T num)
650 {
651 S.final_tolerance = num;
652 }, _val, _1 )]
653 )
654 >> -no_setting_) | no_setting_;
655
656 all_names_ = (no_case[regen_remove_inf_name] >> ':') |
657 (no_case[higher_dim_check_name] >> ':') |
658 (no_case[start_level_name] >> ':') |
659 (no_case[slice_before_name] >> ':') |
660 (no_case[slice_during_name] >> ':') |
661 (no_case[slice_final_name] >> ':')
662 ;
663
664
665 auto str_to_T = [this](T & num, std::string str)
666 {
667 num = bertini::NumTraits<T>::FromString(str);
668 };
669
670
671 higher_dim_check_.name("higher_dim_check_");
672 higher_dim_check_ = *(char_ - all_names_) >> (no_case[higher_dim_check_name] >> ':') >> qi::int_[_val=_1] >> ';';
673
674 start_level_.name("start_level_");
675 start_level_ = *(char_ - all_names_) >> (no_case[start_level_name] >> ':') >> qi::int_[_val=_1] >> ';';
676
677 regen_remove_inf_.name("regen_remove_inf_");
678 regen_remove_inf_ = *(char_ - all_names_) >> (no_case[regen_remove_inf_name] >> ':') >> qi::int_[_val=_1] >> ';';
679
680
681
682 slice_before_.name("slice_before_");
683 slice_before_ = *(char_ - all_names_) >> (no_case[slice_before_name] >> ':')
684 >> mpfr_rules.number_string_[phx::bind( str_to_T, _val, _1 )] >> ';';
685
686 slice_during_.name("slice_during_");
687 slice_during_ = *(char_ - all_names_) >> (no_case[slice_during_name] >> ':')
688 >> mpfr_rules.number_string_[phx::bind( str_to_T, _val, _1 )] >> ';';
689
690 slice_final_.name("slice_final_");
691 slice_final_ = *(char_ - all_names_) >> (no_case[slice_final_name] >> ':')
692 >> mpfr_rules.number_string_[phx::bind( str_to_T, _val, _1 )] >> ';';
693
694
695
696 no_setting_.name("no_setting_");
697 no_setting_ = *(char_ - all_names_);
698
699 no_decl_.name("no_decl_");
700 no_decl_ = *(char_);
701
702
703
704
705 using phx::val;
706 using phx::construct;
707 using namespace qi::labels;
708 qi::on_error<qi::fail>
709 ( root_rule_ ,
710 std::cout<<
711 val("config parser could not complete parsing. Expecting ")<<
712 _4<<
713 val(" here: ")<<
714 construct<std::string>(_3,_2)<<
715 std::endl
716 );
717
718
719
720 }
721
722
723 private:
724 qi::rule<Iterator, algorithm::RegenerationConfig(), ascii::space_type > root_rule_;
725
726 qi::rule<Iterator, T(), ascii::space_type > slice_before_, slice_during_, slice_final_;
727 qi::rule<Iterator, int(), ascii::space_type > regen_remove_inf_, start_level_, higher_dim_check_;
728
729 qi::rule<Iterator, ascii::space_type, std::string()> no_decl_, no_setting_, all_names_;
730 rules::LongNum<Iterator> mpfr_rules;
731
732
733
734 }; //re: Regeneration
735
736
737 template<typename Iterator, typename Skipper>
738 struct ConfigSettingParser<Iterator, algorithm::PostProcessingConfig, Skipper> : qi::grammar<Iterator, algorithm::PostProcessingConfig(), Skipper>
739 {
740 using T = double;
741
742 ConfigSettingParser() : ConfigSettingParser::base_type(root_rule_, "algorithm::PostProcessingConfig")
743 {
744 namespace phx = boost::phoenix;
745 using qi::_1;
746 using qi::_2;
747 using qi::_3;
748 using qi::_4;
749 using qi::_val;
750 using qi::eps;
751 using qi::lit;
752 using qi::char_;
753 using qi::omit;
754 using boost::spirit::lexeme;
755 using boost::spirit::as_string;
756 using boost::spirit::ascii::no_case;
757
758
759
760 std::string real_thresh_name = "imagthreshold";
761 std::string endpoint_finite_name = "endpointfinitethreshold";
762 std::string same_point_name = "endpointsamethreshold";
763
764
765
766 root_rule_.name("config::PostProcessing");
767
768 root_rule_ = ((real_threshold_[phx::bind( [this](algorithm::PostProcessingConfig & S, T num)
769 {
770 S.real_threshold = num;
771 }, _val, _1 )]
772 ^ endpoint_finite_[phx::bind( [this](algorithm::PostProcessingConfig & S, T num)
773 {
774 S.endpoint_finite_threshold = num;
775 }, _val, _1 )]
776 ^ same_point_[phx::bind( [this](algorithm::PostProcessingConfig & S, T num)
777 {
778 S.same_point_tolerance = num;
779 }, _val, _1 )]
780 )
781 >> -no_setting_) | no_setting_;
782
783 all_names_ = (no_case[real_thresh_name] >> ':') |
784 (no_case[endpoint_finite_name] >> ':') |
785 (no_case[same_point_name] >> ':')
786 ;
787
788
789 auto str_to_T = [this](T & num, std::string str)
790 {
791 num = bertini::NumTraits<T>::FromString(str);
792 };
793
794 real_threshold_.name("real_thresh_");
795 real_threshold_ = *(char_ - all_names_) >> (no_case[real_thresh_name] >> ':')
796 >> mpfr_rules.number_string_[phx::bind( str_to_T, _val, _1 )] >> ';';
797
798 endpoint_finite_.name("endpoint_finite_");
799 endpoint_finite_ = *(char_ - all_names_) >> (no_case[endpoint_finite_name] >> ':')
800 >> mpfr_rules.number_string_[phx::bind( str_to_T, _val, _1 )] >> ';';
801
802 same_point_.name("same_point_");
803 same_point_ = *(char_ - all_names_) >> (no_case[same_point_name] >> ':')
804 >> mpfr_rules.number_string_[phx::bind( str_to_T, _val, _1 )] >> ';';
805
806
807
808 no_setting_.name("no_setting_");
809 no_setting_ = *(char_ - all_names_);
810
811 no_decl_.name("no_decl_");
812 no_decl_ = *(char_);
813
814
815
816
817 using phx::val;
818 using phx::construct;
819 using namespace qi::labels;
820 qi::on_error<qi::fail>
821 ( root_rule_ ,
822 std::cout<<
823 val("config parser could not complete parsing. Expecting ")<<
824 _4<<
825 val(" here: ")<<
826 construct<std::string>(_3,_2)<<
827 std::endl
828 );
829
830
831
832 }
833
834
835 private:
836 qi::rule<Iterator, algorithm::PostProcessingConfig(), ascii::space_type > root_rule_;
837
838 qi::rule<Iterator, T(), ascii::space_type > real_threshold_, endpoint_finite_, same_point_;
839
840 qi::rule<Iterator, ascii::space_type, std::string()> no_decl_, no_setting_, all_names_;
841 rules::LongNum<Iterator> mpfr_rules;
842
843
844
845 }; //re: PostProcessing
846
847
848
849 template<typename Iterator, typename Skipper> //boost::spirit::unused_type
850 struct ConfigSettingParser<Iterator, algorithm::classic::AlgoChoice, Skipper> : qi::grammar<Iterator, algorithm::classic::AlgoChoice(), Skipper>
851 {
852 using T = double;
853
854 ConfigSettingParser() : ConfigSettingParser::base_type(root_rule_, "config::classic::AlgoChoice")
855 {
856 namespace phx = boost::phoenix;
857 using qi::_1;
858 using qi::_2;
859 using qi::_3;
860 using qi::_4;
861 using qi::_val;
862 using qi::eps;
863 using qi::lit;
864 using qi::char_;
865 using qi::omit;
866 using boost::spirit::lexeme;
867 using boost::spirit::as_string;
868 using boost::spirit::ascii::no_case;
869
870 tracktype_.add("-4", algorithm::classic::AlgoChoice::EvalFunctions);
871 tracktype_.add("-3", algorithm::classic::AlgoChoice::EvalFunctionJacobian);
872 tracktype_.add("-2", algorithm::classic::AlgoChoice::NewtonIteration);
873 tracktype_.add("-1", algorithm::classic::AlgoChoice::NewtonIterationCondNum);
874 tracktype_.add("0", algorithm::classic::AlgoChoice::ZeroDim);
875 tracktype_.add("1", algorithm::classic::AlgoChoice::NID);
876 tracktype_.add("2", algorithm::classic::AlgoChoice::SampleComponent);
877 tracktype_.add("3", algorithm::classic::AlgoChoice::MembershipTest);
878 tracktype_.add("4", algorithm::classic::AlgoChoice::ExtractWitnessSet);
879 tracktype_.add("5", algorithm::classic::AlgoChoice::WitnessSetProjection);
880 tracktype_.add("6", algorithm::classic::AlgoChoice::IsosingularStab);
881
882 std::string setting_name = "tracktype";
883
884
885 root_rule_.name("config::classic::AlgoChoice");
886
887 root_rule_ = config_name_[_val = _1] >> -no_setting_
888 | no_setting_[_val = algorithm::classic::AlgoChoice::ZeroDim];
889
890 config_name_.name("tracktype_");
891 config_name_ = *(char_ - (no_case[setting_name] >> ':')) >> (no_case[setting_name] >> ':') >> tracktype_[_val = _1] >> ';';
892
893 no_setting_.name("no_setting_");
894 no_setting_ = *(char_ - no_case[setting_name]);
895
896 no_decl_.name("no_decl_");
897 no_decl_ = *(char_);
898
899
900
901
902 using phx::val;
903 using phx::construct;
904 using namespace qi::labels;
905 qi::on_error<qi::fail>
906 ( root_rule_ ,
907 std::cout<<
908 val("config parser could not complete parsing. Expecting ")<<
909 _4<<
910 val(" here: ")<<
911 construct<std::string>(_3,_2)<<
912 std::endl
913 );
914
915
916
917 }
918
919
920 private:
921 qi::rule<Iterator, algorithm::classic::AlgoChoice(), ascii::space_type > root_rule_, config_name_;
922 qi::rule<Iterator, ascii::space_type, std::string()> no_decl_, no_setting_;
923
924 qi::symbols<char,algorithm::classic::AlgoChoice> tracktype_;
925
926
927 }; //re: Meta
928
929
930
931 } // re: namespace classic
932
933 }// re: namespace parsing
934}// re: namespace bertini
Provides the base type for config settings parsers.