Skip to content

Commit 27d7358

Browse files
committed
Merge remote-tracking branch 'origin'
2 parents 014edff + 675a46f commit 27d7358

34 files changed

Lines changed: 726 additions & 232 deletions

benchmarks/basic_tests.py

Lines changed: 97 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@
88
import pyemu
99

1010
bin_path = os.path.join("test_bin")
11+
plat = "unknown"
1112
if "linux" in platform.platform().lower():
1213
bin_path = os.path.join(bin_path,"linux")
14+
plat = "linux"
1315
elif "darwin" in platform.platform().lower() or "macos" in platform.platform().lower() :
1416
bin_path = os.path.join(bin_path,"mac")
17+
plat = "apple"
1518
else:
1619
bin_path = os.path.join(bin_path,"win")
20+
plat = "windows"
1721

1822
bin_path = os.path.abspath("test_bin")
1923
os.environ["PATH"] += os.pathsep + bin_path
@@ -43,6 +47,60 @@
4347
num_reals = 20
4448
port = 4021
4549

50+
51+
def nonascii_path_test(model_d="ies_10par_xsec"):
52+
pyemu.Ensemble.reseed()
53+
base_d = os.path.join(model_d, "template")
54+
new_d = os.path.join(model_d, "test_template_\u0187")
55+
if os.path.exists(new_d):
56+
shutil.rmtree(new_d)
57+
shutil.copytree(base_d, new_d)
58+
print(platform.platform().lower())
59+
pst = pyemu.Pst(os.path.join(new_d, "pest.pst"))
60+
cmd = pst.model_command[0].split()
61+
print(cmd)
62+
cmd = "\"\"{0}\" \"{1}\"\"".format(cmd[0],cmd[1])
63+
print(cmd)
64+
pst.model_command.append(cmd)
65+
cmd = pst.model_command[0].split()
66+
cmd = "\"\'{0}\' \'{1}\'\"".format(cmd[0],cmd[1])
67+
pst.model_command.append(cmd)
68+
69+
tpl_data = pst.model_input_data
70+
tpl_data["pest_file"] = tpl_data.pest_file.apply(lambda x: "\"{0}\"".format(x))
71+
tpl_data["model_file"] = tpl_data.model_file.apply(lambda x: "\"{0}\"".format(x))
72+
73+
ins_data = pst.model_output_data
74+
ins_data["pest_file"] = ins_data.pest_file.apply(lambda x: "\"{0}\"".format(x))
75+
ins_data["model_file"] = ins_data.model_file.apply(lambda x: "\"{0}\"".format(x))
76+
77+
pst.control_data.noptmax = 1
78+
pst.observation_data.loc[pst.nnz_obs_names,"weight"] = 1.0
79+
#pst.pestpp_options["panther_agent_freeze_on_fail"] = True
80+
pst.pestpp_options["ies_num_reals"] = 5
81+
pst.write(os.path.join(new_d, "pest.pst"))
82+
83+
84+
m_d = os.path.join(model_d,"master_pestpp")
85+
if os.path.exists(m_d):
86+
shutil.rmtree(m_d)
87+
shutil.copytree(new_d,m_d)
88+
89+
worker_root = os.path.join(model_d + "_\u0187")
90+
if os.path.exists(worker_root):
91+
shutil.rmtree(worker_root)
92+
os.makedirs(worker_root)
93+
try:
94+
pyemu.os_utils.start_workers(new_d, exe_path, "pest.pst", 1, master_dir=m_d,
95+
worker_root=worker_root,port=port,verbose=True)
96+
except Exception as e:
97+
if plat != "windows":
98+
raise Exception(e)
99+
else:
100+
if plat == "windows":
101+
raise Exception("should have failed")
102+
103+
46104
def basic_test(model_d="ies_10par_xsec"):
47105
pyemu.Ensemble.reseed()
48106
base_d = os.path.join(model_d, "template")
@@ -57,7 +115,38 @@ def basic_test(model_d="ies_10par_xsec"):
57115
cmd = "\"\"{0}\" \"{1}\"\"".format(cmd[0],cmd[1])
58116
print(cmd)
59117
pst.model_command.append(cmd)
118+
cmd = pst.model_command[0].split()
119+
cmd = "\"\'{0}\' \'{1}\'\"".format(cmd[0],cmd[1])
120+
pst.model_command.append(cmd)
121+
122+
tpl_data = pst.model_input_data
123+
tpl_data["pest_file"] = tpl_data.pest_file.apply(lambda x: "\"{0}\"".format(x))
124+
tpl_data["model_file"] = tpl_data.model_file.apply(lambda x: "\"{0}\"".format(x))
60125

126+
ins_data = pst.model_output_data
127+
ins_data["pest_file"] = ins_data.pest_file.apply(lambda x: "\"{0}\"".format(x))
128+
ins_data["model_file"] = ins_data.model_file.apply(lambda x: "\"{0}\"".format(x))
129+
130+
pst.control_data.noptmax = 0
131+
pst.write(os.path.join(new_d, "pest.pst"))
132+
pyemu.os_utils.run("{0} pest.pst".format(exe_path),cwd=new_d)
133+
# pst.write(os.path.join(new_d, "pest.pst"),version=2)
134+
# pyemu.os_utils.run("{0} pest.pst".format(exe_path),cwd=new_d)
135+
136+
tpl_data = pst.model_input_data
137+
tpl_data["pest_file"] = tpl_data.pest_file.apply(lambda x: "\'{0}\'".format(x))
138+
tpl_data["model_file"] = tpl_data.model_file.apply(lambda x: "\'{0}\'".format(x))
139+
140+
ins_data = pst.model_output_data
141+
ins_data["pest_file"] = ins_data.pest_file.apply(lambda x: "\'{0}\'".format(x))
142+
ins_data["model_file"] = ins_data.model_file.apply(lambda x: "\'{0}\'".format(x))
143+
144+
pst.control_data.noptmax = 0
145+
pst.write(os.path.join(new_d, "pest.pst"))
146+
pyemu.os_utils.run("{0} pest.pst".format(exe_path),cwd=new_d)
147+
# pst.write(os.path.join(new_d, "pest.pst"),version=2)
148+
# pyemu.os_utils.run("{0} pest.pst".format(exe_path),cwd=new_d)
149+
61150
# set first par as fixed
62151
#pst.parameter_data.loc[pst.par_names[0], "partrans"] = "fixed"
63152

@@ -2030,11 +2119,15 @@ def mf6_v5_ies_nonpersistent_test():
20302119
assert found == num_workers
20312120

20322121

2033-
2122+
def parse_pst_test():
2123+
t_d = os.path.join("parse_pst_testfiles","kerry")
2124+
pyemu.os_utils.run("{0} control.pst".format(exe_path),cwd=t_d)
20342125

20352126

20362127
if __name__ == "__main__":
2037-
basic_test()
2128+
#parse_pst_test()
2129+
#basic_test()
2130+
nonascii_path_test()
20382131

20392132
#mf6_v5_ies_nonpersistent_test()
20402133
#large_fake_test()
@@ -2049,7 +2142,7 @@ def mf6_v5_ies_nonpersistent_test():
20492142
#plot_collapse_invest()
20502143

20512144
#run()
2052-
# mf6_v5_ies_test()
2145+
#mf6_v5_ies_test()
20532146
#prep_ends()
20542147
#sweep_bin_test()
20552148
# mf6_v5_sen_test()
@@ -2096,7 +2189,7 @@ def mf6_v5_ies_nonpersistent_test():
20962189
#mf6_v5_sen_test()
20972190

20982191
#shutil.copy2(os.path.join("..","exe","windows","x64","Debug","pestpp-opt.exe"),os.path.join("..","bin","win","pestpp-opt.exe"))
2099-
mf6_v5_opt_stack_test()
2192+
#mf6_v5_opt_stack_test()
21002193
# mf6_v5_glm_test()
21012194
# mf6_v5_ies_test()
21022195
#cmdline_test()

benchmarks/henry_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ def setup_pst():
318318
pf.pst.pestpp_options["opt_dec_var_groups"] = "dv_pars"
319319
pf.pst.pestpp_options["panther_echo"] = True
320320
pf.pst.pestpp_options["mou_risk_objective"] = True
321-
pf.pst.pestpp_options["mou_generator"] = "de"
321+
pf.pst.pestpp_options["mou_generator"] = "pso"
322322
pf.pst.pestpp_options["mou_population_size"] = 100
323323

324324
pf.pst.try_parse_name_metadata()
@@ -618,8 +618,8 @@ def invest():
618618

619619

620620

621-
def run_mou(risk_obj=False,chance_points="single",risk=0.5,stack_size=100,
622-
num_workers=12,pop_size=100,tag="",recalc_every=100000,noptmax=100):
621+
def run_mou(risk_obj=False,chance_points="single",risk=0.5,stack_size=10,
622+
num_workers=12,pop_size=10,tag="",recalc_every=100000,noptmax=3):
623623
t_d = os.path.join("henry","henry_template")
624624
pst = pyemu.Pst(os.path.join(t_d,"henry.pst"))
625625
pst.pestpp_options["opt_par_stack"] = "prior.jcb"
@@ -793,7 +793,7 @@ def simple_henry_test():
793793

794794
plot_domain(os.path.join("henry", "henry_temp"))
795795
setup_pst()
796-
run_mou(risk=0.65,tag="65_single_once",num_workers=10,noptmax=10,pop_size=50,stack_size=30)
796+
run_mou(risk=0.65,tag="65_single_once",num_workers=10,noptmax=10,pop_size=10,stack_size=10)
797797

798798

799799

benchmarks/ies_10par_xsec/template/pest.pst

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,9 @@ head
5050
h02_09 4.7000000000E+00 0.0000000000E+00 head
5151
h02_10 5.1000000000E+00 0.0000000000E+00 head
5252
* model command line
53-
mfnwt ./10par_xsec.nam
53+
mfnwt 10par_xsec.nam
5454
* model input/output
55-
.\hk_Layer_1.ref.tpl .\hk_Layer_1.ref
56-
.\hk_Layer_1.ref.tpl .\nested/really\deep/hk_Layer_1.ref
57-
.\strt_Layer_1.ref.tpl .\strt_Layer_1.ref
58-
.\10par_xsec.hds.ins .\10par_xsec.hds
59-
++panther_transfer_on_finish(10par_xsec.hds,10par_xsec.list)
60-
++ies_num_reals(5)
55+
hk_Layer_1.ref.tpl hk_Layer_1.ref
56+
hk_Layer_1.ref.tpl nested/really\deep/hk_Layer_1.ref
57+
strt_Layer_1.ref.tpl strt_Layer_1.ref
58+
10par_xsec.hds.ins 10par_xsec.hds

0 commit comments

Comments
 (0)