Commit 96c46e23 authored by Miroslav Shaltev's avatar Miroslav Shaltev
Browse files

work on hybrid search with partial lattice

parent c6072a3c
......@@ -593,7 +593,7 @@ int main(int argc, char *argv[]) {
MFCSearch->Semicohmetric(semig);
}
if (MFCSearch->HybridSearch() && !MFCSearch->HybridSearchLatticeAtOnce()) {
if (MFCSearch->HybridSearch() && MFCSearch->HybridSearchLatticeAtOnce()) {
MFCSearch->HybridSearchCreateLattice(MFCSearch->Semicohmetric(),MFCSearch->HybridSearchMismatch(),MFCSearch->HybridSearchLattice());
}
......@@ -727,7 +727,7 @@ int main(int argc, char *argv[]) {
MFCSearch->Cohmetric(g);
}
if (MFCSearch->HybridSearch() && !MFCSearch->HybridSearchLatticeAtOnce()) {
if (MFCSearch->HybridSearch() && MFCSearch->HybridSearchLatticeAtOnce()) {
MFCSearch->HybridSearchCreateLattice(MFCSearch->Cohmetric(),MFCSearch->HybridSearchMismatch(),MFCSearch->HybridSearchLattice());
}
......@@ -866,7 +866,7 @@ int main(int argc, char *argv[]) {
MFCSearch->SaveMetric(MFCSearch->MetricFile(SCStage,SCMETRIC),MFCSearch->Semicohmetric());
}
if (MFCSearch->HybridSearch() && !MFCSearch->HybridSearchLatticeAtOnce()) {
if (MFCSearch->HybridSearch() && MFCSearch->HybridSearchLatticeAtOnce()) {
MFCSearch->HybridSearchCreateLattice(MFCSearch->Semicohmetric(),MFCSearch->HybridSearchMismatch(),MFCSearch->HybridSearchLattice());
}
......
......@@ -2973,6 +2973,16 @@ INT4 FStatNomad::DoSearch(Display out,vector<ExPoint> &epv,INT4 fstatsearchtype,
hybrid_search->Tiling(tiling);
hybrid_search->NumberPoints(var_HybridSearchPoints);
hybrid_search->Directions(directions);
hybrid_search->Lattice(HybridSearchLattice());
hybrid_search->M(HybridSearchMismatch());
hybrid_search->G(Semicohmetric());
hybrid_search->MDim(DimMetric(SType(),USETYPE_SEARCH));
if (HybridSearchLatticeAtOnce()){
hybrid_search->PartialLattice(FALSE);
}
else {
hybrid_search->PartialLattice(TRUE);
}
printf("SET HYBRID SEARCH\n");
mads.set_user_search ( hybrid_search );
}
......@@ -3014,17 +3024,22 @@ INT4 FStatNomad::DoSearch(Display out,vector<ExPoint> &epv,INT4 fstatsearchtype,
FirstPoint(s,true);
SkipSearch(s,false);
trials_init();
if (HybridSearch()){
FCHybridSearch hybrid_search ( p );
mads.set_user_search ( &hybrid_search );
}
if (FinalHybridSearch()){
FCHybridSearch *hybrid_search = new FCHybridSearch ( p );
hybrid_search->Tiling(tiling);
hybrid_search->NumberPoints(var_FinalHybridSearchPoints);
hybrid_search->Directions(directions);
hybrid_search->Lattice(FinalHybridSearchLattice());
hybrid_search->M(FinalHybridSearchMismatch());
hybrid_search->G(Cohmetric());
hybrid_search->MDim(DimMetric(SType(),USETYPE_SEARCH));
if (FinalHybridSearchLatticeAtOnce()){
hybrid_search->PartialLattice(FALSE);
}
else {
hybrid_search->PartialLattice(TRUE);
}
printf("SET HYBRID SEARCH\n");
mads.set_user_search ( hybrid_search );
}
......@@ -3403,10 +3418,58 @@ void SCHybridSearch::search( Mads & mads, int &nb_search_pts, bool &stop, stop_t
// template bank
LatticeTilingIterator *itr = XLALCreateLatticeTilingIterator( tiling, n );
LatticeTilingLocator *tloc = XLALCreateLatticeTilingLocator(tiling);
const UINT8 total = XLALTotalLatticeTilingPoints( itr );
LatticeTilingIterator *itr;
LatticeTilingLocator *tloc;
if (partiallattice){
LatticeTiling *ptiling = XLALCreateLatticeTiling(mdim);
XLAL_CHECK_MAIN(ptiling != NULL, XLAL_EFUNC);
// set bounds for each dimension using a rough estimate
std::vector<tDirection> pdirections;
for (INT4 i = 0; i < directions.size(); i++) {
pdirections.push_back(directions.at(i));
pdirections.at(i).min = (*x)[i].value()/directions.at(i).scale - 2. * np / gsl_matrix_get(g,i,i);
pdirections.at(i).max = (*x)[i].value()/directions.at(i).scale + 2. * np / gsl_matrix_get(g,i,i);
printf("size in direction %d:%.16e\n",i,pdirections.at(i).max-pdirections.at(i).min);
}
for (INT4 i = 0; i < directions.size(); i++) {
XLAL_CHECK_MAIN(XLALSetLatticeTilingConstantBound(ptiling, i, pdirections.at(i).min, pdirections.at(i).max) == XLAL_SUCCESS, XLAL_EFUNC);
}
const size_t ln = XLALTotalLatticeTilingDimensions(ptiling);
// Set lattice and metric
XLAL_CHECK_MAIN(XLALSetTilingLatticeAndMetric(ptiling, lattice, g, m) == XLAL_SUCCESS, XLAL_EFUNC);
// Create a lattice iterator
itr = XLALCreateLatticeTilingIterator(ptiling, ln);
XLAL_CHECK_MAIN(itr != NULL, XLAL_EFUNC);
tloc = XLALCreateLatticeTilingLocator(ptiling);
// Print number of templates
UINT8 ntemplates = XLALTotalLatticeTilingPoints(itr);
XLAL_CHECK_MAIN(ntemplates > 0, XLAL_EFUNC);
printf("HybridSearch total number of partial templates: %" LAL_UINT8_FORMAT "\n", ntemplates);
}
else {
itr = XLALCreateLatticeTilingIterator( tiling, n );
tloc = XLALCreateLatticeTilingLocator(tiling);
// Print number of templates
UINT8 ntemplates = XLALTotalLatticeTilingPoints(itr);
XLAL_CHECK_MAIN(ntemplates > 0, XLAL_EFUNC);
printf("HybridSearch total number of templates: %" LAL_UINT8_FORMAT "\n", ntemplates);
}
gsl_matrix *points = gsl_matrix_calloc(n,1);
for (INT4 i = 0; i < n; i++){
gsl_matrix_set(points,i,0,(*x)[i].value()/directions.at(i).scale);
......@@ -3533,9 +3596,55 @@ void FCHybridSearch::search ( Mads &mads, int &nb_search_pts, bool &stop, stop_t
// template bank
LatticeTilingIterator *itr = XLALCreateLatticeTilingIterator( tiling, n );
LatticeTilingLocator *tloc = XLALCreateLatticeTilingLocator(tiling);
const UINT8 total = XLALTotalLatticeTilingPoints( itr );
LatticeTilingIterator *itr;
LatticeTilingLocator *tloc;
if (partiallattice){
LatticeTiling *ptiling = XLALCreateLatticeTiling(mdim);
XLAL_CHECK_MAIN(ptiling != NULL, XLAL_EFUNC);
// set bounds for each dimension using a rough estimate
std::vector<tDirection> pdirections;
for (INT4 i = 0; i < directions.size(); i++) {
pdirections.push_back(directions.at(i));
pdirections.at(i).min = (*x)[i].value()/directions.at(i).scale - 2. * np / gsl_matrix_get(g,i,i);
pdirections.at(i).max = (*x)[i].value()/directions.at(i).scale + 2. * np / gsl_matrix_get(g,i,i);
printf("size in direction %d:%.16e,%.16e\n",i,(*x)[i].value()/directions.at(i).scale,pdirections.at(i).max-pdirections.at(i).min);
}
for (INT4 i = 0; i < directions.size(); i++) {
XLAL_CHECK_MAIN(XLALSetLatticeTilingConstantBound(ptiling, i, pdirections.at(i).min, pdirections.at(i).max) == XLAL_SUCCESS, XLAL_EFUNC);
}
const size_t n = XLALTotalLatticeTilingDimensions(ptiling);
// Set lattice and metric
XLAL_CHECK_MAIN(XLALSetTilingLatticeAndMetric(ptiling, lattice, g, m) == XLAL_SUCCESS, XLAL_EFUNC);
// Create a lattice iterator
itr = XLALCreateLatticeTilingIterator(ptiling, n);
XLAL_CHECK_MAIN(itr != NULL, XLAL_EFUNC);
tloc = XLALCreateLatticeTilingLocator(ptiling);
// Print number of templates
UINT8 ntemplates = XLALTotalLatticeTilingPoints(itr);
XLAL_CHECK_MAIN(ntemplates > 0, XLAL_EFUNC);
printf("HybridSearch total number of partial templates: %" LAL_UINT8_FORMAT "\n", ntemplates);
}
else {
itr = XLALCreateLatticeTilingIterator( tiling, n );
tloc = XLALCreateLatticeTilingLocator(tiling);
UINT8 ntemplates = XLALTotalLatticeTilingPoints( itr );
printf("HybridSearch total number of templates: %" LAL_UINT8_FORMAT "\n", ntemplates);
}
gsl_matrix *points = gsl_matrix_calloc(n,1);
......
......@@ -403,12 +403,36 @@ public:
directions = v;
}
void PartialLattice(BOOLEAN v){
partiallattice = v;
}
void MDim(INT4 v){
mdim = v;
}
void M(REAL8 v){
m = v;
}
void Lattice(CHAR *v){
lattice = v;
}
void G(gsl_matrix *v){
g = v;
}
private:
LatticeTiling *tiling;
INT4 np;
BOOLEAN partiallattice;
std::vector<tDirection> directions;
CHAR* lattice;
INT4 mdim;
REAL8 m;
gsl_matrix *g;
};
class FCHybridSearch : public NOMAD::Search {
......@@ -427,12 +451,36 @@ public:
void Directions(std::vector<tDirection> v){
directions = v;
}
void PartialLattice(BOOLEAN v){
partiallattice = v;
}
void MDim(INT4 v){
mdim = v;
}
void M(REAL8 v){
m = v;
}
void Lattice(CHAR* v){
lattice = v;
}
void G(gsl_matrix *v){
g = v;
}
private:
LatticeTiling *tiling;
INT4 np;
BOOLEAN partiallattice;
std::vector<tDirection> directions;
CHAR* lattice;
INT4 mdim;
REAL8 m;
gsl_matrix *g;
};
class FStatNomad {
......@@ -2117,8 +2165,7 @@ public:
void HybridSearchCreateLattice(gsl_matrix *g, REAL4 m,CHAR *lattice);
MultiSFTVector *multiSFTs;
NOMAD::Cache *cache() {
return nomad_cache;
......
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