Commit cd2e03ce authored by Miroslav Shaltev's avatar Miroslav Shaltev
Browse files

add options for final hybrid search

parent 7bf56fa6
...@@ -1077,8 +1077,8 @@ int main(int argc, char *argv[]) { ...@@ -1077,8 +1077,8 @@ int main(int argc, char *argv[]) {
MFCSearch->write_dts_file(); MFCSearch->write_dts_file();
} }
if (MFCSearch->HybridSearch()) { if (MFCSearch->FinalHybridSearch()) {
MFCSearch->HybridSearchCreateLattice(MFCSearch->Cohmetric(),MFCSearch->HybridSearchMismatch(),MFCSearch->HybridSearchLattice()); MFCSearch->HybridSearchCreateLattice(MFCSearch->Cohmetric(),MFCSearch->FinalHybridSearchMismatch(),MFCSearch->FinalHybridSearchLattice());
} }
if (MFCSearch->FinalMinMeshCoarseningExponent() != 0 && MFCSearch->FinalMaxMeshCoarseningExponent() != 0) { if (MFCSearch->FinalMinMeshCoarseningExponent() != 0 && MFCSearch->FinalMaxMeshCoarseningExponent() != 0) {
...@@ -1360,6 +1360,13 @@ INT4 FCSearch::XLALInitUserVars ( int argc, char *argv[] ) ...@@ -1360,6 +1360,13 @@ INT4 FCSearch::XLALInitUserVars ( int argc, char *argv[] )
strcpy(uvar->HybridSearchLattice, "an-star"); strcpy(uvar->HybridSearchLattice, "an-star");
uvar->HybridSearchPoints = 16; uvar->HybridSearchPoints = 16;
uvar->FinalHybridSearch = FALSE;
uvar->FinalHybridSearchMismatch = 0.8;
uvar->FinalHybridSearchLattice = (char*)LALCalloc( 16, sizeof(CHAR) );
strcpy(uvar->FinalHybridSearchLattice, "an-star");
uvar->FinalHybridSearchPoints = 16;
uvar->metricType = MTAVFSTAT; uvar->metricType = MTAVFSTAT;
SignalIsKnown = FALSE; SignalIsKnown = FALSE;
...@@ -1521,6 +1528,10 @@ INT4 FCSearch::XLALInitUserVars ( int argc, char *argv[] ) ...@@ -1521,6 +1528,10 @@ INT4 FCSearch::XLALInitUserVars ( int argc, char *argv[] )
XLALRegisterUvarMember( HybridSearchMismatch,REAL8, 0, OPTIONAL, "Hybrid search maximal mismatch"); XLALRegisterUvarMember( HybridSearchMismatch,REAL8, 0, OPTIONAL, "Hybrid search maximal mismatch");
XLALRegisterUvarMember( HybridSearchLattice,STRING, 0, OPTIONAL, "Hybrid search lattice type: 'an-star' or 'cubic'"); XLALRegisterUvarMember( HybridSearchLattice,STRING, 0, OPTIONAL, "Hybrid search lattice type: 'an-star' or 'cubic'");
XLALRegisterUvarMember( HybridSearchPoints,INT4, 0, OPTIONAL, "Hybrid search number of points"); XLALRegisterUvarMember( HybridSearchPoints,INT4, 0, OPTIONAL, "Hybrid search number of points");
XLALRegisterUvarMember( FinalHybridSearch,BOOLEAN, 0, OPTIONAL, "Final do hybrid search (grid search in the Nomad search step)");
XLALRegisterUvarMember( FinalHybridSearchMismatch,REAL8, 0, OPTIONAL, "Final hybrid search maximal mismatch");
XLALRegisterUvarMember( FinalHybridSearchLattice,STRING, 0, OPTIONAL, "Final hybrid search lattice type: 'an-star' or 'cubic'");
XLALRegisterUvarMember( FinalHybridSearchPoints,INT4, 0, OPTIONAL, "Final hybrid search number of points");
XLALRegisterUvarMember( metricType, INT4, 0, OPTIONAL, "Type of metric to compute: 0=phase-metric, 1=average F-metric"); XLALRegisterUvarMember( metricType, INT4, 0, OPTIONAL, "Type of metric to compute: 0=phase-metric, 1=average F-metric");
/* read cmdline & cfgfile */ /* read cmdline & cfgfile */
...@@ -1961,6 +1972,11 @@ INT4 FCSearch::XLALInitUserVars ( int argc, char *argv[] ) ...@@ -1961,6 +1972,11 @@ INT4 FCSearch::XLALInitUserVars ( int argc, char *argv[] )
HybridSearchLattice(uvar->HybridSearchLattice); HybridSearchLattice(uvar->HybridSearchLattice);
HybridSearchPoints(uvar->HybridSearchPoints); HybridSearchPoints(uvar->HybridSearchPoints);
FinalHybridSearch(uvar->FinalHybridSearch);
FinalHybridSearchMismatch(uvar->FinalHybridSearchMismatch);
FinalHybridSearchLattice(uvar->FinalHybridSearchLattice);
FinalHybridSearchPoints(uvar->FinalHybridSearchPoints);
dopplermax(uvar->dopplermax); dopplermax(uvar->dopplermax);
if ( uvar->ComputeDTS && uvar->FStatSearchType == CHSEARCH ) { if ( uvar->ComputeDTS && uvar->FStatSearchType == CHSEARCH ) {
......
...@@ -174,6 +174,10 @@ extern "C" { ...@@ -174,6 +174,10 @@ extern "C" {
REAL8 HybridSearchMismatch; REAL8 HybridSearchMismatch;
CHAR *HybridSearchLattice; CHAR *HybridSearchLattice;
INT4 HybridSearchPoints; INT4 HybridSearchPoints;
BOOLEAN FinalHybridSearch;
REAL8 FinalHybridSearchMismatch;
CHAR *FinalHybridSearchLattice;
INT4 FinalHybridSearchPoints;
INT4 metricType; INT4 metricType;
......
...@@ -3020,10 +3020,10 @@ INT4 FStatNomad::DoSearch(Display out,vector<ExPoint> &epv,INT4 fstatsearchtype, ...@@ -3020,10 +3020,10 @@ INT4 FStatNomad::DoSearch(Display out,vector<ExPoint> &epv,INT4 fstatsearchtype,
mads.set_user_search ( &hybrid_search ); mads.set_user_search ( &hybrid_search );
} }
if (HybridSearch()){ if (FinalHybridSearch()){
FCHybridSearch *hybrid_search = new FCHybridSearch ( p ); FCHybridSearch *hybrid_search = new FCHybridSearch ( p );
hybrid_search->Tiling(tiling); hybrid_search->Tiling(tiling);
hybrid_search->NumberPoints(var_HybridSearchPoints); hybrid_search->NumberPoints(var_FinalHybridSearchPoints);
hybrid_search->Directions(directions); hybrid_search->Directions(directions);
printf("SET HYBRID SEARCH\n"); printf("SET HYBRID SEARCH\n");
mads.set_user_search ( hybrid_search ); mads.set_user_search ( hybrid_search );
...@@ -3342,7 +3342,7 @@ XLALGetDetectorIDs( ...@@ -3342,7 +3342,7 @@ XLALGetDetectorIDs(
} /* XLALGetDetectorIDs() */ } /* XLALGetDetectorIDs() */
void SCHybridSearch::search( Mads & mads, int &nb_search_pts, bool &stop, stop_type &stop_reason, success_type &success, bool &count_search, const Eval_Point *& new_feas_inc, const Eval_Point *& new_infeas_inc){ void SCHybridSearch::search( Mads & mads, int &nb_search_pts, bool &stop, stop_type &stop_reason, success_type &success, bool &count_search, const Eval_Point *& new_feas_inc, const Eval_Point *& new_infeas_inc){
// printf("ENTER HYBRID SEARCH!\n");
new_feas_inc = new_infeas_inc = NULL; new_feas_inc = new_infeas_inc = NULL;
nb_search_pts = 0; nb_search_pts = 0;
success = UNSUCCESSFUL; success = UNSUCCESSFUL;
...@@ -3407,13 +3407,11 @@ void SCHybridSearch::search( Mads & mads, int &nb_search_pts, bool &stop, stop_t ...@@ -3407,13 +3407,11 @@ void SCHybridSearch::search( Mads & mads, int &nb_search_pts, bool &stop, stop_t
LatticeTilingLocator *tloc = XLALCreateLatticeTilingLocator(tiling); LatticeTilingLocator *tloc = XLALCreateLatticeTilingLocator(tiling);
const UINT8 total = XLALTotalLatticeTilingPoints( itr ); const UINT8 total = XLALTotalLatticeTilingPoints( itr );
// printf("TLOC CREATED, n=%d.\n",n);
gsl_matrix *points = gsl_matrix_calloc(n,1); gsl_matrix *points = gsl_matrix_calloc(n,1);
for (INT4 i = 0; i < n; i++){ for (INT4 i = 0; i < n; i++){
// printf("%d:%.16f\n",i,(*x)[i].value()/directions.at(i).scale);
gsl_matrix_set(points,i,0,(*x)[i].value()/directions.at(i).scale); gsl_matrix_set(points,i,0,(*x)[i].value()/directions.at(i).scale);
} }
// printf("MATRIX SET DONE.\n");
gsl_matrix *nearest_points = NULL; gsl_matrix *nearest_points = NULL;
gsl_matrix *GAMAT( nearest_points, n, np ); gsl_matrix *GAMAT( nearest_points, n, np );
...@@ -3433,8 +3431,6 @@ void SCHybridSearch::search( Mads & mads, int &nb_search_pts, bool &stop, stop_t ...@@ -3433,8 +3431,6 @@ void SCHybridSearch::search( Mads & mads, int &nb_search_pts, bool &stop, stop_t
XLALNearestLatticeTilingPoints (tloc, points, &nearest_points, NULL); XLALNearestLatticeTilingPoints (tloc, points, &nearest_points, NULL);
// printf("NEAREST POINTS\n");
Evaluator_Control & ev_control = mads.get_evaluator_control(); Evaluator_Control & ev_control = mads.get_evaluator_control();
for (INT4 i = 0; i < nearest_points->size2; i++) { for (INT4 i = 0; i < nearest_points->size2; i++) {
...@@ -3448,32 +3444,14 @@ void SCHybridSearch::search( Mads & mads, int &nb_search_pts, bool &stop, stop_t ...@@ -3448,32 +3444,14 @@ void SCHybridSearch::search( Mads & mads, int &nb_search_pts, bool &stop, stop_t
for (INT4 j = 0; j < n; j++) { for (INT4 j = 0; j < n; j++) {
(*tk)[j] = (directions.at(j).scale * gsl_vector_get(cv,j)); (*tk)[j] = (directions.at(j).scale * gsl_vector_get(cv,j));
// printf("%.16f\t",gsl_vector_get(cv,j));
} }
// printf("\n");
ev_control.add_eval_point ( tk, _p.out().get_search_dd(), false, Double(), Double(), Double(), Double());
ev_control.add_eval_point ( tk , gsl_matrix_free(points);
_p.out().get_search_dd() , gsl_matrix_free(nearest_points);
false ,
Double() ,
Double() ,
Double() ,
Double() );
gsl_vector_free(cv); gsl_vector_free(cv);
} }
// printf("EXIT HYBRID SEARCH\n");
// Evaluator_Control:
// add the new point to the ordered list of search trial points:
nb_search_pts = 1; nb_search_pts = 1;
...@@ -3494,7 +3472,7 @@ void SCHybridSearch::search( Mads & mads, int &nb_search_pts, bool &stop, stop_t ...@@ -3494,7 +3472,7 @@ void SCHybridSearch::search( Mads & mads, int &nb_search_pts, bool &stop, stop_t
} }
void FCHybridSearch::search ( Mads &mads, int &nb_search_pts, bool &stop, stop_type &stop_reason, success_type &success, bool &count_search , const Eval_Point *& new_feas_inc, const Eval_Point *& new_infeas_inc ) { void FCHybridSearch::search ( Mads &mads, int &nb_search_pts, bool &stop, stop_type &stop_reason, success_type &success, bool &count_search , const Eval_Point *& new_feas_inc, const Eval_Point *& new_infeas_inc ) {
// printf("ENTER HYBRID SEARCH!\n");
new_feas_inc = new_infeas_inc = NULL; new_feas_inc = new_infeas_inc = NULL;
nb_search_pts = 0; nb_search_pts = 0;
success = UNSUCCESSFUL; success = UNSUCCESSFUL;
...@@ -3559,13 +3537,12 @@ void FCHybridSearch::search ( Mads &mads, int &nb_search_pts, bool &stop, stop_t ...@@ -3559,13 +3537,12 @@ void FCHybridSearch::search ( Mads &mads, int &nb_search_pts, bool &stop, stop_t
LatticeTilingLocator *tloc = XLALCreateLatticeTilingLocator(tiling); LatticeTilingLocator *tloc = XLALCreateLatticeTilingLocator(tiling);
const UINT8 total = XLALTotalLatticeTilingPoints( itr ); const UINT8 total = XLALTotalLatticeTilingPoints( itr );
// printf("TLOC CREATED, n=%d.\n",n);
gsl_matrix *points = gsl_matrix_calloc(n,1); gsl_matrix *points = gsl_matrix_calloc(n,1);
for (INT4 i = 0; i < n; i++){ for (INT4 i = 0; i < n; i++){
// printf("%d:%.16f\n",i,(*x)[i].value()/directions.at(i).scale);
gsl_matrix_set(points,i,0,(*x)[i].value()/directions.at(i).scale); gsl_matrix_set(points,i,0,(*x)[i].value()/directions.at(i).scale);
} }
// printf("MATRIX SET DONE.\n");
gsl_matrix *nearest_points = NULL; gsl_matrix *nearest_points = NULL;
gsl_matrix *GAMAT( nearest_points, n, np ); gsl_matrix *GAMAT( nearest_points, n, np );
...@@ -3585,8 +3562,6 @@ void FCHybridSearch::search ( Mads &mads, int &nb_search_pts, bool &stop, stop_t ...@@ -3585,8 +3562,6 @@ void FCHybridSearch::search ( Mads &mads, int &nb_search_pts, bool &stop, stop_t
XLALNearestLatticeTilingPoints (tloc, points, &nearest_points, NULL); XLALNearestLatticeTilingPoints (tloc, points, &nearest_points, NULL);
// printf("NEAREST POINTS\n");
Evaluator_Control & ev_control = mads.get_evaluator_control(); Evaluator_Control & ev_control = mads.get_evaluator_control();
for (INT4 i = 0; i < nearest_points->size2; i++) { for (INT4 i = 0; i < nearest_points->size2; i++) {
...@@ -3600,46 +3575,19 @@ void FCHybridSearch::search ( Mads &mads, int &nb_search_pts, bool &stop, stop_t ...@@ -3600,46 +3575,19 @@ void FCHybridSearch::search ( Mads &mads, int &nb_search_pts, bool &stop, stop_t
for (INT4 j = 0; j < n; j++) { for (INT4 j = 0; j < n; j++) {
(*tk)[j] = (directions.at(j).scale * gsl_vector_get(cv,j)); (*tk)[j] = (directions.at(j).scale * gsl_vector_get(cv,j));
// printf("%.16f\t",gsl_vector_get(cv,j));
} }
// printf("\n");
ev_control.add_eval_point ( tk, _p.out().get_search_dd(), false, Double(), Double(), Double(), Double());
ev_control.add_eval_point ( tk , gsl_matrix_free(points);
_p.out().get_search_dd() , gsl_matrix_free(nearest_points);
false ,
Double() ,
Double() ,
Double() ,
Double() );
gsl_vector_free(cv); gsl_vector_free(cv);
} }
// printf("EXIT HYBRID SEARCH\n");
// Evaluator_Control:
// add the new point to the ordered list of search trial points:
nb_search_pts = 1; nb_search_pts = 1;
// evaluation:
new_feas_inc = new_infeas_inc = NULL; new_feas_inc = new_infeas_inc = NULL;
ev_control.eval_list_of_points ( _type , ev_control.eval_list_of_points ( _type, mads.get_true_barrier(), mads.get_sgte_barrier(), mads.get_pareto_front(), stop, stop_reason, new_feas_inc, new_infeas_inc, success);
mads.get_true_barrier() ,
mads.get_sgte_barrier() ,
mads.get_pareto_front() ,
stop ,
stop_reason ,
new_feas_inc ,
new_infeas_inc ,
success );
} }
...@@ -2051,6 +2051,39 @@ public: ...@@ -2051,6 +2051,39 @@ public:
return var_HybridSearchPoints; return var_HybridSearchPoints;
} }
void FinalHybridSearch(BOOLEAN v){
var_FinalHybridSearch = v;
}
BOOLEAN FinalHybridSearch(){
return var_FinalHybridSearch;
}
void FinalHybridSearchMismatch(REAL8 v){
var_FinalHybridSearchMismatch = v;
}
REAL8 FinalHybridSearchMismatch(){
return var_FinalHybridSearchMismatch;
}
void FinalHybridSearchLattice(CHAR* v){
var_FinalHybridSearchLattice = v;
}
CHAR* FinalHybridSearchLattice(){
return var_FinalHybridSearchLattice;
}
void FinalHybridSearchPoints(INT4 v){
var_FinalHybridSearchPoints = v;
}
INT4 FinalHybridSearchPoints(){
return var_FinalHybridSearchPoints;
}
REAL8 DoPredictFStat(INT4 fstatsearchtype,LALSegList *segList); REAL8 DoPredictFStat(INT4 fstatsearchtype,LALSegList *segList);
UsefulStageVariables usefulParams; UsefulStageVariables usefulParams;
...@@ -2157,9 +2190,13 @@ private: ...@@ -2157,9 +2190,13 @@ private:
REAL8 var_SignalPeriod; REAL8 var_SignalPeriod;
BOOLEAN var_HybridSearch; BOOLEAN var_HybridSearch;
BOOLEAN var_FinalHybridSearch;
REAL4 var_HybridSearchMismatch; REAL4 var_HybridSearchMismatch;
CHAR *var_HybridSearchLattice; CHAR *var_HybridSearchLattice;
INT4 var_HybridSearchPoints; INT4 var_HybridSearchPoints;
REAL4 var_FinalHybridSearchMismatch;
CHAR *var_FinalHybridSearchLattice;
INT4 var_FinalHybridSearchPoints;
UINT8 trials_cnt; UINT8 trials_cnt;
std::vector<UINT8> trials_vec; std::vector<UINT8> trials_vec;
......
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