Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 : Copyright (c) 2013-2023 The plumed team 3 : (see the PEOPLE file at the root of the distribution for a list of names) 4 : 5 : See http://www.plumed.org for more information. 6 : 7 : This file is part of plumed, version 2. 8 : 9 : plumed is free software: you can redistribute it and/or modify 10 : it under the terms of the GNU Lesser General Public License as published by 11 : the Free Software Foundation, either version 3 of the License, or 12 : (at your option) any later version. 13 : 14 : plumed is distributed in the hope that it will be useful, 15 : but WITHOUT ANY WARRANTY; without even the implied warranty of 16 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 : GNU Lesser General Public License for more details. 18 : 19 : You should have received a copy of the GNU Lesser General Public License 20 : along with plumed. If not, see <http://www.gnu.org/licenses/>. 21 : +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ 22 : #ifndef __PLUMED_analysis_LandmarkSelectionBase_h 23 : #define __PLUMED_analysis_LandmarkSelectionBase_h 24 : 25 : #include "AnalysisBase.h" 26 : 27 : namespace PLMD { 28 : namespace analysis { 29 : 30 : class LandmarkSelectionBase : public AnalysisBase { 31 : friend class ReselectLandmarks; 32 : private: 33 : /// The number of landmarks we are selecting 34 : unsigned nlandmarks; 35 : /// The weights of the landmark points 36 : std::vector<double> lweights; 37 : /// The indices of the landmarks in the original data set 38 : std::vector<unsigned> landmark_indices; 39 : /// How do we treat weights 40 : bool novoronoi, noweights; 41 : protected: 42 : /// Transfer frame i in the underlying action to the object we are going to analyze 43 : void selectFrame( const unsigned& ); 44 : /// Do a voronoi analysis 45 : void voronoiAnalysis( const std::vector<unsigned>& myindices, std::vector<double>& lweights, std::vector<unsigned>& assignments ) const ; 46 : public: 47 : static void registerKeywords( Keywords& keys ); 48 : explicit LandmarkSelectionBase( const ActionOptions& ao ); 49 : /// Return the number of data points 50 : unsigned getNumberOfDataPoints() const override; 51 : /// Return the index of the data point in the base class 52 : unsigned getDataPointIndexInBase( const unsigned& idata ) const override; 53 : /// Get the weight 54 : double getWeight( const unsigned& idata ) override; 55 : /// Get a reference configuration 56 : DataCollectionObject& getStoredData( const unsigned& idat, const bool& calcdist ) override; 57 : /// Select landmark configurations 58 : void performAnalysis() override; 59 : virtual void selectLandmarks()=0; 60 : /// Get the squared dissimilarity between two reference configurations 61 : double getDissimilarity( const unsigned& i, const unsigned& j ) override; 62 : /// This does nothing - it just ensures the final class is not abstract 63 0 : void performTask( const unsigned&, const unsigned&, MultiValue& ) const override { 64 0 : plumed_error(); 65 : } 66 : }; 67 : 68 : inline 69 126447 : unsigned LandmarkSelectionBase::getNumberOfDataPoints() const { 70 126447 : return nlandmarks; 71 : } 72 : 73 : inline 74 125002 : unsigned LandmarkSelectionBase::getDataPointIndexInBase( const unsigned& idata ) const { 75 125002 : return AnalysisBase::getDataPointIndexInBase( landmark_indices[idata] ); 76 : } 77 : 78 : inline 79 8361301 : double LandmarkSelectionBase::getWeight( const unsigned& idata ) { 80 8361301 : return lweights[idata]; 81 : } 82 : 83 : inline 84 531 : DataCollectionObject& LandmarkSelectionBase::getStoredData( const unsigned& idat, const bool& calcdist ) { 85 531 : return AnalysisBase::getStoredData( landmark_indices[idat], calcdist ); 86 : } 87 : 88 : inline 89 62329 : double LandmarkSelectionBase::getDissimilarity( const unsigned& i, const unsigned& j ) { 90 62329 : return AnalysisBase::getDissimilarity( landmark_indices[i], landmark_indices[j] ); 91 : } 92 : 93 : } 94 : } 95 : #endif