TTK
Loading...
Searching...
No Matches
TopologicalSimplification.h
Go to the documentation of this file.
1
105
106#pragma once
107
108// base code includes
109
110#include <Debug.h>
114#include <Triangulation.h>
115
116#include <cmath>
117#include <set>
118#include <tuple>
119#include <type_traits>
120
121namespace ttk {
122
123 class TopologicalSimplification : virtual public Debug {
124 public:
126
127 enum class BACKEND { LEGACY, LTS, TO };
128 /*
129 * Either execute this file "legacy" algorithm, or the
130 * lts algorithm. The choice depends on the value of the variable backend_.
131 * Default is lts (localized).
132 */
133 template <typename dataType, typename triangulationType>
134 int execute(const dataType *const inputScalars,
135 dataType *const outputScalars,
136 const SimplexId *const identifiers,
137 const SimplexId *const inputOffsets,
138 SimplexId *const offsets,
139 const SimplexId constraintNumber,
140 const bool addPerturbation,
141 triangulationType &triangulation,
142 const ttk::DiagramType &constraintDiagram = {});
143
144 inline void setBackend(const BACKEND arg) {
145 backend_ = arg;
146 }
147
149 switch(backend_) {
150 case BACKEND::LEGACY:
154 break;
155
156 case BACKEND::LTS:
160 break;
161
162 case BACKEND::TO:
166 break;
167
168 default:
169 this->printErr(
170 "Error, the backend for topological simplification is invalid");
171 return -1;
172 }
173 return 0;
174 }
175
176 protected:
181
185 int EpochNumber{1000};
186
187 // if PDCMethod == 0 then we use Progressive approach
188 // if PDCMethod == 1 then we use Classical Auction approach
189 int PDCMethod{1};
190
191 // if MethodOptimization == 0 then we use direct optimization
192 // if MethodOptimization == 1 then we use Adam
194
195 // if FinePairManagement == 0 then we let the algorithm choose
196 // if FinePairManagement == 1 then we fill the domain
197 // if FinePairManagement == 2 then we cut the domain
199
200 // Adam
202 double LearningRate{0.0001};
203
204 // Direct Optimization : Gradient Step Size
205 double Alpha{0.5};
206
207 // Stopping criterion: when the loss becomes less than a percentage (e.g.
208 // 1%) of the original loss (between input diagram and simplified diagram)
209 double CoefStopCondition{0.01};
210
211 //
214 double Threshold{0.01};
218
220
222 };
223} // namespace ttk
224
225template <typename dataType, typename triangulationType>
227 const dataType *const inputScalars,
228 dataType *const outputScalars,
229 const SimplexId *const identifiers,
230 const SimplexId *const inputOffsets,
231 SimplexId *const offsets,
232 const SimplexId constraintNumber,
233 const bool addPerturbation,
234 triangulationType &triangulation,
235 const ttk::DiagramType &constraintDiagram) {
236 switch(backend_) {
237 case BACKEND::LTS:
238 return ltsObject_
239 .removeUnauthorizedExtrema<dataType, SimplexId, triangulationType>(
240 outputScalars, offsets, &triangulation, identifiers, constraintNumber,
241 addPerturbation);
242 case BACKEND::LEGACY:
243 return legacyObject_.execute(inputScalars, outputScalars, identifiers,
244 inputOffsets, offsets, constraintNumber,
245 triangulation);
246
247 case BACKEND::TO:
267
268 return topologyOptimizer_.execute(inputScalars, outputScalars, offsets,
269 &triangulation, constraintDiagram);
270 default:
271 this->printErr(
272 "Error, the backend for topological simplification is invalid");
273 return -1;
274 }
275}
AbstractTriangulation is an interface class that defines an interface for efficient traversal methods...
virtual int setThreadNumber(const int threadNumber)
Definition BaseClass.h:80
Minimalist debugging class.
Definition Debug.h:88
int debugLevel_
Definition Debug.h:379
virtual int setDebugLevel(const int &debugLevel)
Definition Debug.cpp:147
int printErr(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
Definition Debug.h:149
TTK processing package for the topological simplification of scalar data.
int preconditionTriangulation(AbstractTriangulation *triangulation)
int execute(const dataType *const inputScalars, dataType *const outputScalars, const SimplexId *const identifiers, const SimplexId *const inputOffsets, SimplexId *const offsets, const SimplexId constraintNumber, const triangulationType &triangulation) const
void setMethodOptimization(int methodOptimization)
void setLearningRate(double learningRate)
void setFinePairManagement(int finePairManagement)
void setThresholdMethod(int thresholdMethod)
void setChooseLearningRate(int chooseLearningRate)
void setFastAssignmentUpdate(bool FastAssignmentUpdate)
int preconditionTriangulation(AbstractTriangulation *triangulation)
void setLowerThreshold(int lowerThreshold)
void setConstraintAveraging(bool ConstraintAveraging)
void setPrintFrequency(int printFrequency)
void setThresholdPersistence(double thresholdPersistence)
void setPairTypeToDelete(int pairTypeToDelete)
void setUpperThreshold(int upperThreshold)
void setOptimizationWithoutMatching(bool optimizationWithoutMatching)
void setCoefStopCondition(double coefStopCondition)
void setUseFastPersistenceUpdate(bool UseFastPersistenceUpdate)
int execute(const dataType *const inputScalars, dataType *const outputScalars, SimplexId *const inputOffsets, triangulationType *triangulation, const ttk::DiagramType &constraintDiagram) const
TTK processing package for the topological simplification of scalar data.
LegacyTopologicalSimplification legacyObject_
int preconditionTriangulation(AbstractTriangulation *triangulation)
lts::LocalizedTopologicalSimplification ltsObject_
int execute(const dataType *const inputScalars, dataType *const outputScalars, const SimplexId *const identifiers, const SimplexId *const inputOffsets, SimplexId *const offsets, const SimplexId constraintNumber, const bool addPerturbation, triangulationType &triangulation, const ttk::DiagramType &constraintDiagram={})
ttk::TopologicalOptimization topologyOptimizer_
int preconditionTriangulation(ttk::AbstractTriangulation *triangulation) const
int removeUnauthorizedExtrema(DT *scalars, IT *order, const TT *triangulation, const IT *authorizedExtremaIndices, const IT &nAuthorizedExtremaIndices, const bool &computePerturbation) const
The Topology ToolKit.
std::vector< PersistencePair > DiagramType
Persistence Diagram type as a vector of Persistence pairs.
int SimplexId
Identifier type for simplices of any dimension.
Definition DataTypes.h:22