Commit 826feb4f authored by Yaroslav Gevorkov's avatar Yaroslav Gevorkov
Browse files

added openmp for multi seed refinement

parent c22fe6fb
......@@ -13,6 +13,7 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
endif()
find_package(Eigen3 3.3.4 NO_MODULE)
find_package(OpenMP)
include_directories(include)
......@@ -41,12 +42,16 @@ set(SOURCES_test src/main.cpp
src/tests.cpp
)
if(PINKINDEXER_BUILD_EXECUTABLE)
if(PINKINDEXER_BUILD_EXECUTABLE)
add_executable(pinkIndexer ${SOURCES} ${SOURCES_test})
else(PINKINDEXER_BUILD_EXECUTABLE)
add_library(pinkIndexer SHARED ${SOURCES})
endif(PINKINDEXER_BUILD_EXECUTABLE)
if(OpenMP_CXX_FOUND)
target_link_libraries(pinkIndexer PUBLIC OpenMP::OpenMP_CXX)
endif(OpenMP_CXX_FOUND)
if(EIGEN3_FOUND)
target_link_libraries (pinkIndexer PUBLIC Eigen3::Eigen)
else()
......
......@@ -63,7 +63,6 @@ int PinkIndexer::indexPattern(Lattice& indexedLattice, Eigen::Array<bool, Eigen:
Matrix3f bestBasis = bestRotation * sampleLattice.getBasis();
indexedLattice = Lattice(bestBasis);
// indexedLattice.minimize();
switch (refinementType)
{
......@@ -91,37 +90,48 @@ int PinkIndexer::indexPattern(Lattice& indexedLattice, Eigen::Array<bool, Eigen:
break;
case RefinementType::firstFixedThenVariableLatticeParametersMultiSeed:
{
Lattice bestLattice = indexedLattice;
int maxFittedNodesCount = refinement.getFittedPeaks(indexedLattice, fittedPeaks, ucsDirections, ucsBorderNorms);
#define REFINEMENT_TRIES 250
int fittedNodesCount[REFINEMENT_TRIES];
Lattice fittedLattices[REFINEMENT_TRIES];
float maxRelativeDeviation = 0.01;
float maxRelativeDeviation = 0.012;
Array<float, 1, 3> columnDeviationNorms = indexedLattice.getBasis().colwise().norm() * maxRelativeDeviation;
for (uint32_t i = 0; i < 16; ++i)
#pragma omp parallel for
for (int i = 0; i < REFINEMENT_TRIES; ++i)
{
Matrix3f currentBasis = indexedLattice.getBasis() + (Array33f::Random().rowwise() * columnDeviationNorms ).matrix();
Lattice currentLattice(currentBasis);
Refinement refinement(finalRefinementTolerance);
Matrix3f currentBasis = indexedLattice.getBasis() + (Array33f::Random().rowwise() * columnDeviationNorms).matrix();
fittedLattices[i] = Lattice(currentBasis);
refinement.setTolerance(min(finalRefinementTolerance * 2.5, 0.12));
refinement.refineFixedLattice(currentLattice, ucsDirections, ucsBorderNorms);
refinement.refineFixedLattice(fittedLattices[i], ucsDirections, ucsBorderNorms);
refinement.setTolerance(min(finalRefinementTolerance * 1.8, 0.10));
refinement.refineVariableLattice(currentLattice, ucsDirections, ucsBorderNorms);
refinement.refineVariableLattice(fittedLattices[i], ucsDirections, ucsBorderNorms);
refinement.setTolerance(finalRefinementTolerance);
refinement.refineVariableLattice(currentLattice, ucsDirections, ucsBorderNorms);
refinement.refineVariableLattice(fittedLattices[i], ucsDirections, ucsBorderNorms);
fittedNodesCount[i] = refinement.getFittedPeaks(fittedLattices[i], fittedPeaks, ucsDirections, ucsBorderNorms);
}
int fittedNodesCount = refinement.getFittedPeaks(currentLattice, fittedPeaks, ucsDirections, ucsBorderNorms);
if (fittedNodesCount > maxFittedNodesCount)
Lattice bestLattice = indexedLattice;
int maxFittedNodesCount = refinement.getFittedPeaks(indexedLattice, fittedPeaks, ucsDirections, ucsBorderNorms);
for (int i = 0; i < REFINEMENT_TRIES; ++i)
{
if (fittedNodesCount[i] > maxFittedNodesCount)
{
maxFittedNodesCount = fittedNodesCount;
bestLattice = currentLattice;
maxFittedNodesCount = fittedNodesCount[i];
indexedLattice = fittedLattices[i];
}
}
indexedLattice = bestLattice;
}
break;
default:
break;
}
indexedLattice.minimize();
return refinement.getFittedPeaks(indexedLattice, fittedPeaks, ucsDirections, ucsBorderNorms);
// int fittedPeaksCount = refinement.getFittedPeaksCount(indexedLattice, ucsDirections, ucsBorderNorms);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment