Skip to content
Snippets Groups Projects
Commit 32c6275e authored by Gareth Tribello's avatar Gareth Tribello
Browse files

Added function to select the landmarks indices from a second different collection object

parent 1d0a9981
No related branches found
No related tags found
No related merge requests found
include ../../scripts/test.make
type=driver
# this is to test a different name
arg="--plumed plumed.dat --ixyz trajectory.xyz --dump-forces forces --dump-forces-fmt=%10.6f"
extra_files="../../trajectories/trajectory.xyz"
#! FIELDS dist
1.2626
1.3934
0.0000 0.0171
0.0171 0.0000
dist: DISTANCE ATOMS=1,2
ss1: EUCLIDEAN_DISSIMILARITIES ATOMS=1-5 METRIC=OPTIMAL STRIDE=1 USE_ALL_DATA
ss2: EUCLIDEAN_DISSIMILARITIES ARG=dist STRIDE=1 USE_ALL_DATA
l1: LANDMARK_SELECT_STRIDE USE_OUTPUT_DATA_FROM=ss1 NLANDMARKS=2
l2: RESELECT_LANDMARKS USE_OUTPUT_DATA_FROM=ss2 LANDMARKS=l1
OUTPUT_ANALYSIS_DATA_TO_COLVAR USE_OUTPUT_DATA_FROM=l2 FILE=data FMT=%8.4f
PRINT_DISSIMILARITY_MATRIX USE_OUTPUT_DATA_FROM=l2 FILE=mymatrix.dat FMT=%8.4f
......@@ -31,7 +31,7 @@ void AnalysisBase::registerKeywords( Keywords& keys ){
ActionPilot::registerKeywords( keys );
ActionAtomistic::registerKeywords( keys );
ActionWithArguments::registerKeywords( keys );
ActionWithVessel::registerKeywords( keys ); keys.remove("TOL"); keys.remove("LOWMEM"); keys.remove("TIMINGS"); keys.isAnalysis();
ActionWithVessel::registerKeywords( keys ); keys.remove("TOL"); keys.remove("LOWMEM"); keys.reset_style("TIMINGS","hidden"); keys.isAnalysis();
keys.add("atoms-2","USE_OUTPUT_DATA_FROM","use the ouput of the analysis performed by this object as input to your new analysis object");
}
......
......@@ -46,6 +46,7 @@ class AnalysisBase :
public ActionWithArguments,
public vesselbase::ActionWithVessel
{
friend class ReselectLandmarks;
friend class ReadDissimilarityMatrix;
friend class AnalysisWithDataCollection;
private:
......
......@@ -55,6 +55,7 @@ PLUMED_REGISTER_ACTION(EuclideanDissimilarityMatrix,"EUCLIDEAN_DISSIMILARITIES")
void EuclideanDissimilarityMatrix::registerKeywords( Keywords& keys ){
AnalysisWithDataCollection::registerKeywords( keys );
keys.reset_style("METRIC","atoms-1");
}
EuclideanDissimilarityMatrix::EuclideanDissimilarityMatrix( const ActionOptions& ao ):
......
......@@ -42,7 +42,7 @@ LandmarkSelectionBase::LandmarkSelectionBase( const ActionOptions& ao ):
Action(ao),
AnalysisWithDataCollection(ao)
{
parse("NLANDMARKS",nlandmarks);
if( keywords.exists("NLANDMARKS") ) parse("NLANDMARKS",nlandmarks);
log.printf(" selecting %d landmark points \n",nlandmarks);
lweights.resize( nlandmarks );
......@@ -60,6 +60,7 @@ void LandmarkSelectionBase::selectFrame( const unsigned& iframe ){
void LandmarkSelectionBase::performAnalysis(){
landmark_indices.resize(0); selectLandmarks();
plumed_dbg_assert( nlandmarks==getNumberOfDataPoints() );
if( lweights.size()!=nlandmarks ) lweights.resize( nlandmarks );
if( !novoronoi ){
lweights.assign(lweights.size(),0.0);
......
......@@ -28,6 +28,7 @@ namespace PLMD {
namespace analysis {
class LandmarkSelectionBase : public AnalysisWithDataCollection {
friend class ReselectLandmarks;
private:
/// The number of landmarks we are selecting
unsigned nlandmarks;
......
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Copyright (c) 2012-2014 The plumed team
(see the PEOPLE file at the root of the distribution for a list of names)
See http://www.plumed-code.org for more information.
This file is part of plumed, version 2.
plumed is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
plumed is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with plumed. If not, see <http://www.gnu.org/licenses/>.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#include "LandmarkSelectionBase.h"
#include "core/ActionRegister.h"
#include "core/PlumedMain.h"
#include "core/ActionSet.h"
#include "tools/Random.h"
//+PLUMEDOC LANDMARKS RESELECT_LANDMARKS
/*
This allows us to use one measure in landmark selection and a different measure in dimensionality reduction
\par Examples
*/
//+ENDPLUMEDOC
namespace PLMD {
namespace analysis {
class ReselectLandmarks : public LandmarkSelectionBase {
private:
LandmarkSelectionBase* mylandmarks;
public:
static void registerKeywords( Keywords& keys );
ReselectLandmarks( const ActionOptions& ao );
void selectLandmarks();
};
PLUMED_REGISTER_ACTION(ReselectLandmarks,"RESELECT_LANDMARKS")
void ReselectLandmarks::registerKeywords( Keywords& keys ){
LandmarkSelectionBase::registerKeywords(keys);
LandmarkSelectionBase::removeDataCollectionKeywords( keys );
keys.remove("NLANDMARKS");
keys.add("compulsory","LANDMARKS","the action that selects the landmarks that you want to reselect using this action");
}
ReselectLandmarks::ReselectLandmarks( const ActionOptions& ao ):
Action(ao),
LandmarkSelectionBase(ao)
{
std::string datastr; parse("LANDMARKS",datastr);
mylandmarks = plumed.getActionSet().selectWithLabel<LandmarkSelectionBase*>( datastr );
if( !mylandmarks ) error("input to LANDMARKS is not a landmark selection action");
nlandmarks = mylandmarks->nlandmarks;
if( (mylandmarks->mydata)->getNumberOfDataPoints()!=mydata->getNumberOfDataPoints() ||
mylandmarks->use_all_data!=mydata->use_all_data ) error("mismatch between ammount of landmark class and base class");
}
void ReselectLandmarks::selectLandmarks(){
for(unsigned i=0;i<mylandmarks->getNumberOfDataPoints();++i) selectFrame( mylandmarks->getDataPointIndexInBase(i) );
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment