Bertini 2 d882924 (2026-10-06 19:56 UTC)
Numerical algebraic geometry library (C++ core)
Loading...
Searching...
No Matches
switches_zerodim.hpp
Go to the documentation of this file.
1//This file is part of Bertini 2.
2//
3//bertini2/blackbox/switches_zerodim.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/blackbox/switches_zerodim.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/blackbox/switches_zerodim.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// silviana amethyst, university of wisconsin-eau claire
23
29
30
31
32#pragma once
33
34
35#include "bertini2/system.hpp"
37#include "bertini2/endgames.hpp"
38
40
41
42namespace bertini{
43namespace blackbox{
44
45
46
54{
55 // INTERIM default = TotalDegreeBinomial (see policies.hpp): the linear-product TotalDegreeLinearProduct is the
56 // eventual default but currently stalls the Cauchy endgame on harder systems, so the safe
57 // default stays roots of unity until that is fixed.
61};
62
63
78{
79 // INTERIM: a single affine group infers TotalDegreeBinomial (the safe default). The eventual choice
80 // here is TotalDegreeLinearProduct (general position), gated on the Cauchy-endgame fix; see policies.hpp.
81 if (sys.NumVariableGroups() == 1 && sys.NumHomVariableGroups() == 0)
83 else
84 return type::Start::MHom;
85}
86
87
88// The concrete start-system type appears only at the construction site, via
89// start_system::MakeStartFactory<StartType>() (see start_base.hpp); ZeroDim downstream is a
90// single type that holds the start system polymorphically. Add a start system => add a
91// case in ZeroDimSpecifyStart, no new ZeroDim instantiation.
92
105template <typename TrackerType, typename EndgameType, typename ... ConstTs>
106std::unique_ptr<algorithm::AnyZeroDim> ZeroDimSpecifyComplete(ConstTs const& ...ts)
107{
108 // the blackbox always clones + builds (ZeroDimSolver); ts... = (target, start_factory).
109 return std::make_unique<
111 >(ts...);
112}
113
123template <typename TrackerType, typename ... ConstTs>
124std::unique_ptr<algorithm::AnyZeroDim> ZeroDimSpecifyEndgame(ZeroDimRT const& rt, ConstTs const& ...ts)
125{
126 switch (rt.endgame)
127 {
129 // honor the requested endgame! until 2026-06-12 this hardcoded Cauchy.
130 return ZeroDimSpecifyComplete<TrackerType,
132
134 return ZeroDimSpecifyComplete<TrackerType,
136 }
137 throw std::runtime_error("unrecognized endgame type in ZeroDimSpecifyEndgame");
138}
139
148template <typename ... ConstTs>
149std::unique_ptr<algorithm::AnyZeroDim> ZeroDimSpecifyTracker(ZeroDimRT const& rt, ConstTs const& ...ts)
150{
151 switch (rt.tracker)
152 {
159 }
160 throw std::runtime_error("unrecognized tracker type in ZeroDimSpecifyTracker");
161}
162
174template <typename ... ConstTs>
175std::unique_ptr<algorithm::AnyZeroDim> ZeroDimSpecifyStart(ZeroDimRT const& rt, ConstTs const& ...ts)
176{
177 // append the start-system factory to the argument pack; ZeroDimSolver consumes (target, factory).
178 switch (rt.start)
179 {
187 throw std::runtime_error("trying to use generic zero dim with user homotopy. use the specific UserBlaBla instead");
188 }
189 throw std::runtime_error("unrecognized start system type in ZeroDimSpecifyStart");
190}
191
203template <typename ... ConstTs>
204std::unique_ptr<algorithm::AnyZeroDim> MakeZeroDim(ZeroDimRT const& rt, ConstTs const& ...ts)
205{
206 return ZeroDimSpecifyStart(rt, ts...);
207}
208
209
210} //ns blackbox
211} //ns bertini
Configs for the blackbox whatnot.
The fundamental polynomial system class for Bertini2.
Definition system.hpp:106
size_t NumVariableGroups() const
Get the number of affine variable groups in the system.
size_t NumHomVariableGroups() const
Get the number of homogeneous variable groups in the system.
Collects the various header files which define the Bertini2 endgames.
Tracker
Which path tracker the zero-dim solve should use.
Definition config.hpp:40
@ FixedDouble
Definition config.hpp:40
@ Adaptive
Definition config.hpp:40
@ FixedMultiple
Definition config.hpp:40
Endgame
Which endgame the zero-dim solve should use.
Definition config.hpp:42
@ Cauchy
Definition config.hpp:42
@ PowerSeries
Definition config.hpp:42
Start
Which start system the zero-dim solve should use.
Definition config.hpp:38
@ MHom
Definition config.hpp:38
@ User
Definition config.hpp:38
@ TotalDegreeLinearProduct
Definition config.hpp:38
@ TotalDegreeBinomial
Definition config.hpp:38
Definition algorithm_builder.hpp:37
std::unique_ptr< algorithm::AnyZeroDim > ZeroDimSpecifyEndgame(ZeroDimRT const &rt, ConstTs const &...ts)
Resolve the runtime endgame choice (rt.endgame) into a compile-time endgame type, then continue.
Definition switches_zerodim.hpp:124
type::Start InferStartType(System const &sys)
Infer which start system to use from the target system's variable-group structure.
Definition switches_zerodim.hpp:77
std::unique_ptr< algorithm::AnyZeroDim > ZeroDimSpecifyStart(ZeroDimRT const &rt, ConstTs const &...ts)
Resolve the runtime start-system choice (rt.start) into a start-system factory, then continue.
Definition switches_zerodim.hpp:175
std::unique_ptr< algorithm::AnyZeroDim > ZeroDimSpecifyComplete(ConstTs const &...ts)
Instantiate the fully-specified ZeroDim solver – the end of the switch chain.
Definition switches_zerodim.hpp:106
std::unique_ptr< algorithm::AnyZeroDim > ZeroDimSpecifyTracker(ZeroDimRT const &rt, ConstTs const &...ts)
Resolve the runtime tracker choice (rt.tracker) into a compile-time tracker type, then continue.
Definition switches_zerodim.hpp:149
std::unique_ptr< algorithm::AnyZeroDim > MakeZeroDim(ZeroDimRT const &rt, ConstTs const &...ts)
Build a ZeroDim solver from runtime options – the entry point of the switch chain.
Definition switches_zerodim.hpp:204
StartSystemFactory< SystemType > MakeStartFactory()
Build a StartSystemFactory that mints a concrete start system from the target.
Definition start_base.hpp:68
Definition algorithm_builder.hpp:36
The zero-dimensional solve algorithm: given a polynomial system, form a start system and a homotopy,...
Definition zero_dim_solve.hpp:3255
Runtime options selecting which ZeroDim algorithm to instantiate.
Definition switches_zerodim.hpp:54
type::Start start
Which start system to use.
Definition switches_zerodim.hpp:58
type::Tracker tracker
Which path tracker to use.
Definition switches_zerodim.hpp:59
type::Endgame endgame
Which endgame to use.
Definition switches_zerodim.hpp:60
endgame::CauchyEndgame< EGPrecT > Cauchy
The Cauchy endgame for this tracker.
Definition config.hpp:90
endgame::PowerSeriesEndgame< EGPrecT > PSEG
The power-series endgame for this tracker.
Definition config.hpp:89
Collects the various header files which define the Bertini2 systems.
Provides the algorithm for computing all zero-dimensional solutions for an algberaic system.