Skip to content

Commit

Permalink
more sweep work
Browse files Browse the repository at this point in the history
  • Loading branch information
jtwhite79 committed Mar 26, 2024
1 parent deadc18 commit 5db90d2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
13 changes: 11 additions & 2 deletions src/libs/common/utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,8 @@ bool read_dense_binary_records(ifstream& in,int n_records,int n_col,vector<strin
double data;
vector<double> rec;
rec_vecs.clear();

row_names.clear();
i = 0;
while (true)
{
//finished
Expand Down Expand Up @@ -951,6 +952,7 @@ bool read_dense_binary_records(ifstream& in,int n_records,int n_col,vector<strin
}

rec.clear();
rec.resize(n_col,0);
for (int j = 0; j < n_col; j++)
{
if (!in.good())
Expand All @@ -962,7 +964,8 @@ bool read_dense_binary_records(ifstream& in,int n_records,int n_col,vector<strin
break;
}
in.read((char*)&(data), sizeof(data));
rec.push_back(data);
//rec.push_back(data);
rec[j] = data;

}
if (in.eof())
Expand All @@ -977,7 +980,13 @@ bool read_dense_binary_records(ifstream& in,int n_records,int n_col,vector<strin
}
row_names.push_back(name);
rec_vecs.push_back(rec);

i++;
if (i >= n_records)
{
break;
}

}

return success;
Expand Down
21 changes: 10 additions & 11 deletions src/programs/sweep/sweep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,24 +271,23 @@ void load_parameters_from_dense_binary(map<string, int>& header_info, ifstream&
cout << endl;
//process each parameter value line in the csv file
streampos current_pos = in.tellg();
in.seekg(current_pos,std::ios::beg);
int tmp1,n_cols,tmp3;
read_binary_matrix_header(in,tmp1,n_cols,tmp3);
if (!is_dense_binary_matrix(tmp1,n_cols,tmp3))
in.seekg(0,std::ios::beg);
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");
}
in.seekg(current_pos);
n_col *= -1;
in.seekg(current_pos,std::ios::beg);


vector<vector<double>> rec_vecs;



run_ids.clear();
sweep_pars.clear();

bool success = read_dense_binary_records(in,chunk,n_cols,run_ids,rec_vecs);
bool success = read_dense_binary_records(in,chunk,n_col,run_ids,rec_vecs);
if (!success)
{
throw runtime_error("error processing dense binary file parameter records");
Expand All @@ -315,7 +314,7 @@ void load_parameters_from_dense_binary(map<string, int>& header_info, ifstream&
//pars.update_without_clear(names, vals);
sweep_pars.push_back(pars);
//sweep_pars.emplace_back(pars);
run_ids.push_back(run_id);
//run_ids.push_back(run_id);

if (pars.size() > 10000)
cout << irec << "\r" << flush;
Expand Down Expand Up @@ -805,7 +804,7 @@ int main(int argc, char* argv[])
{
//Parameters temp = base_trans_seq.active_ctl2model_cp(par);
irun_ids.push_back(run_manager_ptr->add_run(base_trans_seq.active_ctl2model_cp(par)));

break;
}

//make some runs
Expand All @@ -815,7 +814,7 @@ int main(int argc, char* argv[])
//process the runs
cout << "processing runs...";
//process_sweep_runs(obs_stream, pest_scenario, run_manager_ptr, run_ids, obj_func,total_runs_done);
process_sweep_runs(obs_stream, pest_scenario, run_manager_ptr,irun_ids, run_ids, obj_func, total_runs_done);
//process_sweep_runs(obs_stream, pest_scenario, run_manager_ptr,irun_ids, run_ids, obj_func, total_runs_done);

cout << "done" << endl;
total_runs_done += run_ids.size();
Expand Down

0 comments on commit 5db90d2

Please sign in to comment.