Skip to content
Snippets Groups Projects
Commit bf21c583 authored by sandipde's avatar sandipde
Browse files

Fixed implementation of lowmem in EuclideanDissimilarityMatrix

parent 8c0513ba
No related branches found
No related tags found
No related merge requests found
......@@ -32,7 +32,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.reset_style("TIMINGS","hidden"); keys.isAnalysis();
ActionWithVessel::registerKeywords( keys ); keys.remove("TOL"); 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");
}
......
......@@ -37,7 +37,6 @@ namespace analysis {
class EuclideanDissimilarityMatrix : public AnalysisWithDataCollection {
private:
bool lowmem;
Matrix<double> dissimilarities;
public:
static void registerKeywords( Keywords& keys );
......@@ -57,27 +56,24 @@ PLUMED_REGISTER_ACTION(EuclideanDissimilarityMatrix,"EUCLIDEAN_DISSIMILARITIES")
void EuclideanDissimilarityMatrix::registerKeywords( Keywords& keys ){
AnalysisWithDataCollection::registerKeywords( keys );
keys.reset_style("METRIC","atoms-1"); keys.use("FRAMES");
keys.addFlag("LOWMEM",false,"lower the memory requirements of the calculation");
}
EuclideanDissimilarityMatrix::EuclideanDissimilarityMatrix( const ActionOptions& ao ):
Action(ao),
AnalysisWithDataCollection(ao)
{
parseFlag("LOWMEM",lowmem);
if( lowmem ) log.printf(" lowering memory requirements \n");
}
void EuclideanDissimilarityMatrix::performAnalysis(){
// Resize dissimilarities matrix and set all elements to zero
if( !lowmem ){
if( !usingLowMem() ){
dissimilarities.resize( getNumberOfDataPoints(), getNumberOfDataPoints() ); dissimilarities=0;
}
}
double EuclideanDissimilarityMatrix::getDissimilarity( const unsigned& iframe, const unsigned& jframe ){
plumed_dbg_assert( iframe<getNumberOfDataPoints() && jframe<getNumberOfDataPoints() );
if( !lowmem ){
if( !usingLowMem() ){
if( dissimilarities(iframe,jframe)>0. ){ return dissimilarities(iframe,jframe); }
}
if( iframe!=jframe ){
......@@ -85,9 +81,11 @@ double EuclideanDissimilarityMatrix::getDissimilarity( const unsigned& iframe, c
if( mydata ){ myref1=AnalysisBase::getReferenceConfiguration(iframe,true); myref2=AnalysisBase::getReferenceConfiguration(jframe,true); }
else { myref1 = data[iframe]; myref2 = data[jframe]; }
if( myref1->getNumberOfProperties()>0 ){
dissimilarities(iframe,jframe) = dissimilarities(jframe,iframe) = property_distance( myref1, myref2, true );
if( !usingLowMem() ) dissimilarities(iframe,jframe) = dissimilarities(jframe,iframe) = property_distance( myref1, myref2, true );
else return property_distance( myref1, myref2, true );
} else {
dissimilarities(iframe,jframe) = dissimilarities(jframe,iframe) = distance( getPbc(), getArguments(), myref1, myref2, true );
if( !usingLowMem() ) dissimilarities(iframe,jframe) = dissimilarities(jframe,iframe) = distance( getPbc(), getArguments(), myref1, myref2, true );
else return distance( getPbc(), getArguments(), myref1, myref2, true );
}
return dissimilarities(iframe,jframe);
}
......
......@@ -64,6 +64,7 @@ void DimensionalityReductionBase::getDataPoint( const unsigned& idata, std::vect
}
void DimensionalityReductionBase::performAnalysis(){
log.printf("Generating projections required by action %s \n",getLabel().c_str() );
// Resize the tempory array (this is used for out of sample)
dtargets.resize( getNumberOfDataPoints() );
// Resize the projections array
......@@ -84,6 +85,7 @@ void DimensionalityReductionBase::performAnalysis(){
}
// This calculates the projections of the points
calculateProjections( targets, projections );
log.printf("Generated projections required by action %s \n",getLabel().c_str() );
}
double DimensionalityReductionBase::calculateStress( const std::vector<double>& p, std::vector<double>& d ){
......
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