AutoPas  3.0.0
Loading...
Searching...
No Matches
AutoPasDecl.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <memory>
9#include <set>
10
31
32namespace autopas {
33
34// Forward declare Handler so that including this header does not include the whole library with all
35// containers and traversals.
36template <class Particle_T>
37class LogicHandler;
38
45template <class Particle_T>
46class AutoPas {
47 public:
51 using ParticleType = Particle_T;
52
58
64
70
76
81 explicit AutoPas(std::ostream &logOutputStream = std::cout);
82
83 ~AutoPas();
84
90 AutoPas &operator=(AutoPas &&other) noexcept;
91
100 void init();
101
108 std::vector<Particle_T> resizeBox(const std::array<double, 3> &boxMin, const std::array<double, 3> &boxMax);
109
113 void forceRetune();
114
120 void finalize() {
121 if (not _externalMPICommunicator) {
122 AutoPas_MPI_Comm_free(&_tuningStrategyFactoryInfo.autopasMpiCommunicator);
123 }
124 }
125
132 [[nodiscard]] std::vector<Particle_T> updateContainer();
133
143 void reserve(size_t numParticles);
144
154 void reserve(size_t numParticles, size_t numHaloParticles);
155
164 void addParticle(const Particle_T &p);
165
173 template <class Collection>
174 void addParticles(Collection &&particles);
175
185 template <class Collection, class F>
186 void addParticlesIf(Collection &&particles, F predicate);
187
195 void addHaloParticle(const Particle_T &haloParticle);
196
204 template <class Collection>
205 void addHaloParticles(Collection &&particles);
206
216 template <class Collection, class F>
217 void addHaloParticlesIf(Collection &&particles, F predicate);
218
223 void deleteAllParticles();
224
233 void deleteParticle(IteratorT &iter);
234
241
254 bool deleteParticle(Particle_T &particle);
255
262 template <class Functor>
264
272 IteratorT begin(IteratorBehavior behavior = IteratorBehavior::ownedOrHalo);
273
278 ConstIteratorT begin(IteratorBehavior behavior = IteratorBehavior::ownedOrHalo) const;
279
287 template <typename Lambda>
288 void forEachParallel(Lambda forEachLambda, IteratorBehavior behavior = IteratorBehavior::ownedOrHalo) {
289 // TODO lgaertner: parallelize with kokkos integration
290 withStaticContainerType(getContainer(), [&](auto &container) { container.forEach(forEachLambda, behavior); });
291 }
292
297 template <typename Lambda>
298 void forEachParallel(Lambda forEachLambda, IteratorBehavior behavior = IteratorBehavior::ownedOrHalo) const {
299 // TODO lgaertner: parallelize with kokkos integration
300 withStaticContainerType(getContainer(), [&](auto &container) { container.forEach(forEachLambda, behavior); });
301 }
302
309 template <typename Lambda>
310 void forEach(Lambda forEachLambda, IteratorBehavior behavior = IteratorBehavior::ownedOrHalo) {
311 withStaticContainerType(getContainer(), [&](auto &container) { container.forEach(forEachLambda, behavior); });
312 }
313
318 template <typename Lambda>
319 void forEach(Lambda forEachLambda, IteratorBehavior behavior = IteratorBehavior::ownedOrHalo) const {
320 withStaticContainerType(getContainer(), [&](auto &container) { container.forEach(forEachLambda, behavior); });
321 }
322
332 template <typename Lambda, typename A>
333 void reduceParallel(Lambda reduceLambda, A &result, IteratorBehavior behavior = IteratorBehavior::ownedOrHalo) {
334 // TODO lgaertner: parallelize with kokkos integration
335 withStaticContainerType(getContainer(), [&](auto &container) { container.reduce(reduceLambda, result, behavior); });
336 }
337
342 template <typename Lambda, typename A>
343 void reduceParallel(Lambda reduceLambda, A &result, IteratorBehavior behavior = IteratorBehavior::ownedOrHalo) const {
344 // TODO lgaertner: parallelize with kokkos integration
345 withStaticContainerType(getContainer(), [&](auto &container) { container.reduce(reduceLambda, result, behavior); });
346 }
347
356 template <typename Lambda, typename A>
357 void reduce(Lambda reduceLambda, A &result, IteratorBehavior behavior = IteratorBehavior::ownedOrHalo) {
358 withStaticContainerType(getContainer(), [&](auto &container) { container.reduce(reduceLambda, result, behavior); });
359 }
360
365 template <typename Lambda, typename A>
366 void reduce(Lambda reduceLambda, A &result, IteratorBehavior behavior = IteratorBehavior::ownedOrHalo) const {
367 withStaticContainerType(getContainer(), [&](auto &container) { container.reduce(reduceLambda, result, behavior); });
368 }
369
374 ConstIteratorT cbegin(IteratorBehavior behavior = IteratorBehavior::ownedOrHalo) const { return begin(behavior); }
375
386 [[nodiscard]] constexpr bool end() const { return false; }
387
399 RegionIteratorT getRegionIterator(const std::array<double, 3> &lowerCorner, const std::array<double, 3> &higherCorner,
400 IteratorBehavior behavior = IteratorBehavior::ownedOrHalo);
405 RegionConstIteratorT getRegionIterator(const std::array<double, 3> &lowerCorner,
406 const std::array<double, 3> &higherCorner,
407 IteratorBehavior behavior = IteratorBehavior::ownedOrHalo) const;
408
418 template <typename Lambda>
419 void forEachInRegionParallel(Lambda forEachLambda, const std::array<double, 3> &lowerCorner,
420 const std::array<double, 3> &higherCorner,
421 IteratorBehavior behavior = IteratorBehavior::ownedOrHalo) {
422 // TODO (lgaertner): parallelize with kokkos integration
423 withStaticContainerType(getContainer(), [&](auto &container) {
424 container.forEachInRegion(forEachLambda, lowerCorner, higherCorner, behavior);
425 });
426 }
427
432 template <typename Lambda>
433 void forEachInRegionParallel(Lambda forEachLambda, const std::array<double, 3> &lowerCorner,
434 const std::array<double, 3> &higherCorner,
435 IteratorBehavior behavior = IteratorBehavior::ownedOrHalo) const {
436 // TODO (lgaertner): parallelize with kokkos integration
437 withStaticContainerType(getContainer(), [&](auto &container) {
438 container.forEachInRegion(forEachLambda, lowerCorner, higherCorner, behavior);
439 });
440 }
441
450 template <typename Lambda>
451 void forEachInRegion(Lambda forEachLambda, const std::array<double, 3> &lowerCorner,
452 const std::array<double, 3> &higherCorner,
453 IteratorBehavior behavior = IteratorBehavior::ownedOrHalo) {
454 withStaticContainerType(getContainer(), [&](auto &container) {
455 container.forEachInRegion(forEachLambda, lowerCorner, higherCorner, behavior);
456 });
457 }
458
463 template <typename Lambda>
464 void forEachInRegion(Lambda forEachLambda, const std::array<double, 3> &lowerCorner,
465 const std::array<double, 3> &higherCorner,
466 IteratorBehavior behavior = IteratorBehavior::ownedOrHalo) const {
467 withStaticContainerType(getContainer(), [&](auto &container) {
468 container.forEachInRegion(forEachLambda, lowerCorner, higherCorner, behavior);
469 });
470 }
471
483 template <typename Lambda, typename A>
484 void reduceInRegionParallel(Lambda reduceLambda, A &result, const std::array<double, 3> &lowerCorner,
485 const std::array<double, 3> &higherCorner,
486 IteratorBehavior behavior = IteratorBehavior::ownedOrHalo) {
487 // TODO lgaertner: parallelize with kokkos integration
488 withStaticContainerType(getContainer(), [&](auto &container) {
489 container.reduceInRegion(reduceLambda, result, lowerCorner, higherCorner, behavior);
490 });
491 }
492
497 template <typename Lambda, typename A>
498 void reduceInRegionParallel(Lambda reduceLambda, A &result, const std::array<double, 3> &lowerCorner,
499 const std::array<double, 3> &higherCorner,
500 IteratorBehavior behavior = IteratorBehavior::ownedOrHalo) const {
501 // TODO lgaertner: parallelize with kokkos integration
502 withStaticContainerType(getContainer(), [&](auto &container) {
503 container.reduceInRegion(reduceLambda, result, lowerCorner, higherCorner, behavior);
504 });
505 }
506
517 template <typename Lambda, typename A>
518 void reduceInRegion(Lambda reduceLambda, A &result, const std::array<double, 3> &lowerCorner,
519 const std::array<double, 3> &higherCorner,
520 IteratorBehavior behavior = IteratorBehavior::ownedOrHalo) {
521 withStaticContainerType(getContainer(), [&](auto &container) {
522 container.reduceInRegion(reduceLambda, result, lowerCorner, higherCorner, behavior);
523 });
524 }
525
530 template <typename Lambda, typename A>
531 void reduceInRegion(Lambda reduceLambda, A &result, const std::array<double, 3> &lowerCorner,
532 const std::array<double, 3> &higherCorner,
533 IteratorBehavior behavior = IteratorBehavior::ownedOrHalo) const {
534 withStaticContainerType(getContainer(), [&](auto &container) {
535 container.reduceInRegion(reduceLambda, result, lowerCorner, higherCorner, behavior);
536 });
537 }
538
544 double getVerletSkin() { return _logicHandlerInfo.verletSkin; };
545
551 [[nodiscard]] size_t getNumberOfParticles(IteratorBehavior behavior = IteratorBehavior::owned) const;
552
557 [[nodiscard]] unsigned long getContainerType() const;
558
563 [[nodiscard]] const std::array<double, 3> &getBoxMin() const;
564
569 [[nodiscard]] const std::array<double, 3> &getBoxMax() const;
570
575 [[nodiscard]] bool searchSpaceIsTrivial();
576
581 void setBoxMin(const std::array<double, 3> &boxMin) { _logicHandlerInfo.boxMin = boxMin; }
582
587 void setBoxMax(const std::array<double, 3> &boxMax) { _logicHandlerInfo.boxMax = boxMax; }
588
593 [[nodiscard]] double getCutoff() const { return _logicHandlerInfo.cutoff; }
594
599 void setCutoff(double cutoff) {
600 if (cutoff <= 0.0) {
601 utils::ExceptionHandler::exception("Error: Cutoff has to be positive {} <= 0.0!", cutoff);
602 }
603 _logicHandlerInfo.cutoff = cutoff;
604 }
605
610 [[nodiscard]] const NumberSet<double> &getAllowedCellSizeFactors() const { return *_allowedCellSizeFactors; }
611
616 void setAllowedCellSizeFactors(const NumberSet<double> &allowedCellSizeFactors) {
617 if (allowedCellSizeFactors.getMin() <= 0.0) {
618 utils::ExceptionHandler::exception("Error: minimum cell size factor has to be positive {} <= 0.0!",
619 allowedCellSizeFactors.getMin());
620 }
621 _allowedCellSizeFactors = std::move(allowedCellSizeFactors.clone());
622 }
623
628 void setCellSizeFactor(double cellSizeFactor) {
629 if (cellSizeFactor <= 0.0) {
630 utils::ExceptionHandler::exception("Error: cell size factor has to be positive! {}<= 0.0!", cellSizeFactor);
631 }
632 _allowedCellSizeFactors = std::make_unique<NumberSetFinite<double>>(std::set<double>{cellSizeFactor});
633 }
634
639 void setVerletSkin(double verletSkin) { _logicHandlerInfo.verletSkin = verletSkin; }
640
645 [[nodiscard]] unsigned int getVerletRebuildFrequency() const { return _verletRebuildFrequency; }
646
651 void setVerletRebuildFrequency(unsigned int verletRebuildFrequency) {
652 _verletRebuildFrequency = verletRebuildFrequency;
653 }
658 [[nodiscard]] unsigned int getVerletClusterSize() const { return _logicHandlerInfo.verletClusterSize; }
659
664 void setVerletClusterSize(unsigned int verletClusterSize) { _logicHandlerInfo.verletClusterSize = verletClusterSize; }
665
670 [[nodiscard]] unsigned int getTuningInterval() const { return _autoTunerInfo.tuningInterval; }
671
676 void setTuningInterval(unsigned int tuningInterval) { _autoTunerInfo.tuningInterval = tuningInterval; }
677
682 [[nodiscard]] unsigned int getNumSamples() const { return _autoTunerInfo.maxSamples; }
683
688 void setNumSamples(unsigned int numSamples) { _autoTunerInfo.maxSamples = numSamples; }
689
695 void setEarlyStoppingFactor(double earlyStoppingFactor) { _autoTunerInfo.earlyStoppingFactor = earlyStoppingFactor; }
696
701 [[nodiscard]] bool getUseLOESSSmoothening() const { return _autoTunerInfo.useLOESSSmoothening; }
702
707 void setUseLOESSSmoothening(bool useLOESSSmoothening) { _autoTunerInfo.useLOESSSmoothening = useLOESSSmoothening; }
708
713 [[nodiscard]] unsigned int getMaxEvidence() const { return _tuningStrategyFactoryInfo.maxEvidence; }
714
719 void setMaxEvidence(unsigned int maxEvidence) { _tuningStrategyFactoryInfo.maxEvidence = maxEvidence; }
720
725 [[nodiscard]] double getRelativeOptimumRange() const { return _tuningStrategyFactoryInfo.relativeOptimumRange; }
726
731 void setRelativeOptimumRange(double relativeOptimumRange) {
732 _tuningStrategyFactoryInfo.relativeOptimumRange = relativeOptimumRange;
733 }
734
739 [[nodiscard]] unsigned int getMaxTuningPhasesWithoutTest() const {
740 return _tuningStrategyFactoryInfo.maxTuningPhasesWithoutTest;
741 }
742
747 void setMaxTuningPhasesWithoutTest(unsigned int maxTuningPhasesWithoutTest) {
748 _tuningStrategyFactoryInfo.maxTuningPhasesWithoutTest = maxTuningPhasesWithoutTest;
749 }
750
756 [[nodiscard]] double getRelativeBlacklistRange() const { return _tuningStrategyFactoryInfo.relativeBlacklistRange; }
757
762 void setRelativeBlacklistRange(double relativeBlacklistRange) {
763 _tuningStrategyFactoryInfo.relativeBlacklistRange = relativeBlacklistRange;
764 }
765
771 [[nodiscard]] unsigned int getEvidenceFirstPrediction() const {
772 return _tuningStrategyFactoryInfo.minNumberOfEvidence;
773 }
774
780 void setEvidenceFirstPrediction(unsigned int evidenceFirstPrediction) {
781 _tuningStrategyFactoryInfo.minNumberOfEvidence = evidenceFirstPrediction;
782 }
783
788 [[nodiscard]] AcquisitionFunctionOption getAcquisitionFunction() const {
789 return _tuningStrategyFactoryInfo.acquisitionFunctionOption;
790 }
791
798 void setAcquisitionFunction(AcquisitionFunctionOption acqFun) {
799 _tuningStrategyFactoryInfo.acquisitionFunctionOption = acqFun;
800 }
801
806 ExtrapolationMethodOption getExtrapolationMethodOption() const {
807 return _tuningStrategyFactoryInfo.extrapolationMethodOption;
808 }
809
814 void setExtrapolationMethodOption(ExtrapolationMethodOption extrapolationMethodOption) {
815 _tuningStrategyFactoryInfo.extrapolationMethodOption = extrapolationMethodOption;
816 }
817
822 [[nodiscard]] SelectorStrategyOption getSelectorStrategy() const { return _autoTunerInfo.selectorStrategy; }
823
829 void setSelectorStrategy(SelectorStrategyOption selectorStrategy) {
830 _autoTunerInfo.selectorStrategy = selectorStrategy;
831 }
832
837 const std::set<LoadEstimatorOption> &getAllowedLoadEstimators() const { return _allowedLoadEstimators; }
838
844 void setAllowedLoadEstimators(const std::set<LoadEstimatorOption> &allowedLoadEstimators) {
845 _allowedLoadEstimators = allowedLoadEstimators;
846 }
847
852 [[nodiscard]] const std::set<ContainerOption> &getAllowedContainers() const { return _allowedContainers; }
853
859 void setAllowedContainers(const std::set<ContainerOption> &allowedContainers) {
860 _allowedContainers = allowedContainers;
861 }
862
869 [[nodiscard]] const std::set<TraversalOption> &getAllowedTraversals(
870 const InteractionTypeOption interactionType = InteractionTypeOption::pairwise) const {
871 return _allowedTraversals.at(interactionType);
872 }
873
881 void setAllowedTraversals(const std::set<TraversalOption> &allowedTraversals,
882 const InteractionTypeOption interactionType = InteractionTypeOption::pairwise) {
883 if (interactionType == InteractionTypeOption::all) {
884 for (auto iType : InteractionTypeOption::getMostOptions()) {
885 _allowedTraversals[iType] = allowedTraversals;
886 }
887 } else {
888 _allowedTraversals[interactionType] = allowedTraversals;
889 }
890 }
891
898 [[nodiscard]] const std::set<DataLayoutOption> &getAllowedDataLayouts(
899 const InteractionTypeOption interactionType = InteractionTypeOption::pairwise) const {
900 return _allowedDataLayouts.at(interactionType);
901 }
902
910 void setAllowedDataLayouts(const std::set<DataLayoutOption> &allowedDataLayouts,
911 const InteractionTypeOption interactionType = InteractionTypeOption::pairwise) {
912 if (interactionType == InteractionTypeOption::all) {
913 for (auto iType : InteractionTypeOption::getMostOptions()) {
914 _allowedDataLayouts[iType] = allowedDataLayouts;
915 }
916 } else {
917 _allowedDataLayouts[interactionType] = allowedDataLayouts;
918 }
919 }
920
927 [[nodiscard]] const std::set<Newton3Option> &getAllowedNewton3Options(
928 const InteractionTypeOption interactionType = InteractionTypeOption::pairwise) const {
929 return _allowedNewton3Options.at(interactionType);
930 }
931
939 void setAllowedNewton3Options(const std::set<Newton3Option> &allowedNewton3Options,
940 const InteractionTypeOption interactionType = InteractionTypeOption::pairwise) {
941 if (interactionType == InteractionTypeOption::all) {
942 for (auto iType : InteractionTypeOption::getMostOptions()) {
943 _allowedNewton3Options[iType] = allowedNewton3Options;
944 }
945 } else {
946 _allowedNewton3Options[interactionType] = allowedNewton3Options;
947 }
948 }
949
956 void setAllowedInteractionTypeOptions(const std::set<InteractionTypeOption> &allowedInteractionTypeOptions) {
957 _allowedInteractionTypeOptions = allowedInteractionTypeOptions;
958 }
959
964 [[nodiscard]] std::unordered_map<InteractionTypeOption::Value, std::reference_wrapper<const Configuration>>
966 std::unordered_map<InteractionTypeOption::Value, std::reference_wrapper<const Configuration>> currentConfigs;
967 currentConfigs.reserve(_autoTuners.size());
968
969 for (const auto &[type, tuner] : _autoTuners) {
970 currentConfigs.emplace(type, std::cref(tuner->getCurrentConfig()));
971 }
972 return currentConfigs;
973 }
974
979 [[nodiscard]] const std::vector<TuningStrategyOption> &getTuningStrategyOptions() const {
980 return _tuningStrategyOptions;
981 }
982
988 void setTuningStrategyOption(const std::vector<TuningStrategyOption> &tuningStrategyOptions) {
989 _tuningStrategyOptions = tuningStrategyOptions;
990 }
991
996 [[nodiscard]] const TuningMetricOption &getTuningMetricOption() const { return _autoTunerInfo.tuningMetric; }
997
1004 _autoTunerInfo.tuningMetric = tuningMetricOption;
1005 }
1006
1011 [[nodiscard]] const EnergySensorOption &getEnergySensorOption() const { return _autoTunerInfo.energySensor; }
1012
1018 _autoTunerInfo.energySensor = energySensorOption;
1019 }
1020
1025 void setMPITuningMaxDifferenceForBucket(double MPITuningMaxDifferenceForBucket) {
1026 _tuningStrategyFactoryInfo.mpiTuningMaxDifferenceForBucket = MPITuningMaxDifferenceForBucket;
1027 }
1028
1033 void setMPITuningWeightForMaxDensity(double MPITuningWeightForMaxDensity) {
1034 _tuningStrategyFactoryInfo.mpiTuningWeightForMaxDensity = MPITuningWeightForMaxDensity;
1035 }
1036
1037// Only define the interface for the MPI communicator if AUTOPAS_INCLUDE_MPI=ON
1038// The internal implementation will use _autopasMPICommunicator with WrapMPI regardless of AUTOPAS_INCLUDE_MPI
1039#if defined(AUTOPAS_INCLUDE_MPI)
1045 void setMPICommunicator(MPI_Comm comm) { _tuningStrategyFactoryInfo.autopasMpiCommunicator = comm; }
1046
1051 MPI_Comm getMPICommunicator() { return _tuningStrategyFactoryInfo.autopasMpiCommunicator; }
1052#endif
1053
1059 void setOutputSuffix(const std::string &suffix) { _outputSuffix = suffix; }
1060
1067 double getMeanRebuildFrequency() { return _logicHandler->getMeanRebuildFrequency(); }
1068
1073 void setUseTuningLogger(bool useTuningLogger) { _useTuningStrategyLoggerProxy = useTuningLogger; }
1074
1079 void setRuleFileName(const std::string &ruleFileName) { _tuningStrategyFactoryInfo.ruleFileName = ruleFileName; }
1080
1085 void setFuzzyRuleFileName(const std::string &fuzzyRuleFileName) {
1086 _tuningStrategyFactoryInfo.fuzzyRuleFileName = fuzzyRuleFileName;
1087 }
1088
1093 const std::string &getRuleFileName() const { return _tuningStrategyFactoryInfo.ruleFileName; }
1094
1101 void setSortingThreshold(size_t sortingThreshold) { _sortingThreshold = sortingThreshold; }
1102
1107 size_t getSortingThreshold() const { return _sortingThreshold; }
1108
1109 private:
1111
1112 const autopas::ParticleContainerInterface<Particle_T> &getContainer() const;
1116 TuningStrategyFactoryInfo _tuningStrategyFactoryInfo{};
1120 AutoTunerInfo _autoTunerInfo{};
1124 LogicHandlerInfo _logicHandlerInfo{};
1128 bool _useTuningStrategyLoggerProxy{false};
1133 unsigned int _verletRebuildFrequency{100};
1138 std::vector<TuningStrategyOption> _tuningStrategyOptions{};
1143 std::set<ContainerOption> _allowedContainers{ContainerOption::getMostOptions()};
1148 std::unordered_map<InteractionTypeOption::Value, std::set<TraversalOption>> _allowedTraversals{
1149 {InteractionTypeOption::pairwise, TraversalOption::getMostPairwiseOptions()},
1150 {InteractionTypeOption::triwise, TraversalOption::getMostTriwiseOptions()}};
1155 std::unordered_map<InteractionTypeOption::Value, std::set<DataLayoutOption>> _allowedDataLayouts{
1156 {InteractionTypeOption::pairwise, DataLayoutOption::getMostOptions()},
1157 {InteractionTypeOption::triwise, DataLayoutOption::getMostOptions()}};
1161 std::unordered_map<InteractionTypeOption::Value, std::set<Newton3Option>> _allowedNewton3Options{
1162 {InteractionTypeOption::pairwise, Newton3Option::getMostOptions()},
1163 {InteractionTypeOption::triwise, Newton3Option::getMostOptions()}};
1168 std::set<InteractionTypeOption> _allowedInteractionTypeOptions{InteractionTypeOption::pairwise};
1172 std::unique_ptr<NumberSet<double>> _allowedCellSizeFactors{
1173 std::make_unique<NumberSetFinite<double>>(std::set<double>({1.}))};
1178 std::set<LoadEstimatorOption> _allowedLoadEstimators{LoadEstimatorOption::getAllOptions()};
1182 std::unique_ptr<autopas::LogicHandler<Particle_T>> _logicHandler;
1183
1188 std::unordered_map<InteractionTypeOption::Value, std::unique_ptr<autopas::AutoTuner>> _autoTuners;
1189
1193 bool _externalMPICommunicator{false};
1198 std::string _outputSuffix{""};
1202 size_t _sortingThreshold{8};
1213 template <class F>
1214 void addParticlesAux(size_t numParticlesToAdd, size_t numHalosToAdd, size_t collectionSize, F loopBody);
1215}; // class AutoPas
1216} // namespace autopas
The AutoPas class is intended to be the main point of Interaction for the user.
Definition: AutoPasDecl.h:46
void setMaxEvidence(unsigned int maxEvidence)
Set maximum number of evidence for tuning.
Definition: AutoPasDecl.h:719
void setNumSamples(unsigned int numSamples)
Set number of samples taken per configuration during the tuning.
Definition: AutoPasDecl.h:688
void setAllowedNewton3Options(const std::set< Newton3Option > &allowedNewton3Options, const InteractionTypeOption interactionType=InteractionTypeOption::pairwise)
Set the list of allowed newton 3 options.
Definition: AutoPasDecl.h:939
void setSelectorStrategy(SelectorStrategyOption selectorStrategy)
Set the strategy of how to select a performance value for a piece of evidence from multiple time meas...
Definition: AutoPasDecl.h:829
void setFuzzyRuleFileName(const std::string &fuzzyRuleFileName)
Set fuzzy rule file name for the RuleBasedTuning.
Definition: AutoPasDecl.h:1085
unsigned int getTuningInterval() const
Get tuning interval.
Definition: AutoPasDecl.h:670
unsigned int getMaxTuningPhasesWithoutTest() const
Get the maximum number of tuning phases before a configuration is certainly tested again.
Definition: AutoPasDecl.h:739
const std::set< TraversalOption > & getAllowedTraversals(const InteractionTypeOption interactionType=InteractionTypeOption::pairwise) const
Get the list of allowed traversals.
Definition: AutoPasDecl.h:869
std::vector< Particle_T > updateContainer()
Updates the container.
Definition: AutoPasImpl.h:224
void setTuningMetricOption(TuningMetricOption tuningMetricOption)
Setter for the tuning metric option.
Definition: AutoPasDecl.h:1003
void reduceInRegion(Lambda reduceLambda, A &result, const std::array< double, 3 > &lowerCorner, const std::array< double, 3 > &higherCorner, IteratorBehavior behavior=IteratorBehavior::ownedOrHalo) const
Execute code on all particles in a certain region as defined by a lambda function.
Definition: AutoPasDecl.h:531
autopas::ContainerIterator< Particle_T, false, true > RegionConstIteratorT
Define the const region iterator type for ease of use.
Definition: AutoPasDecl.h:75
const std::array< double, 3 > & getBoxMin() const
Get the lower corner of the container without the halo.
Definition: AutoPasImpl.h:339
unsigned int getNumSamples() const
Get number of samples taken per configuration during the tuning.
Definition: AutoPasDecl.h:682
unsigned int getMaxEvidence() const
Get maximum number of evidence for tuning.
Definition: AutoPasDecl.h:713
void setBoxMax(const std::array< double, 3 > &boxMax)
Set coordinates of the upper corner of the domain.
Definition: AutoPasDecl.h:587
void reduce(Lambda reduceLambda, A &result, IteratorBehavior behavior=IteratorBehavior::ownedOrHalo) const
Reduce properties of particles as defined by a lambda function.
Definition: AutoPasDecl.h:366
bool searchSpaceIsTrivial()
get the bool value indicating if the search space is trivial (not more than one configuration to test...
Definition: AutoPasImpl.h:359
void setUseTuningLogger(bool useTuningLogger)
Set if the tuning information should be logged to a file.
Definition: AutoPasDecl.h:1073
unsigned int getVerletRebuildFrequency() const
Get Verlet rebuild frequency.
Definition: AutoPasDecl.h:645
ConstIteratorT cbegin(IteratorBehavior behavior=IteratorBehavior::ownedOrHalo) const
Iterate over all particles by using for(auto iter = autoPas.begin(); iter.isValid(); ++iter)
Definition: AutoPasDecl.h:374
void addHaloParticles(Collection &&particles)
Adds all halo particles from the collection to the container.
Definition: AutoPasImpl.h:256
void reserve(size_t numParticles)
Reserve memory for a given number of particles in the container and logic layers.
Definition: AutoPasImpl.h:169
const std::string & getRuleFileName() const
Get the name / path of the rule file for the RuleBasedTuning.
Definition: AutoPasDecl.h:1093
void setRuleFileName(const std::string &ruleFileName)
Set rule file name for the RuleBasedTuning.
Definition: AutoPasDecl.h:1079
ExtrapolationMethodOption getExtrapolationMethodOption() const
Get extrapolation method for the prediction of the configuration performance.
Definition: AutoPasDecl.h:806
const std::set< DataLayoutOption > & getAllowedDataLayouts(const InteractionTypeOption interactionType=InteractionTypeOption::pairwise) const
Get the list of allowed data layouts.
Definition: AutoPasDecl.h:898
SelectorStrategyOption getSelectorStrategy() const
Get the selector configuration strategy.
Definition: AutoPasDecl.h:822
unsigned int getVerletClusterSize() const
Get Verlet cluster size.
Definition: AutoPasDecl.h:658
void addHaloParticlesIf(Collection &&particles, F predicate)
Adds all halo particles for which predicate(particle) == true to the container.
Definition: AutoPasImpl.h:262
void addParticles(Collection &&particles)
Adds all particles from the collection to the container.
Definition: AutoPasImpl.h:197
void setVerletSkin(double verletSkin)
Set length added to the cutoff for the Verlet lists' skin per timestep.
Definition: AutoPasDecl.h:639
void setOutputSuffix(const std::string &suffix)
Suffix for all output files produced by this instance of AutoPas, e.g.
Definition: AutoPasDecl.h:1059
void setMaxTuningPhasesWithoutTest(unsigned int maxTuningPhasesWithoutTest)
Set the maximum number of tuning phases before a configuration is certainly tested again.
Definition: AutoPasDecl.h:747
void setEnergySensorOption(EnergySensorOption energySensorOption)
Setter for the energy sensor.
Definition: AutoPasDecl.h:1017
unsigned long getContainerType() const
Returns the type of the currently used container.
Definition: AutoPasImpl.h:334
void forEach(Lambda forEachLambda, IteratorBehavior behavior=IteratorBehavior::ownedOrHalo)
Execute code on all particles as defined by a lambda function.
Definition: AutoPasDecl.h:310
const std::set< ContainerOption > & getAllowedContainers() const
Get the list of allowed containers.
Definition: AutoPasDecl.h:852
void deleteParticle(IteratorT &iter)
Deletes the particle behind the current iterator position and leaves the container in a valid state.
Definition: AutoPasImpl.h:288
void setAcquisitionFunction(AcquisitionFunctionOption acqFun)
Set acquisition function for tuning.
Definition: AutoPasDecl.h:798
void setEarlyStoppingFactor(double earlyStoppingFactor)
Set the earlyStoppingFactor for the auto tuner.
Definition: AutoPasDecl.h:695
void setMPITuningWeightForMaxDensity(double MPITuningWeightForMaxDensity)
Setter for the maxDensity-Weight in calculation for bucket distribution.
Definition: AutoPasDecl.h:1033
void reduceParallel(Lambda reduceLambda, A &result, IteratorBehavior behavior=IteratorBehavior::ownedOrHalo) const
Reduce properties of particles as defined by a lambda function.
Definition: AutoPasDecl.h:343
void reduceInRegion(Lambda reduceLambda, A &result, const std::array< double, 3 > &lowerCorner, const std::array< double, 3 > &higherCorner, IteratorBehavior behavior=IteratorBehavior::ownedOrHalo)
Execute code on all particles in a certain region as defined by a lambda function.
Definition: AutoPasDecl.h:518
void setEvidenceFirstPrediction(unsigned int evidenceFirstPrediction)
Set the number of tests that need to have happened for a configuration until the first predictions ar...
Definition: AutoPasDecl.h:780
void forEachParallel(Lambda forEachLambda, IteratorBehavior behavior=IteratorBehavior::ownedOrHalo)
execute code on all particles in parallel as defined by a lambda function
Definition: AutoPasDecl.h:288
const EnergySensorOption & getEnergySensorOption() const
Getter for the energy sensor.
Definition: AutoPasDecl.h:1011
double getRelativeOptimumRange() const
Get the range for the optimum in which has to be to be tested.
Definition: AutoPasDecl.h:725
void finalize()
Free the AutoPas MPI communicator.
Definition: AutoPasDecl.h:120
void setCellSizeFactor(double cellSizeFactor)
Set allowed cell size factors to one element (only relevant for LinkedCells, VerletLists and VerletLi...
Definition: AutoPasDecl.h:628
void setRelativeBlacklistRange(double relativeBlacklistRange)
Set the range of the configurations that are not going to be blacklisted.
Definition: AutoPasDecl.h:762
size_t getSortingThreshold() const
Get the sorting-threshold for traversals that use the CellFunctor.
Definition: AutoPasDecl.h:1107
unsigned int getEvidenceFirstPrediction() const
Get the number of tests that need to have happened for a configuration until the first predictions ar...
Definition: AutoPasDecl.h:771
void addParticlesIf(Collection &&particles, F predicate)
Adds all particles for which predicate(particle) == true to the container.
Definition: AutoPasImpl.h:203
double getRelativeBlacklistRange() const
For Predictive tuning: Get the relative cutoff for configurations to be blacklisted.
Definition: AutoPasDecl.h:756
void setTuningStrategyOption(const std::vector< TuningStrategyOption > &tuningStrategyOptions)
Setter for the tuning strategy option.
Definition: AutoPasDecl.h:988
autopas::ContainerIterator< Particle_T, true, true > RegionIteratorT
Define the region iterator type for ease of use.
Definition: AutoPasDecl.h:69
void forEachParallel(Lambda forEachLambda, IteratorBehavior behavior=IteratorBehavior::ownedOrHalo) const
execute code on all particles in parallel as defined by a lambda function
Definition: AutoPasDecl.h:298
std::vector< Particle_T > resizeBox(const std::array< double, 3 > &boxMin, const std::array< double, 3 > &boxMax)
Resizes the bounding box of the AutoPas object.
Definition: AutoPasImpl.h:229
void setMPITuningMaxDifferenceForBucket(double MPITuningMaxDifferenceForBucket)
Setter for the maximal Difference for the bucket distribution.
Definition: AutoPasDecl.h:1025
const TuningMetricOption & getTuningMetricOption() const
Getter for the tuning metric option.
Definition: AutoPasDecl.h:996
void setAllowedCellSizeFactors(const NumberSet< double > &allowedCellSizeFactors)
Set allowed cell size factors (only relevant for LinkedCells, VerletLists and VerletListsCells).
Definition: AutoPasDecl.h:616
void forEachInRegion(Lambda forEachLambda, const std::array< double, 3 > &lowerCorner, const std::array< double, 3 > &higherCorner, IteratorBehavior behavior=IteratorBehavior::ownedOrHalo) const
Execute code on all particles in a certain region as defined by a lambda function.
Definition: AutoPasDecl.h:464
void reduce(Lambda reduceLambda, A &result, IteratorBehavior behavior=IteratorBehavior::ownedOrHalo)
Reduce properties of particles as defined by a lambda function.
Definition: AutoPasDecl.h:357
void setAllowedLoadEstimators(const std::set< LoadEstimatorOption > &allowedLoadEstimators)
Set the list of allowed load estimation algorithms.
Definition: AutoPasDecl.h:844
double getVerletSkin()
Function to iterate over all pairs of particles in the container.
Definition: AutoPasDecl.h:544
void setAllowedTraversals(const std::set< TraversalOption > &allowedTraversals, const InteractionTypeOption interactionType=InteractionTypeOption::pairwise)
Set the list of allowed traversals.
Definition: AutoPasDecl.h:881
void reduceParallel(Lambda reduceLambda, A &result, IteratorBehavior behavior=IteratorBehavior::ownedOrHalo)
Reduce properties of particles in parallel as defined by a lambda function.
Definition: AutoPasDecl.h:333
AcquisitionFunctionOption getAcquisitionFunction() const
Get acquisition function used for tuning.
Definition: AutoPasDecl.h:788
void setVerletClusterSize(unsigned int verletClusterSize)
Set Verlet cluster size.
Definition: AutoPasDecl.h:664
void forEach(Lambda forEachLambda, IteratorBehavior behavior=IteratorBehavior::ownedOrHalo) const
Execute code on all particles as defined by a lambda function.
Definition: AutoPasDecl.h:319
const std::array< double, 3 > & getBoxMax() const
Get the upper corner of the container without the halo.
Definition: AutoPasImpl.h:344
const NumberSet< double > & getAllowedCellSizeFactors() const
Get allowed cell size factors (only relevant for LinkedCells, VerletLists and VerletListsCells).
Definition: AutoPasDecl.h:610
void addHaloParticle(const Particle_T &haloParticle)
Adds a particle to the container that lies in the halo region of the container.
Definition: AutoPasImpl.h:250
void setAllowedDataLayouts(const std::set< DataLayoutOption > &allowedDataLayouts, const InteractionTypeOption interactionType=InteractionTypeOption::pairwise)
Set the list of allowed data layouts.
Definition: AutoPasDecl.h:910
void setSortingThreshold(size_t sortingThreshold)
Set the sorting-threshold for traversals that use the CellFunctor If the sum of the number of particl...
Definition: AutoPasDecl.h:1101
Particle_T ParticleType
Particle type to be accessible after initialization.
Definition: AutoPasDecl.h:51
autopas::ContainerIterator< Particle_T, true, false > IteratorT
Define the iterator type for ease of use.
Definition: AutoPasDecl.h:57
RegionIteratorT getRegionIterator(const std::array< double, 3 > &lowerCorner, const std::array< double, 3 > &higherCorner, IteratorBehavior behavior=IteratorBehavior::ownedOrHalo)
Iterate over all particles in a specified region.
Definition: AutoPasImpl.h:321
void reduceInRegionParallel(Lambda reduceLambda, A &result, const std::array< double, 3 > &lowerCorner, const std::array< double, 3 > &higherCorner, IteratorBehavior behavior=IteratorBehavior::ownedOrHalo)
Execute code on all particles in a certain region in parallel as defined by a lambda function.
Definition: AutoPasDecl.h:484
double getMeanRebuildFrequency()
Getter for the mean rebuild frequency.
Definition: AutoPasDecl.h:1067
AutoPas & operator=(AutoPas &&other) noexcept
Move assignment operator.
Definition: AutoPasImpl.h:59
void setExtrapolationMethodOption(ExtrapolationMethodOption extrapolationMethodOption)
Set extrapolation method for the prediction of the configuration performance.
Definition: AutoPasDecl.h:814
void setBoxMin(const std::array< double, 3 > &boxMin)
Set coordinates of the lower corner of the domain.
Definition: AutoPasDecl.h:581
void init()
Initialize AutoPas.
Definition: AutoPasImpl.h:66
const std::vector< TuningStrategyOption > & getTuningStrategyOptions() const
Getter for the tuning strategy option.
Definition: AutoPasDecl.h:979
autopas::ContainerIterator< Particle_T, false, false > ConstIteratorT
Define the const iterator type for ease of use.
Definition: AutoPasDecl.h:63
void forceRetune()
Force the internal tuner to enter a new tuning phase upon the next call to computeInteractions().
Definition: AutoPasImpl.h:243
void setAllowedInteractionTypeOptions(const std::set< InteractionTypeOption > &allowedInteractionTypeOptions)
Set the list of allowed interaction types.
Definition: AutoPasDecl.h:956
void setVerletRebuildFrequency(unsigned int verletRebuildFrequency)
Set Verlet rebuild frequency.
Definition: AutoPasDecl.h:651
void forEachInRegion(Lambda forEachLambda, const std::array< double, 3 > &lowerCorner, const std::array< double, 3 > &higherCorner, IteratorBehavior behavior=IteratorBehavior::ownedOrHalo)
Execute code on all particles in a certain region as defined by a lambda function.
Definition: AutoPasDecl.h:451
const std::set< LoadEstimatorOption > & getAllowedLoadEstimators() const
Get the list of allowed load estimation algorithms.
Definition: AutoPasDecl.h:837
void setUseLOESSSmoothening(bool useLOESSSmoothening)
Set flag for whether a LOESS-based smoothening is used.
Definition: AutoPasDecl.h:707
size_t getNumberOfParticles(IteratorBehavior behavior=IteratorBehavior::owned) const
Returns the number of particles in this container.
Definition: AutoPasImpl.h:151
void reduceInRegionParallel(Lambda reduceLambda, A &result, const std::array< double, 3 > &lowerCorner, const std::array< double, 3 > &higherCorner, IteratorBehavior behavior=IteratorBehavior::ownedOrHalo) const
Execute code on all particles in a certain region as defined by a lambda function.
Definition: AutoPasDecl.h:498
void deleteAllParticles()
Deletes all particles.
Definition: AutoPasImpl.h:283
bool computeInteractions(Functor *f)
Function to iterate over all inter-particle interactions in the container This function only handles ...
Definition: AutoPasImpl.h:128
void forEachInRegionParallel(Lambda forEachLambda, const std::array< double, 3 > &lowerCorner, const std::array< double, 3 > &higherCorner, IteratorBehavior behavior=IteratorBehavior::ownedOrHalo)
Execute code on all particles in a certain region in parallel as defined by a lambda function.
Definition: AutoPasDecl.h:419
void addParticle(const Particle_T &p)
Adds a particle to the container.
Definition: AutoPasImpl.h:191
void forEachInRegionParallel(Lambda forEachLambda, const std::array< double, 3 > &lowerCorner, const std::array< double, 3 > &higherCorner, IteratorBehavior behavior=IteratorBehavior::ownedOrHalo) const
Execute code on all particles in a certain region in parallel as defined by a lambda function.
Definition: AutoPasDecl.h:433
bool getUseLOESSSmoothening() const
Get flag for whether a LOESS-based smoothening is used.
Definition: AutoPasDecl.h:701
double getCutoff() const
Get cutoff radius.
Definition: AutoPasDecl.h:593
IteratorT begin(IteratorBehavior behavior=IteratorBehavior::ownedOrHalo)
Iterate over all particles by using for(auto iter = autoPas.begin(); iter.isValid(); ++iter)
Definition: AutoPasImpl.h:311
std::unordered_map< InteractionTypeOption::Value, std::reference_wrapper< const Configuration > > getCurrentConfigs() const
Getter for the currently selected configuration.
Definition: AutoPasDecl.h:965
void setRelativeOptimumRange(double relativeOptimumRange)
Set the range for the optimum in which has to be to be tested.
Definition: AutoPasDecl.h:731
void setAllowedContainers(const std::set< ContainerOption > &allowedContainers)
Set the list of allowed containers.
Definition: AutoPasDecl.h:859
void setCutoff(double cutoff)
Set cutoff radius.
Definition: AutoPasDecl.h:599
void setTuningInterval(unsigned int tuningInterval)
Set tuning interval.
Definition: AutoPasDecl.h:676
constexpr bool end() const
Dummy to make range-based for loops work.
Definition: AutoPasDecl.h:386
const std::set< Newton3Option > & getAllowedNewton3Options(const InteractionTypeOption interactionType=InteractionTypeOption::pairwise) const
Get the list of allowed newton 3 options.
Definition: AutoPasDecl.h:927
Public iterator class that iterates over a particle container and additional vectors (which are typic...
Definition: ContainerIterator.h:93
Class representing the different energy sensor options.
Definition: EnergySensorOption.h:19
Functor base class.
Definition: Functor.h:40
double verletSkin
Length added to the cutoff for the Verlet lists' skin.
Definition: LogicHandlerInfo.h:33
std::array< double, 3 > boxMax
Upper corner of the container without halo.
Definition: LogicHandlerInfo.h:25
unsigned int verletClusterSize
Number of particles in a cluster to use in VCL.
Definition: LogicHandlerInfo.h:37
double cutoff
Cutoff radius to be used in this simulation.
Definition: LogicHandlerInfo.h:29
std::array< double, 3 > boxMin
Lower corner of the container without halo.
Definition: LogicHandlerInfo.h:21
The LogicHandler takes care of the containers s.t.
Definition: LogicHandler.h:47
Virtual class describing a finite or infinite set of numbers.
Definition: NumberSet.h:22
virtual Number getMin() const =0
Get the smallest number in the set.
virtual std::unique_ptr< NumberSet > clone() const =0
Create a copy of a NumberSet.
The ParticleContainerInterface class provides a basic interface for all Containers within AutoPas.
Definition: ParticleContainerInterface.h:37
Class representing the load estimator choices.
Definition: TuningMetricOption.h:18
static void exception(const Exception e)
Handle an exception derived by std::exception.
Definition: ExceptionHandler.h:63
This is the main namespace of AutoPas.
Definition: AutoPasDecl.h:32
decltype(auto) withStaticContainerType(autopas::ParticleContainerInterface< Particle_T > &container, FunctionType &&function)
Will execute the passed function body with the static container type of container.
Definition: StaticContainerSelector.h:33
int AutoPas_MPI_Comm_free(AutoPas_MPI_Comm *comm)
Wrapper for MPI_Comm_free.
Definition: WrapMPI.h:820
unsigned int tuningInterval
Number of time steps after which the auto-tuner shall reevaluate the optimum.
Definition: AutoTunerInfo.h:29
SelectorStrategyOption selectorStrategy
Strategy how to select the optimum from the collected samples.
Definition: AutoTunerInfo.h:21
unsigned int maxSamples
Number of samples that shall be collected per combination.
Definition: AutoTunerInfo.h:33
bool useLOESSSmoothening
Flag for whether LOESS Smoothening is used to smoothen the tuning results.
Definition: AutoTunerInfo.h:46
TuningMetricOption tuningMetric
Metric used to rate configurations (time or energy).
Definition: AutoTunerInfo.h:25
double earlyStoppingFactor
EarlyStoppingFactor for the auto-tuner.
Definition: AutoTunerInfo.h:38
EnergySensorOption energySensor
Used energy sensor of energy metric selected.
Definition: AutoTunerInfo.h:42
Helper struct encapsulating most information needed to build TuningStrategies by the TuningStrategyFa...
Definition: TuningStrategyFactoryInfo.h:22
double mpiTuningWeightForMaxDensity
Weight for maxDensity in the calculation for bucket distribution.
Definition: TuningStrategyFactoryInfo.h:87
double mpiTuningMaxDifferenceForBucket
Maximum absolute difference in similarity metric for two ranks to fall in the same bucket.
Definition: TuningStrategyFactoryInfo.h:83
std::string ruleFileName
The name and path of the file where the rules are stored.
Definition: TuningStrategyFactoryInfo.h:66
unsigned int maxEvidence
Strategies that don't converge (or not quickly enough) can be told to limit the number of evidence to...
Definition: TuningStrategyFactoryInfo.h:27
AcquisitionFunctionOption acquisitionFunctionOption
Function used to predict informational gain.
Definition: TuningStrategyFactoryInfo.h:60
std::string fuzzyRuleFileName
The name and path of the file where the rules are stored.
Definition: TuningStrategyFactoryInfo.h:72
unsigned int maxTuningPhasesWithoutTest
If a config is not tested for this number of tuning phases test it again to make predictions more rel...
Definition: TuningStrategyFactoryInfo.h:44
double relativeBlacklistRange
Any configuration that is slower than the fastest times this factor will be blacklisted.
Definition: TuningStrategyFactoryInfo.h:54
ExtrapolationMethodOption extrapolationMethodOption
Function option used for extrapolating performance from observed evidence.
Definition: TuningStrategyFactoryInfo.h:36
double relativeOptimumRange
Factor of the range of the optimal configurations for the optimalSearchSpace.
Definition: TuningStrategyFactoryInfo.h:40
unsigned int minNumberOfEvidence
The number of evidence that have to be collected until the first prediction can be made.
Definition: TuningStrategyFactoryInfo.h:48
AutoPas_MPI_Comm autopasMpiCommunicator
MPI Communicator used within AutoPas.
Definition: TuningStrategyFactoryInfo.h:91