Bertini 2 d882924 (2026-10-06 19:56 UTC)
Numerical algebraic geometry library (C++ core)
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) 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
34
35namespace bertini {
36 namespace parsing {
37 namespace classic {
38
39
40
44 template<typename Iterator, typename Skipper>
46 struct ConfigSettingParser<Iterator, algorithm::TolerancesConfig, Skipper> : qi::grammar<Iterator, algorithm::TolerancesConfig(), Skipper>
47 {
48 using T = double;
49
50 ConfigSettingParser() : ConfigSettingParser::base_type(root_rule_, "config::TolerancesType")
51 {
52 namespace phx = boost::phoenix;
53 using qi::_1;
54 using qi::_2;
55 using qi::_3;
56 using qi::_4;
57 using qi::_val;
58 using qi::eps;
59 using qi::lit;
60 using qi::char_;
61 using qi::omit;
62 using boost::spirit::lexeme;
63 using boost::spirit::as_string;
64 using boost::spirit::ascii::no_case;
65
66
67
68 std::string newton_before_name = "tracktolbeforeeg";
69 std::string newton_during_name = "tracktolduringeg";
70
71
72 root_rule_.name("config::Tolerances");
73
74 root_rule_ = ((newton_before_endgame_[phx::bind( [](algorithm::TolerancesConfig & S, T l)
75 {
77 }, _val, _1 )]
78 ^ newton_during_endgame_[phx::bind( [](algorithm::TolerancesConfig & S, T num)
79 {
81 }, _val, _1 )])
82
83 >> -no_setting_)
84 | no_setting_;
85
86
87 all_names_ = (no_case[newton_before_name] >> ':') | (no_case[newton_during_name] >> ':');
88
89 newton_before_endgame_.name("newton_before_endgame_");
90 newton_before_endgame_ = *(char_ - all_names_) >> (no_case[newton_before_name] >> ':')
91 >> mpfr_rules.number_string_[phx::bind( [](T & num, std::string str)
92 {
94 }, _val, _1 )] >> ';';
95
96 newton_during_endgame_.name("newton_during_endgame_");
97 newton_during_endgame_ = *(char_ - all_names_) >> (no_case[newton_during_name] >>':')
98 >> mpfr_rules.number_string_[phx::bind( [](T & num, std::string str)
99 {
101 }, _val, _1 )] >> ';';
102
103 no_setting_.name("no_setting_");
104 no_setting_ = *(char_ - all_names_);
105
106 no_decl_.name("no_decl_");
107 no_decl_ = *(char_);
108
109
110
111
112
113 qi::on_error<qi::fail>(
114 root_rule_,
115 phx::bind(&ReportParseError, _1, _2, _3, _4, std::string("config::Tolerances"))
116 );
117
118
119
120 }
121
122
123 private:
124 qi::rule<Iterator, algorithm::TolerancesConfig(), ascii::space_type > root_rule_;
125 qi::rule<Iterator, T(), ascii::space_type > newton_before_endgame_, newton_during_endgame_;
126 qi::rule<Iterator, ascii::space_type, std::string()> no_decl_, no_setting_, all_names_;
127 rules::LongNum<Iterator> mpfr_rules;
128
129
130
131 }; //re: Tolerances
132
133
134
135
136
137
138
139
140
141 template<typename Iterator, typename Skipper>
143 struct ConfigSettingParser<Iterator, algorithm::ZeroDimConfig, Skipper> : qi::grammar<Iterator, algorithm::ZeroDimConfig(), Skipper>
144 {
145
146 ConfigSettingParser() : ConfigSettingParser::base_type(root_rule_, "algorithm::ZeroDimConfig")
147 {
148 namespace phx = boost::phoenix;
149 using qi::_1;
150 using qi::_2;
151 using qi::_3;
152 using qi::_4;
153 using qi::_val;
154 using qi::eps;
155 using qi::lit;
156 using qi::char_;
157 using qi::omit;
158 using boost::spirit::lexeme;
159 using boost::spirit::as_string;
160 using boost::spirit::ascii::no_case;
161
162
163
164 std::string init_prec_name = "initialprec";
165 std::string max_cross_resolve_name = "maxcrossedpathresolves";
166 std::string start_time_name = "starttime";
167 std::string endgame_boundary_name = "endgamebdry";
168 std::string target_time_name = "targettime";
169 std::string path_variable_name_name = "pathvarname";
170
171
172 root_rule_.name("config::ZeroDim");
173
174 root_rule_ = ((init_prec_[phx::bind( [](algorithm::ZeroDimConfig & S, int num)
175 {
176 S.initial_ambient_precision = static_cast<unsigned int>(num);
177 }, _val, _1 )]
178 ^ path_variable_name_[phx::bind( [](algorithm::ZeroDimConfig & S, std::string omnom)
179 {
180 S.path_variable_name = omnom;
181 }, _val, _1 )]
182 ^ max_cross_resolve_[phx::bind( [](algorithm::ZeroDimConfig & S, int num)
183 {
184 S.max_num_crossed_path_resolve_attempts = static_cast<unsigned int>(num);
185 }, _val, _1 )]
186 ^ start_time_[phx::bind( [](algorithm::ZeroDimConfig & S, mpq_rational num)
187 {
188 S.start_time = num;
189 }, _val, _1 )]
190 ^ endgame_boundary_[phx::bind( [](algorithm::ZeroDimConfig & S, mpq_rational num)
191 {
192 S.endgame_boundary = num;
193 }, _val, _1 )]
194 ^ target_time_[phx::bind( [](algorithm::ZeroDimConfig & S, mpq_rational num)
195 {
196 S.target_time = num;
197 }, _val, _1 )]
198 )
199 >> -no_setting_) | no_setting_;
200
201 all_names_ = (no_case[init_prec_name] >> ':') |
202 (no_case[target_time_name] >> ':') |
203 (no_case[path_variable_name_name] >> ':') |
204 (no_case[max_cross_resolve_name] >> ':') |
205 (no_case[start_time_name] >> ':') |
206 (no_case[endgame_boundary_name] >> ':')
207 ;
208
209
210 // The times are stored as exact, precision-free mpq_rational. Parse the number
211 // string to a multiprecision real, then to a rational (the homotopy times are real).
212 auto str_to_rational = [](mpq_rational & num, std::string str)
213 {
214 num = mpq_rational(real_mp(str));
215 };
216
217
218
219 // UTF-8 identifier (same policy as the system parser): a Unicode
220 // letter start, then Unicode alphanumerics or [ ] _ . The parser
221 // is self-contained (never sub-skips inside the identifier), so no
222 // lexeme is needed even on this skippered rule. See
223 // io/parsing/unicode_ident.hpp.
224 valid_variable_name_.name("valid_variable_name_");
225 valid_variable_name_ = utf8_identifier_parser();
226
227
228 path_variable_name_.name("path_variable_name_");
229 path_variable_name_ = *(char_ - all_names_) >> (no_case[path_variable_name_name] >> ':') >> valid_variable_name_ >> ';';
230
231 init_prec_.name("init_prec_");
232 init_prec_ = *(char_ - all_names_) >> (no_case[init_prec_name] >> ':') >> qi::int_[_val=_1] >> ';';
233
234 max_cross_resolve_.name("max_cross_resolve_");
235 max_cross_resolve_ = *(char_ - all_names_) >> (no_case[max_cross_resolve_name] >> ':') >> qi::int_[_val=_1] >> ';';
236
237 start_time_.name("start_time_");
238 start_time_ = *(char_ - all_names_) >> (no_case[start_time_name] >> ':')
239 >> mpfr_rules.number_string_[phx::bind( str_to_rational, _val, _1 )] >> ';';
240
241 endgame_boundary_.name("endgame_boundary_");
242 endgame_boundary_ = *(char_ - all_names_) >> (no_case[endgame_boundary_name] >> ':')
243 >> mpfr_rules.number_string_[phx::bind( str_to_rational, _val, _1 )] >> ';';
244
245 target_time_.name("target_time_");
246 target_time_ = *(char_ - all_names_) >> (no_case[target_time_name] >> ':')
247 >> mpfr_rules.number_string_[phx::bind( str_to_rational, _val, _1 )] >> ';';
248
249
250
251 no_setting_.name("no_setting_");
252 no_setting_ = *(char_ - all_names_);
253
254 no_decl_.name("no_decl_");
255 no_decl_ = *(char_);
256
257
258
259
260 qi::on_error<qi::fail>(
261 root_rule_,
262 phx::bind(&ReportParseError, _1, _2, _3, _4, std::string("config::ZeroDim"))
263 );
264
265
266
267 }
268
269
270 private:
271 qi::rule<Iterator, algorithm::ZeroDimConfig(), ascii::space_type > root_rule_;
272
273 qi::rule<Iterator, mpq_rational(), ascii::space_type > start_time_, target_time_, endgame_boundary_;
274 qi::rule<Iterator, int(), ascii::space_type > init_prec_, max_cross_resolve_;
275 qi::rule<Iterator, std::string(), ascii::space_type > valid_variable_name_, path_variable_name_;
276
277
278 qi::rule<Iterator, ascii::space_type, std::string()> no_decl_, no_setting_, all_names_;
279 rules::LongNum<Iterator> mpfr_rules;
280
281
282
283 }; //re: ZeroDim
284
285 template<typename Iterator, typename Skipper>
287 struct ConfigSettingParser<Iterator, algorithm::MidPathConfig, Skipper> : qi::grammar<Iterator, algorithm::MidPathConfig(), Skipper>
288 {
289 using T = double;
290
291 ConfigSettingParser() : ConfigSettingParser::base_type(root_rule_, "config::MidPath")
292 {
293 namespace phx = boost::phoenix;
294 using qi::_1;
295 using qi::_2;
296 using qi::_3;
297 using qi::_4;
298 using qi::_val;
299 using qi::eps;
300 using qi::lit;
301 using qi::char_;
302 using qi::omit;
303 using boost::spirit::lexeme;
304 using boost::spirit::as_string;
305 using boost::spirit::ascii::no_case;
306
307
308
309 std::string same_point_tol_name = "midpathtol";
310
311
312 root_rule_.name("config::MidPath");
313
314 root_rule_ = ((same_point_tol_[phx::bind( [](algorithm::MidPathConfig & S, T num)
315 {
316 S.same_point_tolerance = num;
317 }, _val, _1 )]
318 )
319 >> -no_setting_) | no_setting_;
320
321 all_names_ = (no_case[same_point_tol_name] >> ':');
322
323 auto str_to_T = [](T & num, std::string str)
324 {
326 };
327
328
329 same_point_tol_.name("same_point_tol_");
330 same_point_tol_ = *(char_ - all_names_) >> (no_case[same_point_tol_name] >> ':')
331 >> mpfr_rules.number_string_[phx::bind( str_to_T, _val, _1 )] >> ';';
332
333
334 no_setting_.name("no_setting_");
335 no_setting_ = *(char_ - all_names_);
336
337 no_decl_.name("no_decl_");
338 no_decl_ = *(char_);
339
340
341
342
343 qi::on_error<qi::fail>(
344 root_rule_,
345 phx::bind(&ReportParseError, _1, _2, _3, _4, std::string("config::MidPath"))
346 );
347
348
349
350 }
351
352
353 private:
354 qi::rule<Iterator, algorithm::MidPathConfig(), ascii::space_type > root_rule_;
355 qi::rule<Iterator, T(), ascii::space_type > same_point_tol_;
356 qi::rule<Iterator, ascii::space_type, std::string()> no_decl_, no_setting_, all_names_;
357 rules::LongNum<Iterator> mpfr_rules;
358
359 }; //re: MidPath
360
361
362 template<typename Iterator, typename Skipper>
364 struct ConfigSettingParser<Iterator, algorithm::RecordsConfig, Skipper> : qi::grammar<Iterator, algorithm::RecordsConfig(), Skipper>
365 {
366 ConfigSettingParser() : ConfigSettingParser::base_type(root_rule_, "config::Records")
367 {
368 namespace phx = boost::phoenix;
369 using qi::_1;
370 using qi::_val;
371 using qi::char_;
372 root_rule_.name("config::Records");
373 // swallow the text; the semantic action keeps Spirit from trying to fill the
374 // struct with it, and leaves _val at its defaults
375 root_rule_ = (*char_)[phx::bind([](algorithm::RecordsConfig&, std::vector<char> const&){}, _val, _1)];
376 }
377
378 private:
379 qi::rule<Iterator, algorithm::RecordsConfig(), ascii::space_type > root_rule_;
380 };
381
382
383 template<typename Iterator, typename Skipper>
385 struct ConfigSettingParser<Iterator, algorithm::AutoRetrackConfig, Skipper> : qi::grammar<Iterator, algorithm::AutoRetrackConfig(), Skipper>
386 {
387 using T = double;
388
389 ConfigSettingParser() : ConfigSettingParser::base_type(root_rule_, "config::AutoRetrack")
390 {
391 namespace phx = boost::phoenix;
392 using qi::_1;
393 using qi::_2;
394 using qi::_3;
395 using qi::_4;
396 using qi::_val;
397 using qi::eps;
398 using qi::lit;
399 using qi::char_;
400 using qi::omit;
401 using boost::spirit::lexeme;
402 using boost::spirit::as_string;
403 using boost::spirit::ascii::no_case;
404
405
406
407 std::string decrease_factor_name = "retracktolfactor";
408
409
410 root_rule_.name("config::AutoRetrack");
411
412 root_rule_ = ((decrease_factor[phx::bind( [](algorithm::AutoRetrackConfig & S, T num)
413 {
415 }, _val, _1 )]
416 )
417 >> -no_setting_) | no_setting_;
418
419 all_names_ = (no_case[decrease_factor_name] >> ':');
420
421 auto str_to_T = [](T & num, std::string str)
422 {
424 };
425
426
427 decrease_factor.name("decrease_factor");
428 decrease_factor = *(char_ - all_names_) >> (no_case[decrease_factor_name] >> ':')
429 >> mpfr_rules.number_string_[phx::bind( str_to_T, _val, _1 )] >> ';';
430
431
432 no_setting_.name("no_setting_");
433 no_setting_ = *(char_ - all_names_);
434
435 no_decl_.name("no_decl_");
436 no_decl_ = *(char_);
437
438
439
440
441 qi::on_error<qi::fail>(
442 root_rule_,
443 phx::bind(&ReportParseError, _1, _2, _3, _4, std::string("config::AutoRetrack"))
444 );
445
446
447
448 }
449
450
451 private:
452 qi::rule<Iterator, algorithm::AutoRetrackConfig(), ascii::space_type > root_rule_;
453 qi::rule<Iterator, T(), ascii::space_type > decrease_factor;
454 qi::rule<Iterator, ascii::space_type, std::string()> no_decl_, no_setting_, all_names_;
455 rules::LongNum<Iterator> mpfr_rules;
456
457 }; //re: AutoRetrack
458
459
460 template<typename Iterator, typename Skipper>
462 struct ConfigSettingParser<Iterator, algorithm::SharpeningConfig, Skipper> : qi::grammar<Iterator, algorithm::SharpeningConfig(), Skipper>
463 {
464 using T = double;
465
466 ConfigSettingParser() : ConfigSettingParser::base_type(root_rule_, "algorithm::config::Sharpening")
467 {
468 namespace phx = boost::phoenix;
469 using qi::_1;
470 using qi::_2;
471 using qi::_3;
472 using qi::_4;
473 using qi::_val;
474 using qi::eps;
475 using qi::lit;
476 using qi::char_;
477 using qi::omit;
478 using boost::spirit::lexeme;
479 using boost::spirit::as_string;
480 using boost::spirit::ascii::no_case;
481
482
483
484 std::string sharpen_digits_name = "sharpendigits";
485 std::string func_res_tol_name = "functiontolerance";
486 std::string ratio_tol_name = "ratiotolerance";
487
488
489 root_rule_.name("config::Sharpening");
490
491 root_rule_ = ((sharpen_digits_[phx::bind( [](algorithm::SharpeningConfig & S, unsigned num)
492 {
493 S.sharpendigits = num;
494 }, _val, _1 )]
495 ^ func_res_tol_[phx::bind( [](algorithm::SharpeningConfig & S, T num)
496 {
498 }, _val, _1 )]
499 ^ ratio_tol_[phx::bind( [](algorithm::SharpeningConfig & S, T num)
500 {
501 S.ratio_tolerance = num;
502 }, _val, _1 )]
503 )
504 >> -no_setting_) | no_setting_;
505
506 all_names_ = (no_case[sharpen_digits_name] >> ':') |
507 (no_case[func_res_tol_name] >> ':') |
508 (no_case[ratio_tol_name] >> ':')
509 ;
510
511
512 auto str_to_T = [](T & num, std::string str)
513 {
515 };
516
517
518 func_res_tol_.name("func_res_tol_");
519 func_res_tol_ = *(char_ - all_names_) >> (no_case[func_res_tol_name] >> ':')
520 >> mpfr_rules.number_string_[phx::bind( str_to_T, _val, _1 )] >> ';';
521
522 ratio_tol_.name("ratio_tol_");
523 ratio_tol_ = *(char_ - all_names_) >> (no_case[ratio_tol_name] >> ':')
524 >> mpfr_rules.number_string_[phx::bind( str_to_T, _val, _1 )] >> ';';
525
526 sharpen_digits_.name("sharpen_digits_");
527 sharpen_digits_ = *(char_ - all_names_) >> (no_case[sharpen_digits_name] >> ':') >> qi::uint_[_val=_1] >> ';';
528
529
530
531 no_setting_.name("no_setting_");
532 no_setting_ = *(char_ - all_names_);
533
534 no_decl_.name("no_decl_");
535 no_decl_ = *(char_);
536
537
538
539
540 qi::on_error<qi::fail>(
541 root_rule_,
542 phx::bind(&ReportParseError, _1, _2, _3, _4, std::string("config::Sharpening"))
543 );
544
545
546
547 }
548
549
550 private:
551 qi::rule<Iterator, algorithm::SharpeningConfig(), ascii::space_type > root_rule_;
552
553 qi::rule<Iterator, T(), ascii::space_type > func_res_tol_, ratio_tol_;
554 qi::rule<Iterator, unsigned int(), ascii::space_type > sharpen_digits_;
555
556 qi::rule<Iterator, ascii::space_type, std::string()> no_decl_, no_setting_, all_names_;
557 rules::LongNum<Iterator> mpfr_rules;
558
559
560
561 }; //re: Sharpening
562
563 template<typename Iterator, typename Skipper>
565 struct ConfigSettingParser<Iterator, algorithm::RegenerationConfig, Skipper> : qi::grammar<Iterator, algorithm::RegenerationConfig(), Skipper>
566 {
567 using T = double;
568
569 ConfigSettingParser() : ConfigSettingParser::base_type(root_rule_, "algorithm::config::Regeneration")
570 {
571 namespace phx = boost::phoenix;
572 using qi::_1;
573 using qi::_2;
574 using qi::_3;
575 using qi::_4;
576 using qi::_val;
577 using qi::eps;
578 using qi::lit;
579 using qi::char_;
580 using qi::omit;
581 using boost::spirit::lexeme;
582 using boost::spirit::as_string;
583 using boost::spirit::ascii::no_case;
584
585
586
587 std::string regen_remove_inf_name = "regenremoveinf";
588 std::string slice_before_name = "slicetolbeforeeg";
589 std::string slice_during_name = "slicetolduringeg";
590 std::string slice_final_name = "slicefinaltol";
591 std::string higher_dim_check_name = "regenhigherdimtest";
592 std::string start_level_name = "regenstartlevel";
593
594
595 root_rule_.name("config::Regeneration");
596
597 root_rule_ = ((regen_remove_inf_[phx::bind( [](algorithm::RegenerationConfig & S, int num)
598 {
599 S.remove_infinite_endpoints = static_cast<bool>(num);
600 }, _val, _1 )]
601 ^ higher_dim_check_[phx::bind( [](algorithm::RegenerationConfig & S, int num)
602 {
603 S.higher_dimension_check = static_cast<bool>(num);
604 }, _val, _1 )]
605 ^ start_level_[phx::bind( [](algorithm::RegenerationConfig & S, int num)
606 {
607 S.start_level = static_cast<unsigned int>(num);
608 }, _val, _1 )]
609 ^ slice_before_[phx::bind( [](algorithm::RegenerationConfig & S, T num)
610 {
612 }, _val, _1 )]
613 ^ slice_during_[phx::bind( [](algorithm::RegenerationConfig & S, T num)
614 {
616 }, _val, _1 )]
617 ^ slice_final_[phx::bind( [](algorithm::RegenerationConfig & S, T num)
618 {
619 S.slice_final_tolerance = num;
620 }, _val, _1 )]
621 )
622 >> -no_setting_) | no_setting_;
623
624 all_names_ = (no_case[regen_remove_inf_name] >> ':') |
625 (no_case[higher_dim_check_name] >> ':') |
626 (no_case[start_level_name] >> ':') |
627 (no_case[slice_before_name] >> ':') |
628 (no_case[slice_during_name] >> ':') |
629 (no_case[slice_final_name] >> ':')
630 ;
631
632
633 auto str_to_T = [](T & num, std::string str)
634 {
636 };
637
638
639 higher_dim_check_.name("higher_dim_check_");
640 higher_dim_check_ = *(char_ - all_names_) >> (no_case[higher_dim_check_name] >> ':') >> qi::int_[_val=_1] >> ';';
641
642 start_level_.name("start_level_");
643 start_level_ = *(char_ - all_names_) >> (no_case[start_level_name] >> ':') >> qi::int_[_val=_1] >> ';';
644
645 regen_remove_inf_.name("regen_remove_inf_");
646 regen_remove_inf_ = *(char_ - all_names_) >> (no_case[regen_remove_inf_name] >> ':') >> qi::int_[_val=_1] >> ';';
647
648
649
650 slice_before_.name("slice_before_");
651 slice_before_ = *(char_ - all_names_) >> (no_case[slice_before_name] >> ':')
652 >> mpfr_rules.number_string_[phx::bind( str_to_T, _val, _1 )] >> ';';
653
654 slice_during_.name("slice_during_");
655 slice_during_ = *(char_ - all_names_) >> (no_case[slice_during_name] >> ':')
656 >> mpfr_rules.number_string_[phx::bind( str_to_T, _val, _1 )] >> ';';
657
658 slice_final_.name("slice_final_");
659 slice_final_ = *(char_ - all_names_) >> (no_case[slice_final_name] >> ':')
660 >> mpfr_rules.number_string_[phx::bind( str_to_T, _val, _1 )] >> ';';
661
662
663
664 no_setting_.name("no_setting_");
665 no_setting_ = *(char_ - all_names_);
666
667 no_decl_.name("no_decl_");
668 no_decl_ = *(char_);
669
670
671
672
673 qi::on_error<qi::fail>(
674 root_rule_,
675 phx::bind(&ReportParseError, _1, _2, _3, _4, std::string("config::Regeneration"))
676 );
677
678
679
680 }
681
682
683 private:
684 qi::rule<Iterator, algorithm::RegenerationConfig(), ascii::space_type > root_rule_;
685
686 qi::rule<Iterator, T(), ascii::space_type > slice_before_, slice_during_, slice_final_;
687 qi::rule<Iterator, int(), ascii::space_type > regen_remove_inf_, start_level_, higher_dim_check_;
688
689 qi::rule<Iterator, ascii::space_type, std::string()> no_decl_, no_setting_, all_names_;
690 rules::LongNum<Iterator> mpfr_rules;
691
692
693
694 }; //re: Regeneration
695
696
697 template<typename Iterator, typename Skipper>
699 struct ConfigSettingParser<Iterator, algorithm::PostProcessingConfig, Skipper> : qi::grammar<Iterator, algorithm::PostProcessingConfig(), Skipper>
700 {
701 using T = double;
702
703 ConfigSettingParser() : ConfigSettingParser::base_type(root_rule_, "algorithm::PostProcessingConfig")
704 {
705 namespace phx = boost::phoenix;
706 using qi::_1;
707 using qi::_2;
708 using qi::_3;
709 using qi::_4;
710 using qi::_val;
711 using qi::eps;
712 using qi::lit;
713 using qi::char_;
714 using qi::omit;
715 using boost::spirit::lexeme;
716 using boost::spirit::as_string;
717 using boost::spirit::ascii::no_case;
718
719
720
721 std::string real_thresh_name = "imagthreshold";
722 std::string endpoint_finite_name = "endpointfinitethreshold";
723 std::string same_point_name = "endpointsamethreshold";
724 std::string cond_num_name = "condnumthreshold";
725
726
727
728 root_rule_.name("config::PostProcessing");
729
730 root_rule_ = ((real_threshold_[phx::bind( [](algorithm::PostProcessingConfig & S, T num)
731 {
732 S.real_threshold = num;
733 }, _val, _1 )]
734 ^ endpoint_finite_[phx::bind( [](algorithm::PostProcessingConfig & S, T num)
735 {
737 }, _val, _1 )]
738 ^ same_point_[phx::bind( [](algorithm::PostProcessingConfig & S, T num)
739 {
741 }, _val, _1 )]
742 ^ cond_num_[phx::bind( [](algorithm::PostProcessingConfig & S, T num)
743 {
745 }, _val, _1 )]
746 )
747 >> -no_setting_) | no_setting_;
748
749 all_names_ = (no_case[real_thresh_name] >> ':') |
750 (no_case[endpoint_finite_name] >> ':') |
751 (no_case[same_point_name] >> ':') |
752 (no_case[cond_num_name] >> ':')
753 ;
754
755
756 auto str_to_T = [](T & num, std::string str)
757 {
759 };
760
761 real_threshold_.name("real_thresh_");
762 real_threshold_ = *(char_ - all_names_) >> (no_case[real_thresh_name] >> ':')
763 >> mpfr_rules.number_string_[phx::bind( str_to_T, _val, _1 )] >> ';';
764
765 endpoint_finite_.name("endpoint_finite_");
766 endpoint_finite_ = *(char_ - all_names_) >> (no_case[endpoint_finite_name] >> ':')
767 >> mpfr_rules.number_string_[phx::bind( str_to_T, _val, _1 )] >> ';';
768
769 same_point_.name("same_point_");
770 same_point_ = *(char_ - all_names_) >> (no_case[same_point_name] >> ':')
771 >> mpfr_rules.number_string_[phx::bind( str_to_T, _val, _1 )] >> ';';
772
773 cond_num_.name("cond_num_");
774 cond_num_ = *(char_ - all_names_) >> (no_case[cond_num_name] >> ':')
775 >> mpfr_rules.number_string_[phx::bind( str_to_T, _val, _1 )] >> ';';
776
777
778
779 no_setting_.name("no_setting_");
780 no_setting_ = *(char_ - all_names_);
781
782 no_decl_.name("no_decl_");
783 no_decl_ = *(char_);
784
785
786
787
788 qi::on_error<qi::fail>(
789 root_rule_,
790 phx::bind(&ReportParseError, _1, _2, _3, _4, std::string("config::PostProcessing"))
791 );
792
793
794
795 }
796
797
798 private:
799 qi::rule<Iterator, algorithm::PostProcessingConfig(), ascii::space_type > root_rule_;
800
801 qi::rule<Iterator, T(), ascii::space_type > real_threshold_, endpoint_finite_, same_point_, cond_num_;
802
803 qi::rule<Iterator, ascii::space_type, std::string()> no_decl_, no_setting_, all_names_;
804 rules::LongNum<Iterator> mpfr_rules;
805
806
807
808 }; //re: PostProcessing
809
810
811
812 template<typename Iterator, typename Skipper> //boost::spirit::unused_type
814 struct ConfigSettingParser<Iterator, algorithm::classic::AlgoChoice, Skipper> : qi::grammar<Iterator, algorithm::classic::AlgoChoice(), Skipper>
815 {
816 using T = double;
817
818 ConfigSettingParser() : ConfigSettingParser::base_type(root_rule_, "config::classic::AlgoChoice")
819 {
820 namespace phx = boost::phoenix;
821 using qi::_1;
822 using qi::_2;
823 using qi::_3;
824 using qi::_4;
825 using qi::_val;
826 using qi::eps;
827 using qi::lit;
828 using qi::char_;
829 using qi::omit;
830 using boost::spirit::lexeme;
831 using boost::spirit::as_string;
832 using boost::spirit::ascii::no_case;
833
838 tracktype_.add("0", algorithm::classic::AlgoChoice::ZeroDim);
839 tracktype_.add("1", algorithm::classic::AlgoChoice::NID);
845
846 std::string setting_name = "tracktype";
847
848
849 root_rule_.name("config::classic::AlgoChoice");
850
851 root_rule_ = config_name_[_val = _1] >> -no_setting_
852 | no_setting_[_val = algorithm::classic::AlgoChoice::ZeroDim];
853
854 config_name_.name("tracktype_");
855 config_name_ = *(char_ - (no_case[setting_name] >> ':')) >> (no_case[setting_name] >> ':') >> tracktype_[_val = _1] >> ';';
856
857 no_setting_.name("no_setting_");
858 no_setting_ = *(char_ - no_case[setting_name]);
859
860 no_decl_.name("no_decl_");
861 no_decl_ = *(char_);
862
863
864
865
866 qi::on_error<qi::fail>(
867 root_rule_,
868 phx::bind(&ReportParseError, _1, _2, _3, _4, std::string("config::classic::AlgoChoice"))
869 );
870
871
872
873 }
874
875
876 private:
877 qi::rule<Iterator, algorithm::classic::AlgoChoice(), ascii::space_type > root_rule_, config_name_;
878 qi::rule<Iterator, ascii::space_type, std::string()> no_decl_, no_setting_;
879
880 qi::symbols<char,algorithm::classic::AlgoChoice> tracktype_;
881
882
883 }; //re: Meta
884
885
886
887 template<typename Iterator, typename Skipper>
889 struct ConfigSettingParser<Iterator, algorithm::classic::EndgameChoiceConfig, Skipper> : qi::grammar<Iterator, algorithm::classic::EndgameChoiceConfig(), Skipper>
890 {
891 ConfigSettingParser() : ConfigSettingParser::base_type(root_rule_, "config::classic::EndgameChoiceConfig")
892 {
893 namespace phx = boost::phoenix;
894 using qi::_1;
895 using qi::_2;
896 using qi::_3;
897 using qi::_4;
898 using qi::_val;
899 using qi::char_;
900 using boost::spirit::ascii::no_case;
901
902 // Bertini1: endgamenum: 1=PSEG (the DEFAULT, per the Bertini 1 manual; ADR-0058), 2=Cauchy
903 endgamechoice_.add("1", algorithm::classic::EndgameChoice::PowerSeries);
904 endgamechoice_.add("2", algorithm::classic::EndgameChoice::Cauchy);
905
906 std::string setting_name = "endgamenum";
907
908 // enum_rule_ parses the setting and returns the EndgameChoice enum value
909 enum_rule_.name("endgamechoice_");
910 enum_rule_ = *(char_ - (no_case[setting_name] >> ':')) >> (no_case[setting_name] >> ':') >> endgamechoice_[_val = _1] >> ';';
911
912 root_rule_.name("config::classic::EndgameChoiceConfig");
913
914 root_rule_ = enum_rule_[phx::bind([](algorithm::classic::EndgameChoiceConfig& cfg,
916 cfg.endgame = c;
917 }, _val, _1)]
918 >> -no_setting_
919 | no_setting_; // no endgamenum → default (PowerSeries, matching Bertini 1)
920
921 no_setting_.name("no_setting_");
922 no_setting_ = *(char_ - no_case[setting_name]);
923
924 no_decl_.name("no_decl_");
925 no_decl_ = *(char_);
926
927 qi::on_error<qi::fail>(
928 root_rule_,
929 phx::bind(&ReportParseError, _1, _2, _3, _4, std::string("config::classic::EndgameChoiceConfig"))
930 );
931 }
932
933 private:
934 qi::rule<Iterator, algorithm::classic::EndgameChoiceConfig(), ascii::space_type > root_rule_;
935 qi::rule<Iterator, algorithm::classic::EndgameChoice(), ascii::space_type > enum_rule_;
936 qi::rule<Iterator, ascii::space_type, std::string()> no_decl_, no_setting_;
937
938 qi::symbols<char, algorithm::classic::EndgameChoice> endgamechoice_;
939
940 }; //re: EndgameChoiceConfig
941
942
943 } // re: namespace classic
944
945 }// re: namespace parsing
946}// re: namespace bertini
Provides the base type for config settings parsers.
AlgoChoice
Definition config.hpp:49
@ IsosingularStab
Definition config.hpp:60
@ NewtonIteration
Definition config.hpp:52
@ MembershipTest
Definition config.hpp:57
@ ZeroDim
Definition config.hpp:54
@ WitnessSetProjection
Definition config.hpp:59
@ NewtonIterationCondNum
Definition config.hpp:53
@ SampleComponent
Definition config.hpp:56
@ EvalFunctions
Definition config.hpp:50
@ ExtractWitnessSet
Definition config.hpp:58
@ EvalFunctionJacobian
Definition config.hpp:51
EndgameChoice
Definition config.hpp:37
@ PowerSeries
Definition config.hpp:38
Definition algorithm_base.hpp:34
Definition classic_utilities.hpp:41
void ReportParseError(std::string::const_iterator begin, std::string::const_iterator end, std::string::const_iterator err_pos, boost::spirit::info const &what, std::string const &parser_name)
Report a parse error (via FormatParseError) to the log, for use in a Spirit on_error handler.
Definition qi_files.hpp:199
Definition classic_utilities.hpp:40
Definition algorithm_builder.hpp:36
boost::multiprecision::number< boost::multiprecision::mpfr_float_backend< 0 >, boost::multiprecision::et_on > real_mp
The arbitrary-precision real number type.
Definition mpfr_extensions.hpp:53
boost::multiprecision::number< boost::multiprecision::backends::gmp_rational, boost::multiprecision::et_on > mpq_rational
The exact rational number type.
Definition mpfr_extensions.hpp:55
Numeric traits for a bertini number type: digit counts, conversions, and companion types.
Definition num_traits.hpp:57
Configuration for auto-retracking paths flagged as crossed.
Definition config.hpp:90
T midpath_decrease_tolerance_factor
Factor by which tracking tolerances are tightened when re-tracking a crossed path.
Definition config.hpp:93
Configuration for the midpath (path-crossing) check.
Definition config.hpp:80
T same_point_tolerance
Two boundary points are "the same" if within this tolerance.
Definition config.hpp:83
Configuration for post-processing solutions (reality/finiteness/singularity classification).
Definition config.hpp:140
T endpoint_finite_threshold
Bertini 1's EndpointFiniteThreshold. An endpoint is considered to be at infinity if the infinity norm...
Definition config.hpp:145
T real_threshold
Bertini 1's ImagThreshold. Threshold on the imaginary part of a (dehomogenized) solution coordinate b...
Definition config.hpp:143
T condition_number_threshold
Bertini 1's CondNumThreshold. An endpoint is considered singular if it is the endpoint of multiple pa...
Definition config.hpp:149
T same_point_tolerance_multiplier
Bertini 1's EndpointSameThreshold. A multiplier (>= 1) on final_tolerance: two endpoints are consider...
Definition config.hpp:147
How a recording algorithm uses the records it finds: not what to compute, but what already-recorded w...
Definition config.hpp:197
Configuration for the regeneration cascade.
Definition config.hpp:116
unsigned start_level
The regeneration level to start from.
Definition config.hpp:122
bool remove_infinite_endpoints
Bool indicating whether endpoints during the regeneration start point buildup step which are infinite...
Definition config.hpp:119
T slice_newton_before_endgame
Slice-moving tracking tolerance before the endgame. SliceTolBeforeEG.
Definition config.hpp:132
T slice_newton_during_endgame
Slice-moving tracking tolerance during the endgame. SliceTolDuringEG.
Definition config.hpp:133
T slice_final_tolerance
Final tolerance to track the slice move to, using the endgame. SliceFinalTol.
Definition config.hpp:134
bool higher_dimension_check
RegenHigherDimTest.
Definition config.hpp:121
Configuration for sharpening computed solutions.
Definition config.hpp:100
unsigned sharpendigits
how many digits should be correct after sharpening. 0 = do not sharpen, which is Bertini 1's default....
Definition config.hpp:103
T function_residual_tolerance
A polynomial (or any function, really) evaluated at a point is considered to be 0 if the magnitude is...
Definition config.hpp:107
T ratio_tolerance
A computed value is considered to be zero if the ratio of two different approximations is smaller tha...
Definition config.hpp:109
Newton and path-tracking tolerances.
Definition config.hpp:69
T newton_before_endgame
Newton tolerance before the endgame (E.4.1).
Definition config.hpp:72
T newton_during_endgame
Newton tolerance during the endgame (E.4.2).
Definition config.hpp:73
Top-level configuration for a zero-dimensional solve (times, precision, threading).
Definition config.hpp:212
mpq_rational start_time
Homotopy start time (t=1).
Definition config.hpp:243
std::string path_variable_name
Name given to the homotopy's path variable.
Definition config.hpp:247
mpq_rational target_time
Homotopy target time (t=0).
Definition config.hpp:245
unsigned initial_ambient_precision
Initial ambient (working) precision for the solve.
Definition config.hpp:215
unsigned max_num_crossed_path_resolve_attempts
The maximum number of times to attempt to re-solve crossed paths at the endgame boundary.
Definition config.hpp:216
mpq_rational endgame_boundary
Time at which tracking hands off to the endgame (t=1/10).
Definition config.hpp:244
Selects which endgame to use (classic input).
Definition config.hpp:44
EndgameChoice endgame
The chosen endgame. Power series is Bertini 1's documented default (EndgameNum 1); see ADR-0058.
Definition config.hpp:45
double T
The number type used by this parser.
Definition algorithm.hpp:387
double T
The number type used by this parser.
Definition algorithm.hpp:289
double T
The number type used by this parser.
Definition algorithm.hpp:701
double T
The number type used by this parser.
Definition algorithm.hpp:567
double T
The number type used by this parser.
Definition algorithm.hpp:464
double T
The number type used by this parser.
Definition algorithm.hpp:48
double T
The number type used by this parser.
Definition algorithm.hpp:816