1 /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 Copyright (c) 2013-2021 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
performTask(const unsigned &,const unsigned &,MultiValue &)63 void performTask( const unsigned&, const unsigned&, MultiValue& ) const override { plumed_error(); }
64 };
65
66 inline
getNumberOfDataPoints()67 unsigned LandmarkSelectionBase::getNumberOfDataPoints() const {
68 return nlandmarks;
69 }
70
71 inline
getDataPointIndexInBase(const unsigned & idata)72 unsigned LandmarkSelectionBase::getDataPointIndexInBase( const unsigned& idata ) const {
73 return AnalysisBase::getDataPointIndexInBase( landmark_indices[idata] );
74 }
75
76 inline
getWeight(const unsigned & idata)77 double LandmarkSelectionBase::getWeight( const unsigned& idata ) {
78 return lweights[idata];
79 }
80
81 inline
getStoredData(const unsigned & idat,const bool & calcdist)82 DataCollectionObject& LandmarkSelectionBase::getStoredData( const unsigned& idat, const bool& calcdist ) {
83 return AnalysisBase::getStoredData( landmark_indices[idat], calcdist );
84 }
85
86 inline
getDissimilarity(const unsigned & i,const unsigned & j)87 double LandmarkSelectionBase::getDissimilarity( const unsigned& i, const unsigned& j ) {
88 return AnalysisBase::getDissimilarity( landmark_indices[i], landmark_indices[j] );
89 }
90
91 }
92 }
93 #endif
94