Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jtwhite79 committed Oct 15, 2020
2 parents 015fa71 + 9b85ca1 commit 08a31c3
Show file tree
Hide file tree
Showing 16 changed files with 156 additions and 51 deletions.
4 changes: 2 additions & 2 deletions benchmarks/ies_10par_xsec/template/10par_xsec.hds
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
1.000 1.110 1.334 2.013 2.710 2.970 3.030 3.189 3.528 4.099
1.000 1.220 1.668 3.026 4.421 4.939 5.061 5.379 6.056 7.199
1.000 1.200 1.400 1.600 1.800 2.000 2.200 2.400 2.600 2.800
1.000 1.400 1.800 2.200 2.600 3.000 3.400 3.800 4.200 4.600
2 changes: 1 addition & 1 deletion benchmarks/ies_10par_xsec/template/hk_Layer_1.ref
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.500000000000 24.60885796510 1.171074741244 0.536587674942 1.080530619282 8.992641090845 7.576939712260 1.984907019095 1.175282129554 0.697019774664
2.500000000000 2.500000000000 2.500000000000 2.500000000000 2.500000000000 2.500000000000 2.500000000000 2.500000000000 2.500000000000 2.500000000000
Binary file not shown.
2 changes: 1 addition & 1 deletion src/libs/common/config_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define CONFIG_OS_H_


#define PESTPP_VERSION "5.0.3";
#define PESTPP_VERSION "5.0.4";

#if defined(_WIN32) || defined(_WIN64)
#define OS_WIN
Expand Down
29 changes: 29 additions & 0 deletions src/libs/common/network_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,35 @@

using namespace std;

string w_get_hostname()
{
char* temp;
string hostname("");
#ifdef OS_WIN
temp = getenv("COMPUTERNAME");
hostname = temp;
temp = 0;

#else
temp = getenv("HOSTNAME");
if (temp != 0) {
hostname = temp;
temp = 0;
}
else {
temp = new char[512];
if (gethostname(temp, 512) == 0) { // success = 0, failure = -1
hostname = temp;
}
delete[]temp;
temp = 0;
}

#endif
return hostname;

}

string w_init()
{
stringstream ss;
Expand Down
1 change: 1 addition & 0 deletions src/libs/common/network_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <string>

std::string w_init();
std::string w_get_hostname();
int w_close(int sockfd);
void w_cleanup();
std::vector<std::string> w_getnameinfo_vec(int sockfd, int flags=0);
Expand Down
33 changes: 31 additions & 2 deletions src/libs/pestpp_common/Pest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,7 @@ int Pest::process_ctl_file(ifstream& fin, string _pst_filename, ofstream& f_rec)
try {
#endif
prior_info_string = "";
vector<string> notfound_args;
for (lnum = 1, sec_begin_lnum = 1; getline(fin, line); ++lnum)
{
strip_ip(line);
Expand Down Expand Up @@ -1099,6 +1100,7 @@ int Pest::process_ctl_file(ifstream& fin, string _pst_filename, ofstream& f_rec)
ss.str("");
ss << "unrecognized '* control data keyword' key-value pair on line: " << endl << " '" << line << "'" << endl;
throw_control_file_error(f_rec, ss.str(), false);
notfound_args.push_back(line);
}
}

Expand Down Expand Up @@ -1721,6 +1723,23 @@ int Pest::process_ctl_file(ifstream& fin, string _pst_filename, ofstream& f_rec)
throw_control_file_error(f_rec, ss.str());
}

vector<string> invalid;
for (auto kv : arg_map)
{
if (kv.second == PestppOptions::ARG_STATUS::ARG_INVALID)
{
invalid.push_back(kv.first);
}
}
if (invalid.size() > 0)
{
ss.str("");
ss << " the following '++' args have invalid values:" << endl;
for (auto n : invalid)
ss << n << ",";
throw_control_file_error(f_rec, ss.str());
}

vector<string> not_accepted;
for (auto kv : arg_map)
{
Expand All @@ -1729,15 +1748,25 @@ int Pest::process_ctl_file(ifstream& fin, string _pst_filename, ofstream& f_rec)
not_accepted.push_back(kv.first);
}
}

if (not_accepted.size() > 0)
{
ss.str("");
ss << " the following '++' args were not accepted:" << endl;
for (auto n : not_accepted)
ss << n << ",";
throw_control_file_error(f_rec, ss.str());
if (pestpp_options.get_forgive_unknown_args())
{
ss << endl << "forgive_unknown_args is 'true', continuing" << endl;
throw_control_file_error(f_rec, ss.str(), false);
}
else
{
ss << endl << "forgive_unknown_args is 'false' so this is treated as an error" << endl;
throw_control_file_error(f_rec, ss.str(), true);
}
}

if (control_info.pestmode == ControlInfo::PestMode::REGUL)
{
if (regul_scheme_ptr)
Expand Down
44 changes: 32 additions & 12 deletions src/libs/pestpp_common/pest_data_structs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -962,14 +962,7 @@ PestppOptions::ARG_STATUS PestppOptions::assign_value_by_key(string key, const s
debug_parse_only = pest_utils::parse_string_arg_to_bool(value);

}
else if (key == "CHECK_TPLINS")
{
check_tplins = pest_utils::parse_string_arg_to_bool(value);
}
else if (key == "FILL_TPL_ZEROS")
{
fill_tpl_zeros = pest_utils::parse_string_arg_to_bool(value);
}


else if (!assign_value_by_key_continued(key, value))
{
Expand Down Expand Up @@ -1020,6 +1013,27 @@ bool PestppOptions::assign_value_by_key_continued(const string& key, const strin
panther_debug_fail_freeze = pest_utils::parse_string_arg_to_bool(value);
return true;
}
else if (key == "CHECK_TPLINS")
{
check_tplins = pest_utils::parse_string_arg_to_bool(value);
return true;
}
else if (key == "FILL_TPL_ZEROS")
{
fill_tpl_zeros = pest_utils::parse_string_arg_to_bool(value);
return true;
}
else if (key == "FORGIVE_UNKNOWN_ARGS")
{
forgive_unknown_args = pest_utils::parse_string_arg_to_bool(value);
return true;
}
else if (key == "PANTHER_ECHO")
{
panther_echo = pest_utils::parse_string_arg_to_bool(value);
return true;
}

return false;
}

Expand All @@ -1040,6 +1054,7 @@ void PestppOptions::summary(ostream& os) const
for (auto s : lambda_scale_vec)
os << s << ",";
os << endl;
os << "forgive_unknown_args: " << forgive_unknown_args << endl;
os << "max_run_fail: " << max_run_fail << endl;
os << "yamr_poll_interval: " << worker_poll_interval << endl;
os << "parameter_covariance: " << parcov_filename << endl;
Expand All @@ -1058,6 +1073,12 @@ void PestppOptions::summary(ostream& os) const
os << "additional_ins_delimiters: " << additional_ins_delimiters << endl;
os << "random_seed: " << random_seed << endl;

os << "panther_agent_restart_on_error: " << panther_agent_restart_on_error << endl;
os << "panther_agent_no_ping_timeout_secs: " << panther_agent_no_ping_timeout_secs << endl;
os << "panther_debug_loop: " << panther_debug_loop << endl;
os << "panther_echo: " << panther_echo << endl;

os << endl;

os << endl << "...pestpp-glm specific options:" << endl;
os << "max_n_super: " << max_n_super << endl;
Expand Down Expand Up @@ -1199,10 +1220,7 @@ void PestppOptions::summary(ostream& os) const
os << "gsa_sobol_samples: " << gsa_sobol_samples << endl;
os << "gsa_sobol_par_dist: " << gsa_sobol_par_dist << endl;

os << endl;
os << "panther_agent_restart_on_error: " << panther_agent_restart_on_error << endl;
os << "panther_agent_no_ping_timeout_secs: " << panther_agent_no_ping_timeout_secs << endl;
os << "panther_debug_loop: " << panther_debug_loop << endl;

os << "panther_agent_freeze_on_fail: " << panther_debug_fail_freeze << endl;
os << endl << endl << endl;
}
Expand All @@ -1217,6 +1235,7 @@ void PestppOptions::set_defaults()
set_iter_summary_flag(true);
set_der_forgive(true);

set_forgive_unknown_args(false);
set_random_seed(358183147);
set_base_lambda_vec(vector<double>{ 0.1, 1.0, 10.0, 100.0, 1000.0 });
set_lambda_scale_vec(vector<double>{0.75, 1.0, 1.1});
Expand Down Expand Up @@ -1343,6 +1362,7 @@ void PestppOptions::set_defaults()
set_panther_agent_no_ping_timeout_secs(-1);
set_panther_debug_loop(false);
set_panther_debug_fail_freeze(false);
set_panther_echo(true);
}

ostream& operator<< (ostream &os, const ParameterInfo& val)
Expand Down
18 changes: 9 additions & 9 deletions src/libs/pestpp_common/pest_data_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,11 @@ class PestppOptions {
enum GLOBAL_OPT { NONE, OPT_DE };
enum GLMNormalForm { IDENT,DIAG, PRIOR };
enum ARG_STATUS {ARG_ACCEPTED, ARG_DUPLICATE, ARG_NOTFOUND, ARG_INVALID};
/*PestppOptions(int _n_iter_base = 50, int _n_iter_super = 0, int _max_n_super = 50,
double _super_eigthres = 1.0E-6, SVD_PACK _svd_pack = PestppOptions::REDSVD,
double _super_relparmax = 0.1, int max_run_fail = 3,
bool iter_summary_flag = true, bool der_forgive = true,
double overdue_reched_fac = 1.15, double overdue_giveup_fac = 100,
GLOBAL_OPT _global_opt = PestppOptions::NONE,
double _de_f = 0.8, double _de_cr = 0.9, int _de_npopulation = 40, int _de_max_gen = 100, bool _de_dither_f = true);*/
PestppOptions() { ; }

//void parce_line(const string &line);
map<string,ARG_STATUS> parse_plusplus_line(const string &line);
vector<string> notfound_args;
ARG_STATUS assign_value_by_key(string key, const string org_value);
bool assign_value_by_key_continued(const string& key, const string& value);
int get_max_n_super() const { return max_n_super; }
Expand Down Expand Up @@ -364,8 +358,6 @@ class PestppOptions {
void set_ies_use_empirical_prior(bool _ies_use_empirical_prior) { ies_use_empirical_prior = _ies_use_empirical_prior; }
bool get_ies_group_draws() const { return ies_group_draws; }
void set_ies_group_draws(bool _ies_group_draws) { ies_group_draws = _ies_group_draws; }
//bool get_ies_num_reals_passed() const { return ies_num_reals_passed; }
//void set_ies_num_reals_passed(bool _ies_num_reals_passed) { ies_num_reals_passed = _ies_num_reals_passed; }
bool get_ies_enforce_bounds() const { return ies_enforce_bounds; }
void set_ies_enforce_bounds(bool _ies_enforce_bounds) { ies_enforce_bounds = _ies_enforce_bounds; }

Expand Down Expand Up @@ -471,12 +463,19 @@ class PestppOptions {
bool get_panther_debug_loop() const { return panther_debug_loop; }
void set_panther_debug_fail_freeze(bool _flag) { panther_debug_fail_freeze = _flag; }
bool get_panther_debug_fail_freeze() const { return panther_debug_fail_freeze; }

bool get_panther_echo() const { return panther_echo; }
void set_panther_echo(bool _flag) { panther_echo = _flag; }

void set_forgive_unknown_args(bool _flag) { forgive_unknown_args = _flag; }
bool get_forgive_unknown_args() const { return forgive_unknown_args; }

void set_defaults();
void summary(ostream& os) const;

private:

bool forgive_unknown_args;
int n_iter_base;
int n_iter_super;
int max_n_super;
Expand Down Expand Up @@ -613,6 +612,7 @@ class PestppOptions {
int panther_agent_no_ping_timeout_secs;
bool panther_debug_loop;
bool panther_debug_fail_freeze;
bool panther_echo;
};
//ostream& operator<< (ostream &os, const PestppOptions& val);
ostream& operator<< (ostream &os, const ObservationInfo& val);
Expand Down
25 changes: 17 additions & 8 deletions src/libs/run_managers/yamr/RunManagerPanther.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,13 @@ int AgentInfoRec::seconds_since_last_ping_time() const


RunManagerPanther::RunManagerPanther(const string& stor_filename, const string& _port, ofstream& _f_rmr, int _max_n_failure,
double _overdue_reched_fac, double _overdue_giveup_fac, double _overdue_giveup_minutes)
double _overdue_reched_fac, double _overdue_giveup_fac, double _overdue_giveup_minutes, bool _should_echo)
: RunManagerAbstract(vector<string>(), vector<string>(), vector<string>(),
vector<string>(), vector<string>(), stor_filename, _max_n_failure),
overdue_reched_fac(_overdue_reched_fac), overdue_giveup_fac(_overdue_giveup_fac),
port(_port), f_rmr(_f_rmr), n_no_ops(0), overdue_giveup_minutes(_overdue_giveup_minutes),
terminate_idle_thread(false), currently_idle(true), idling(false), idle_thread_finished(false),
idle_thread(nullptr), idle_thread_raii(nullptr)
idle_thread(nullptr), idle_thread_raii(nullptr), should_echo(_should_echo)
{
cout << " starting PANTHER master..." << endl << endl;
max_concurrent_runs = max(MAX_CONCURRENT_RUNS_LOWER_LIMIT, _max_n_failure);
Expand Down Expand Up @@ -455,7 +455,8 @@ RunManagerAbstract::RUN_UNTIL_COND RunManagerPanther::run_until(RUN_UNTIL_COND c
if (agent_info_set.size() == 0) // first entry is the listener, slave apears after this
{
cout << endl << " waiting for agents to appear..." << endl << endl;
f_rmr << endl << " waiting for agents to appear..." << endl << endl;
//f_rmr << endl << " waiting for agents to appear..." << endl << endl;
report("waiting for agents to appear", false);
}
else
{
Expand All @@ -464,11 +465,17 @@ RunManagerAbstract::RUN_UNTIL_COND RunManagerPanther::run_until(RUN_UNTIL_COND c
}
cout << endl;
f_rmr << endl;

cout << "PANTHER progress" << endl;
cout << " runs(C = completed | F = failed | T = timed out)" << endl;
cout << " agents(R = running | W = waiting | U = unavailable)" << endl;
cout << "------------------------------------------------------------------------------" << endl;
if (should_echo)
{
cout << "PANTHER progress" << endl;
cout << " runs(C = completed | F = failed | T = timed out)" << endl;
cout << " agents(R = running | W = waiting | U = unavailable)" << endl;
cout << "------------------------------------------------------------------------------" << endl;
}
else
{
cout << "'panther_echo' is 'false', running in silent mode - see rmr file for details" << endl;
}

std::chrono::system_clock::time_point start_time = std::chrono::system_clock::now();
double run_time_sec = 0.0;
Expand Down Expand Up @@ -1114,6 +1121,8 @@ int RunManagerPanther::schedule_run(int run_id, std::list<list<AgentInfoRec>::it

void RunManagerPanther::echo()
{
if (!should_echo)
return;
map<string, int> stats_map = get_agent_stats();
cout << get_time_string_short() << " runs("
<< "C=" << setw(5) << left << model_runs_done
Expand Down
3 changes: 2 additions & 1 deletion src/libs/run_managers/yamr/RunManagerPanther.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class RunManagerPanther : public RunManagerAbstract
{
public:
RunManagerPanther(const std::string &stor_filename, const std::string &port, std::ofstream &_f_rmr, int _max_n_failure,
double overdue_reched_fac, double overdue_giveup_fac, double overdue_giveup_minutes);
double overdue_reched_fac, double overdue_giveup_fac, double overdue_giveup_minutes, bool _should_echo=true);
virtual void initialize(const Parameters &model_pars, const Observations &obs, const std::string &_filename = std::string(""));
virtual void initialize_restart(const std::string &_filename);
virtual void reinitialize(const std::string &_filename = std::string(""));
Expand Down Expand Up @@ -135,6 +135,7 @@ class RunManagerPanther : public RunManagerAbstract
int model_runs_done;
int model_runs_failed;
int model_runs_timed_out;
bool should_echo;
fd_set master; // master file descriptor list
list<AgentInfoRec> agent_info_set;
map<int, list<AgentInfoRec>::iterator> socket_to_iter_map;
Expand Down
9 changes: 6 additions & 3 deletions src/programs/gsa/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,13 @@ int main(int argc, char* argv[])
fout_rec << endl << endl << "version: " << version << endl;
fout_rec << "binary compiled on " << __DATE__ << " at " << __TIME__ << endl << endl;
fout_rec << "using control file: \"" << cmdline.ctl_file_name << "\"" << endl;
fout_rec << "in directory: \"" << OperSys::getcwd() << "\"" << endl << endl;
fout_rec << "in directory: \"" << OperSys::getcwd() << "\"" << endl;
fout_rec << "on host: \"" << w_get_hostname() << "\"" << endl << endl;

cout << endl;
cout << "using control file: \"" << cmdline.ctl_file_name << "\"" << endl;
cout << "in directory: \"" << OperSys::getcwd() << "\"" << endl << endl;
cout << "in directory: \"" << OperSys::getcwd() << "\"" << endl;
cout << "on host: \"" << w_get_hostname() << "\"" << endl << endl;

// create pest run and process control file to initialize it
Pest pest_scenario;
Expand Down Expand Up @@ -169,7 +171,8 @@ int main(int argc, char* argv[])
pest_scenario.get_pestpp_options().get_max_run_fail(),
pest_scenario.get_pestpp_options().get_overdue_reched_fac(),
pest_scenario.get_pestpp_options().get_overdue_giveup_fac(),
pest_scenario.get_pestpp_options().get_overdue_giveup_minutes());
pest_scenario.get_pestpp_options().get_overdue_giveup_minutes(),
pest_scenario.get_pestpp_options().get_panther_echo());
}
else
{
Expand Down
Loading

0 comments on commit 08a31c3

Please sign in to comment.