Commit be68a904 authored by Yaroslav Gevorkov's avatar Yaroslav Gevorkov
Browse files

added multi seed lengths refinement

parent 8e38d797
......@@ -39,6 +39,7 @@ class PinkIndexer
fixedLatticeParameters,
variableLatticeParameters,
firstFixedThenVariableLatticeParameters,
firstFixedThenVariableLatticeParametersMultiSeedLengths,
firstFixedThenVariableLatticeParametersMultiSeed
};
......
......@@ -34,7 +34,8 @@ typedef enum {
REFINEMENT_TYPE_fixedLatticeParameters = 1,
REFINEMENT_TYPE_variableLatticeParameters = 2,
REFINEMENT_TYPE_firstFixedThenVariableLatticeParameters = 3,
REFINEMENT_TYPE_firstFixedThenVariableLatticeParametersMultiSeed = 4,
REFINEMENT_TYPE_firstFixedThenVariableLatticeParametersMultiSeedLengths = 4,
REFINEMENT_TYPE_firstFixedThenVariableLatticeParametersMultiSeed = 5,
REFINEMENT_TYPE_lastEnum
} refinementType_t;
......
......@@ -99,17 +99,58 @@ void PinkIndexer::refine(Lattice& indexedLattice, const Matrix3Xf& ucsDirections
refinement.setTolerance(finalRefinementTolerance);
refinement.refineVariableLattice(indexedLattice, ucsDirections, ucsBorderNorms);
break;
case RefinementType::firstFixedThenVariableLatticeParametersMultiSeedLengths:
{
constexpr unsigned refinemenTries = 750;
int fittedNodesCount[refinemenTries];
double fittedNodesMeanDefects[refinemenTries];
Lattice fittedLattices[refinemenTries];
float maxRelativeDeviation = 0.0125;
#pragma omp parallel for
for (int i = 0; i < refinemenTries; ++i)
{
Refinement refinement(finalRefinementTolerance);
Matrix3f currentBasis = (indexedLattice.getBasis().array().rowwise() * (Array<float, 1, 3>::Random() * maxRelativeDeviation + 1)).array();
fittedLattices[i] = Lattice(currentBasis);
refinement.setTolerance(min(finalRefinementTolerance * 2.5, 0.12));
refinement.refineFixedLattice(fittedLattices[i], ucsDirections, ucsBorderNorms);
refinement.setTolerance(min(finalRefinementTolerance * 1.8, 0.10));
refinement.refineVariableLattice(fittedLattices[i], ucsDirections, ucsBorderNorms);
refinement.setTolerance(finalRefinementTolerance);
refinement.refineVariableLattice(fittedLattices[i], ucsDirections, ucsBorderNorms);
fittedNodesCount[i] = refinement.getFittedPeaksCount(fittedLattices[i], ucsDirections, ucsBorderNorms);
fittedNodesMeanDefects[i] = refinement.getMeanDefect(fittedLattices[i].getBasis(), ucsDirections, ucsBorderNorms);
}
int maxFittedNodesCount = refinement.getFittedPeaksCount(indexedLattice, ucsDirections, ucsBorderNorms);
double minFittedNodesMeanDefect = refinement.getMeanDefect(indexedLattice.getBasis(), ucsDirections, ucsBorderNorms);
for (int i = 0; i < refinemenTries; ++i)
{
if (fittedNodesCount[i] > maxFittedNodesCount ||
(fittedNodesCount[i] == maxFittedNodesCount && fittedNodesMeanDefects[i] < minFittedNodesMeanDefect))
{
maxFittedNodesCount = fittedNodesCount[i];
minFittedNodesMeanDefect = fittedNodesMeanDefects[i];
indexedLattice = fittedLattices[i];
}
}
}
break;
case RefinementType::firstFixedThenVariableLatticeParametersMultiSeed:
{
#define REFINEMENT_TRIES 750
int fittedNodesCount[REFINEMENT_TRIES];
double fittedNodesMeanDefects[REFINEMENT_TRIES];
Lattice fittedLattices[REFINEMENT_TRIES];
constexpr unsigned refinementTries = 750;
int fittedNodesCount[refinementTries];
double fittedNodesMeanDefects[refinementTries];
Lattice fittedLattices[refinementTries];
float maxRelativeDeviation = 0.0125;
Array<float, 1, 3> columnDeviationNorms = indexedLattice.getBasis().colwise().norm() * maxRelativeDeviation;
#pragma omp parallel for
for (int i = 0; i < REFINEMENT_TRIES; ++i)
for (int i = 0; i < refinementTries; ++i)
{
Refinement refinement(finalRefinementTolerance);
......@@ -129,9 +170,10 @@ void PinkIndexer::refine(Lattice& indexedLattice, const Matrix3Xf& ucsDirections
int maxFittedNodesCount = refinement.getFittedPeaksCount(indexedLattice, ucsDirections, ucsBorderNorms);
double minFittedNodesMeanDefect = refinement.getMeanDefect(indexedLattice.getBasis(), ucsDirections, ucsBorderNorms);
for (int i = 0; i < REFINEMENT_TRIES; ++i)
for (int i = 0; i < refinementTries; ++i)
{
if (fittedNodesCount[i] > maxFittedNodesCount || (fittedNodesCount[i] == maxFittedNodesCount && fittedNodesMeanDefects[i] < minFittedNodesMeanDefect))
if (fittedNodesCount[i] > maxFittedNodesCount ||
(fittedNodesCount[i] == maxFittedNodesCount && fittedNodesMeanDefects[i] < minFittedNodesMeanDefect))
{
maxFittedNodesCount = fittedNodesCount[i];
minFittedNodesMeanDefect = fittedNodesMeanDefects[i];
......
......@@ -70,6 +70,9 @@ extern "C" PinkIndexer* PinkIndexer_new(ExperimentSettings* experimentSettings,
case REFINEMENT_TYPE_firstFixedThenVariableLatticeParameters:
refinementType_enumClass = PinkIndexer::RefinementType::firstFixedThenVariableLatticeParameters;
break;
case REFINEMENT_TYPE_firstFixedThenVariableLatticeParametersMultiSeedLengths:
refinementType_enumClass = PinkIndexer::RefinementType::firstFixedThenVariableLatticeParametersMultiSeedLengths;
break;
case REFINEMENT_TYPE_firstFixedThenVariableLatticeParametersMultiSeed:
refinementType_enumClass = PinkIndexer::RefinementType::firstFixedThenVariableLatticeParametersMultiSeed;
break;
......
Markdown is supported
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