42 using namespace bertini::tracking;
67 template<
typename Iterator,
typename Skipper>
68 struct ConfigSettingParser<Iterator, PrecisionType, Skipper> : qi::grammar<Iterator, PrecisionType(), Skipper>
71 ConfigSettingParser() : ConfigSettingParser::base_type(root_rule_,
"PrecisionType")
73 namespace phx = boost::phoenix;
83 using boost::spirit::lexeme;
84 using boost::spirit::as_string;
85 using boost::spirit::ascii::no_case;
87 precisiontype_.add(
"0", PrecisionType::Fixed);
88 precisiontype_.add(
"1", PrecisionType::Adaptive);
89 precisiontype_.add(
"2", PrecisionType::Adaptive);
94 root_rule_.name(
"config::PrecisionType");
96 root_rule_ = (config_name_[_val = _1] >> -no_setting_) | no_setting_[_val = PrecisionType::Adaptive];
98 config_name_.name(
"precisiontype_");
99 config_name_ = *(char_ - (no_case[
"mptype"]>>
':')) >> (no_case[
"mptype"] >>
':') >> precisiontype_[_val = _1] >>
';';
101 no_setting_.name(
"no_setting_");
102 no_setting_ = *(char_ - no_case[
"mptype:"]);
104 no_decl_.name(
"no_decl_");
111 using phx::construct;
112 using namespace qi::labels;
113 qi::on_error<qi::fail>
116 val(
"config parser could not complete parsing. Expecting ")<<
119 construct<std::string>(_3,_2)<<
129 qi::rule<Iterator, PrecisionType(), ascii::space_type > root_rule_, config_name_;
130 qi::rule<Iterator, ascii::space_type, std::string()> no_decl_, no_setting_;
132 qi::symbols<char,PrecisionType> precisiontype_;
147 template<
typename Iterator,
typename Skipper>
148 struct ConfigSettingParser<Iterator, Predictor, Skipper> : qi::grammar<Iterator, Predictor(), Skipper>
153 namespace phx = boost::phoenix;
163 using boost::spirit::lexeme;
164 using boost::spirit::as_string;
165 using boost::spirit::ascii::no_case;
167 predictor_.add(
"-1", Predictor::Constant);
168 predictor_.add(
"0", Predictor::Euler);
169 predictor_.add(
"1", Predictor::Heun);
170 predictor_.add(
"2", Predictor::RK4);
171 predictor_.add(
"3", Predictor::Heun);
172 predictor_.add(
"4", Predictor::RKNorsett34);
173 predictor_.add(
"5", Predictor::RKF45);
174 predictor_.add(
"6", Predictor::RKCashKarp45);
175 predictor_.add(
"7", Predictor::RKDormandPrince56);
176 predictor_.add(
"8", Predictor::RKVerner67);
179 std::string setting_name =
"odepredictor";
182 root_rule_.name(
"Predictor");
184 root_rule_ = (config_name_[_val = _1] >> -no_setting_) | no_setting_[_val = Predictor::RKF45];
186 config_name_.name(
"predictor_");
187 config_name_ = *(char_ - (no_case[setting_name] >>
':')) >> (no_case[setting_name] >>
':') >> predictor_[_val = _1] >>
';';
189 no_setting_.name(
"no_setting_");
190 no_setting_ = *(char_ - no_case[setting_name]);
192 no_decl_.name(
"no_decl_");
199 using phx::construct;
200 using namespace qi::labels;
201 qi::on_error<qi::fail>
204 val(
"config parser could not complete parsing. Expecting ")<<
207 construct<std::string>(_3,_2)<<
217 qi::rule<Iterator, Predictor(), ascii::space_type > root_rule_, config_name_;
218 qi::rule<Iterator, ascii::space_type, std::string()> no_decl_, no_setting_;
220 qi::symbols<char,Predictor> predictor_;
245 template<
typename Iterator,
typename Skipper>
246 struct ConfigSettingParser<Iterator, SteppingConfig, Skipper> : qi::grammar<Iterator, SteppingConfig(), Skipper>
251 using R = mpq_rational;
255 ConfigSettingParser() : ConfigSettingParser::base_type(root_rule_,
"config::SteppingType")
258 namespace phx = boost::phoenix;
268 using boost::spirit::lexeme;
269 using boost::spirit::as_string;
270 using boost::spirit::ascii::no_case;
274 std::string maxstep_name =
"maxstepsize";
275 std::string stepsuccess_name =
"stepsuccessfactor";
276 std::string stepfail_name =
"stepfailfactor";
277 std::string stepsincrease_name =
"stepsforincrease";
278 std::string maxnumsteps_name =
"maxnumbersteps";
281 root_rule_.name(
"SteppingConfig");
283 root_rule_ = ((max_step_size_[phx::bind( [
this](SteppingConfig & S, T num)
285 S.max_step_size = num;
287 ^ stepsize_success_[phx::bind( [
this](SteppingConfig & S, R num)
289 S.step_size_success_factor = num;
291 ^ stepsize_fail_[phx::bind( [
this](SteppingConfig & S, R num)
293 S.step_size_fail_factor = num;
295 ^ steps_increase_[phx::bind( [
this](SteppingConfig & S,
unsigned num)
297 S.consecutive_successful_steps_before_stepsize_increase = num;
299 ^ max_num_steps_[phx::bind( [
this](SteppingConfig & S,
unsigned num)
301 S.max_num_steps = num;
308 all_names_ = (no_case[maxstep_name] >>
':') | (no_case[stepsuccess_name] >>
':')|
309 (no_case[stepfail_name] >>
':')| (no_case[stepsincrease_name] >>
':') | (no_case[maxnumsteps_name] >>
':');
311 max_step_size_.name(
"max_step_size_");
312 max_step_size_ = *(char_ - all_names_) >> (no_case[maxstep_name] >>
':')
313 >> mpfr_rules.rational[phx::bind( [
this](T & num, std::string
const& str)
315 num = bertini::NumTraits<T>::FromString(str);
316 }, _val, _1 )] >>
';';
318 stepsize_success_.name(
"stepsize_success_");
319 stepsize_success_ = *(char_ - all_names_) >> (no_case[stepsuccess_name] >>
':')
320 >> mpfr_rules.rational[phx::bind( [
this](R & num, std::string
const& str)
322 num = bertini::NumTraits<double>::FromString(str);
323 }, _val, _1 )] >>
';';
325 stepsize_fail_.name(
"stepsize_fail_");
326 stepsize_fail_ = *(char_ - all_names_) >> (no_case[stepfail_name] >>
':')
327 >> mpfr_rules.rational[phx::bind( [
this](R & num, std::string
const& str)
329 num = bertini::NumTraits<double>::FromString(str);
330 }, _val, _1 )] >>
';';
332 steps_increase_.name(
"steps_increase_");
333 steps_increase_ = *(char_ - all_names_) >> (no_case[stepsincrease_name] >>
':') >> qi::uint_[_val=_1] >>
';';
335 max_num_steps_.name(
"max_num_steps_");
336 max_num_steps_ = *(char_ - all_names_) >> (no_case[maxnumsteps_name] >>
':') >> qi::uint_[_val=_1] >>
';';
338 no_setting_.name(
"no_setting_");
339 no_setting_ = *(char_ - all_names_);
341 no_decl_.name(
"no_decl_");
349 using phx::construct;
350 using namespace qi::labels;
351 qi::on_error<qi::fail>
354 val(
"config parser could not complete parsing. Expecting ")<<
357 construct<std::string>(_3,_2)<<
367 qi::rule<Iterator, SteppingConfig(), ascii::space_type > root_rule_;
368 qi::rule<Iterator, T(), ascii::space_type > max_step_size_;
369 qi::rule<Iterator, R(), ascii::space_type > stepsize_success_, stepsize_fail_;
370 qi::rule<Iterator,
unsigned int(), ascii::space_type > steps_increase_, max_num_steps_;
371 qi::rule<Iterator, ascii::space_type, std::string()> no_decl_, no_setting_, all_names_;
372 rules::LongNum<Iterator> mpfr_rules;
385 template<
typename Iterator,
typename Skipper>
386 struct ConfigSettingParser<Iterator, NewtonConfig, Skipper> : qi::grammar<Iterator, NewtonConfig(), Skipper>
389 ConfigSettingParser() : ConfigSettingParser::base_type(root_rule_,
"config::NewtonType")
391 namespace phx = boost::phoenix;
401 using boost::spirit::lexeme;
402 using boost::spirit::as_string;
403 using boost::spirit::ascii::no_case;
407 std::string maxits_name =
"maxnewtonits";
410 root_rule_.name(
"NewtonConfig");
412 root_rule_ = (max_its_[phx::bind( [
this](NewtonConfig & S,
unsigned num)
414 S.max_num_newton_iterations = num;
422 all_names_ = eps >> (no_case[maxits_name] >>
':');
424 max_its_.name(
"max_its_");
425 max_its_ = *(char_ - no_case[maxits_name]) >> (no_case[maxits_name] >>
':') >> qi::uint_[_val=_1] >>
';';
427 no_setting_.name(
"no_setting_");
428 no_setting_ = *(char_ - all_names_);
430 no_decl_.name(
"no_decl_");
438 using phx::construct;
439 using namespace qi::labels;
440 qi::on_error<qi::fail>
443 val(
"config parser could not complete parsing. Expecting ")<<
446 construct<std::string>(_3,_2)<<
456 qi::rule<Iterator, NewtonConfig(), Skipper> root_rule_;
457 qi::rule<Iterator,
unsigned int(), ascii::space_type > max_its_;
458 qi::rule<Iterator, ascii::space_type, std::string()> no_decl_, no_setting_, all_names_;
468 template<
typename Iterator,
typename Skipper>
469 struct ConfigSettingParser<Iterator, FixedPrecisionConfig, Skipper> : qi::grammar<Iterator, FixedPrecisionConfig(), Skipper>
472 ConfigSettingParser() : ConfigSettingParser::base_type(root_rule_,
"config::FixedPrecision")
474 namespace phx = boost::phoenix;
484 using boost::spirit::lexeme;
485 using boost::spirit::as_string;
486 using boost::spirit::ascii::no_case;
490 root_rule_.name(
"config::FixedPrecision");
491 root_rule_ = eps[_val = FixedPrecisionConfig()] >> omit[*(char_)];
496 using phx::construct;
497 using namespace qi::labels;
498 qi::on_error<qi::fail>
501 val(
"config parser could not complete parsing. Expecting ")<<
504 construct<std::string>(_3,_2)<<
511 qi::rule<Iterator, FixedPrecisionConfig(), ascii::space_type > root_rule_;
521 template<
typename Iterator,
typename Skipper>
529 namespace phx = boost::phoenix;
539 using boost::spirit::lexeme;
540 using boost::spirit::as_string;
541 using boost::spirit::ascii::no_case;
545 std::string coefficient_bound_name =
"coefficientbound";
546 std::string degree_bound_name =
"degreebound";
547 std::string lin_solve_error_bnd_name =
"epsilon";
548 std::string jac_eval_err_bnd_name =
"phi";
549 std::string func_eval_err_bnd_name =
"psi";
550 std::string safety_one_name =
"ampsafetydigits1";
551 std::string safety_two_name =
"ampsafetydigits2";
552 std::string max_prec_name =
"ampmaxprec";
553 std::string consec_steps_prec_dec_name =
"maxstepsprecisiondecrease";
554 std::string max_num_prec_decs_name =
"maxnumprecdecreases";
556 root_rule_.name(
"config::AMP");
574 ^ func_eval_err_bnd_[phx::bind( [
this](AdaptiveMultiplePrecisionConfig & S, T num)
578 ^ safety_one_[phx::bind( [
this](AdaptiveMultiplePrecisionConfig & S,
int num)
582 ^ safety_two_[phx::bind( [
this](AdaptiveMultiplePrecisionConfig & S,
int num)
586 ^ max_prec_[phx::bind( [
this](AdaptiveMultiplePrecisionConfig & S,
unsigned num)
590 ^ consec_steps_prec_dec_[phx::bind( [
this](AdaptiveMultiplePrecisionConfig & S,
unsigned num)
592 S.consecutive_successful_steps_before_precision_decrease = num;
594 ^ max_num_prec_decs_[phx::bind( [
this](AdaptiveMultiplePrecisionConfig & S,
unsigned num)
599 >> -no_setting_) | no_setting_;
601 all_names_ = (no_case[coefficient_bound_name] >>
':') |
602 (no_case[degree_bound_name] >>
':') |
603 (no_case[lin_solve_error_bnd_name] >>
':') |
604 (no_case[jac_eval_err_bnd_name] >>
':') |
605 (no_case[func_eval_err_bnd_name] >>
':') |
606 (no_case[safety_one_name] >>
':') |
607 (no_case[safety_two_name] >>
':') |
608 (no_case[max_prec_name] >>
':') |
609 (no_case[consec_steps_prec_dec_name] >>
':') |
610 (no_case[max_num_prec_decs_name] >>
':')
614 auto str_to_T = [
this](T & num, std::string
const& str)
617 num = bertini::NumTraits<T>::FromString(str);
621 degree_bound_.name(
"degree_bound_");
622 degree_bound_ = *(char_ - all_names_) >> (no_case[degree_bound_name] >>
':')
623 >> mpfr_rules.number_string_[phx::bind( str_to_T, _val, _1 )] >>
';';
625 coefficient_bound_.name(
"coefficient_bound_");
626 coefficient_bound_ = *(char_ - all_names_) >> (no_case[coefficient_bound_name] >>
':')
627 >> mpfr_rules.number_string_[phx::bind( str_to_T, _val, _1 )] >>
';';
629 lin_solve_error_bnd_.name(
"lin_solve_error_bnd_");
630 lin_solve_error_bnd_ = *(char_ - all_names_) >> (no_case[lin_solve_error_bnd_name] >>
':')
631 >> mpfr_rules.number_string_[phx::bind( str_to_T, _val, _1 )] >>
';';
633 jac_eval_err_bnd_.name(
"jac_eval_err_bnd_");
634 jac_eval_err_bnd_ = *(char_ - all_names_) >> (no_case[jac_eval_err_bnd_name] >>
':')
635 >> mpfr_rules.number_string_[phx::bind( str_to_T, _val, _1 )] >>
';';
637 func_eval_err_bnd_.name(
"func_eval_err_bnd_");
638 func_eval_err_bnd_ = *(char_ - all_names_) >> (no_case[func_eval_err_bnd_name] >>
':')
639 >> mpfr_rules.number_string_[phx::bind( str_to_T, _val, _1 )] >>
';';
641 safety_one_.name(
"safety_one_");
642 safety_one_ = *(char_ - all_names_) >> (no_case[safety_one_name] >>
':') >> qi::int_[_val=_1] >>
';';
644 safety_two_.name(
"safety_two_");
645 safety_two_ = *(char_ - all_names_) >> (no_case[safety_two_name] >>
':') >> qi::int_[_val=_1] >>
';';
647 max_prec_.name(
"max_prec_");
648 max_prec_ = *(char_ - all_names_) >> (no_case[max_prec_name] >>
':') >> qi::uint_[_val=_1] >>
';';
650 consec_steps_prec_dec_.name(
"consec_steps_prec_dec_");
651 consec_steps_prec_dec_ = *(char_ - all_names_) >> (no_case[consec_steps_prec_dec_name] >>
':') >> qi::uint_[_val=_1] >>
';';
653 max_num_prec_decs_.name(
"max_num_prec_decs_");
654 max_num_prec_decs_ = *(char_ - all_names_) >> (no_case[max_num_prec_decs_name] >>
':') >> qi::uint_[_val=_1] >>
';';
657 no_setting_.name(
"no_setting_");
658 no_setting_ = *(char_ - all_names_);
660 no_decl_.name(
"no_decl_");
667 using phx::construct;
668 using namespace qi::labels;
669 qi::on_error<qi::fail>
672 val(
"config parser could not complete parsing. Expecting ")<<
675 construct<std::string>(_3,_2)<<
685 qi::rule<Iterator, AdaptiveMultiplePrecisionConfig(), ascii::space_type > root_rule_;
687 qi::rule<Iterator, double(), ascii::space_type > degree_bound_, coefficient_bound_, lin_solve_error_bnd_, jac_eval_err_bnd_, func_eval_err_bnd_;
688 qi::rule<Iterator, int(), ascii::space_type > safety_one_, safety_two_;
689 qi::rule<Iterator,
unsigned int(), ascii::space_type > max_prec_, consec_steps_prec_dec_, max_num_prec_decs_;
691 qi::rule<Iterator, ascii::space_type, std::string()> no_decl_, no_setting_, all_names_;
692 rules::LongNum<Iterator> mpfr_rules;
Provides the base type for config settings parsers.
Definition trackers/config.hpp:154
NumErrorT coefficient_bound
User-defined bound on the sum of the abs vals of the coeffs for any polynomial in the system (for ada...
Definition trackers/config.hpp:155
unsigned int maximum_precision
User-chosed setting for the maximum allowable precision. Paths will die if their precision is request...
Definition trackers/config.hpp:171
int safety_digits_2
User-chosen setting for the number of safety digits used during Criterion C.
Definition trackers/config.hpp:170
int safety_digits_1
User-chosen setting for the number of safety digits used during Criteria A & B.
Definition trackers/config.hpp:169
NumErrorT Phi
Bound on (an error bound). Used for AMP criteria A, B.
Definition trackers/config.hpp:161
NumErrorT Psi
Bound on (an error bound). Used for AMP criterion C.
Definition trackers/config.hpp:165
unsigned max_num_precision_decreases
The maximum number of times precision can be lowered during tracking of a segment of path.
Definition trackers/config.hpp:175
NumErrorT epsilon
Bound on growth in error from linear solves. This is in amp1, amp2, and is used for AMP criteria A a...
Definition trackers/config.hpp:158
NumErrorT degree_bound
User-set bound on degrees of polynomials in the system - tricky to compute for factored polys,...
Definition trackers/config.hpp:156
Configs and settings for tracking.