Skip to content

Commit

Permalink
more work on dense binary in sweep
Browse files Browse the repository at this point in the history
  • Loading branch information
jtwhite79 committed Mar 26, 2024
1 parent cff2ca0 commit deadc18
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/libs/common/utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ void read_binary_matrix_header(ifstream& in, int& tmp1, int& tmp2, int& tmp3)
throw runtime_error(ss.str());
}

in.close();


}

Expand Down
8 changes: 5 additions & 3 deletions src/libs/pestpp_common/pest_data_structs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,12 +554,14 @@ PestppOptions::ARG_STATUS PestppOptions::assign_value_by_key(string key, const s
//convert_ip(value, condor_submit_file);
condor_submit_file = org_value;
}
else if ((key == "SWEEP_PARAMETER_CSV_FILE") || (key == "SWEEP_PAR_CSV"))
else if ((key == "SWEEP_PARAMETER_CSV_FILE") || (key == "SWEEP_PAR_CSV") || (key == "SWEEP_PARAMETER_FILE"))
{
passed_args.insert("SWEEP_PARAMETER_CSV_FILE");
passed_args.insert("SWEEP_PAR_CSV");

//convert_ip(org_value, sweep_parameter_csv_file);
passed_args.insert("SWEEP_PARAMETER_FILE");


//convert_ip(org_value, sweep_parameter_csv_file);
sweep_parameter_csv_file = org_value;
}
else if ((key == "SWEEP_OUTPUT_CSV_FILE") || (key == "SWEEP_OBS_CSV"))
Expand Down
29 changes: 23 additions & 6 deletions src/programs/sweep/sweep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,22 +116,29 @@ map<string,int> prepare_parameter_csv(Parameters pars, ifstream &csv, bool forgi
return header_info;
}

map<string,int> prepare_parameter_dense_binary(Parameters pars, ifstream &in, bool forgive)
map<string,int> prepare_parameter_dense_binary(Parameters pars, ifstream &in, bool forgive, vector<string>& header_tokens)
{
stringstream ss;
if (!in.good())
{
throw runtime_error("ifstream not good in prepare_parameter_dense_binary()");
}

//process the header
//any missing header labels will be marked to ignore those columns later
int tmp1,n_cols,tmp3;
read_binary_matrix_header(in,tmp1,n_cols,tmp3);
if (!is_dense_binary_matrix(tmp1,n_cols,tmp3))
int tmp1,n_col,tmp3;
read_binary_matrix_header(in,tmp1,n_col,tmp3);
if (!is_dense_binary_matrix(tmp1,n_col,tmp3))
{
throw runtime_error("prepare_parameter_dense_binary() file does not contain a dense binary matrix");
}
vector<string> header_tokens = read_dense_binary_col_names(in,n_cols);
n_col *= -1;
header_tokens.clear();
header_tokens = read_dense_binary_col_names(in,n_col);
ss.str("");
ss << "..." << header_tokens.size() << " valid parameter entries found in dense binary parameter file ("
<< n_col << " total columns)" << endl;
cout << ss.str();
// check for parameter names that in the pest control file but that are missing from the csv file
vector<string> missing_names;
string name;
Expand Down Expand Up @@ -642,10 +649,12 @@ int main(int argc, char* argv[])
if ((par_ext.compare("jcb") == 0) || (par_ext.compare("jco") == 0))
{
cout << " --- binary jco-type file detected for par_csv" << endl;
fout_rec << " --- binary jco-type file detected for par_csv" << endl;
use_jco = true;
Jacobian jco(file_manager);
jco.read(par_csv_file);
cout << jco.get_matrix_ptr()->rows() << " runs found in binary jco-type file" << endl;
fout_rec << jco.get_matrix_ptr()->rows() << " runs found in binary jco-type file" << endl;
//check that the jco is compatible with the control file
vector<string> names = jco.get_base_numeric_par_names();
jco_col_names = jco.get_sim_obs_names();
Expand All @@ -670,13 +679,21 @@ int main(int argc, char* argv[])
else if (par_ext.compare("csv") == 0)
{
cout << " --- csv file detected for par_csv" << endl;
fout_rec << " --- csv file detected for par_csv" << endl;
header_info = prepare_parameter_csv(pest_scenario.get_ctl_parameters(),
par_stream, pest_scenario.get_pestpp_options().get_sweep_forgive());
}
else if (par_ext.compare("bin")==0)
{
cout << " --- dense binary file detected for par_csv" << endl;
header_info = prepare_parameter_dense_binary(pest_scenario.get_ctl_parameters(),par_stream, pest_scenario.get_pestpp_options().get_sweep_forgive());
fout_rec << " --- dense binary file detected for par_csv" << endl;
vector<string> col_names;
header_info = prepare_parameter_dense_binary(pest_scenario.get_ctl_parameters(),par_stream,
pest_scenario.get_pestpp_options().get_sweep_forgive(),col_names);
vector<string> all_row_names = read_dense_binary_remaining_row_names(par_stream,col_names);
cout << "..." << all_row_names.size() << " parameter sets found in dense binary file" << endl;
fout_rec << "..." << all_row_names.size() << " parameter sets found in dense binary file" << endl;


}
else
Expand Down

0 comments on commit deadc18

Please sign in to comment.