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 { plumed_error(); } 64 : }; 65 : 66 : inline 67 126447 : unsigned LandmarkSelectionBase::getNumberOfDataPoints() const { 68 126447 : return nlandmarks; 69 : } 70 : 71 : inline 72 125002 : unsigned LandmarkSelectionBase::getDataPointIndexInBase( const unsigned& idata ) const { 73 125002 : return AnalysisBase::getDataPointIndexInBase( landmark_indices[idata] ); 74 : } 75 : 76 : inline 77 8361301 : double LandmarkSelectionBase::getWeight( const unsigned& idata ) { 78 8361301 : return lweights[idata]; 79 : } 80 : 81 : inline 82 531 : DataCollectionObject& LandmarkSelectionBase::getStoredData( const unsigned& idat, const bool& calcdist ) { 83 531 : return AnalysisBase::getStoredData( landmark_indices[idat], calcdist ); 84 : } 85 : 86 : inline 87 62329 : double LandmarkSelectionBase::getDissimilarity( const unsigned& i, const unsigned& j ) { 88 62329 : return AnalysisBase::getDissimilarity( landmark_indices[i], landmark_indices[j] ); 89 : } 90 : 91 : } 92 : } 93 : #endif