Skip to content

Commit

Permalink
generate_graphs_autocorr works from the command line
Browse files Browse the repository at this point in the history
fixed a bug in mcmc.py where it did not count the number of new variables when using transforms like keq (this makes it so isotherm MCMC should work correctly now)
set the names correctly for the input_headers for autocorr graphs
  • Loading branch information
Immudzen committed Feb 21, 2020
1 parent 04709de commit 8adbcb6
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -325,3 +325,4 @@ __pycache__/
/Examples/MCMC/Dextran/nsga3_mcmc_6_emcee12_new
/Examples/MCMC/Dextran/nsga3_mcmc_6_emcee6_new
/Examples/MCMC/NonBinding/fit_delay
/Examples/MCMC/Linear/fit
2 changes: 1 addition & 1 deletion CADETMatch.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: CADETMatch
Version: 0.5.26
Version: 0.5.27
Summary: CADETMatch is a parameter estimation and error modeling library for CADET
Home-page: https://github.com/modsim/CADET-Match
Author: William Heymann
Expand Down
1 change: 1 addition & 0 deletions CADETMatch.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ CADETMatch/de_snooker.py
CADETMatch/evo.py
CADETMatch/fitness.py
CADETMatch/ga_simple.py
CADETMatch/generate_autocorr_graphs.py
CADETMatch/generate_corner_graphs.py
CADETMatch/generate_graphs.py
CADETMatch/grad.py
Expand Down
4 changes: 2 additions & 2 deletions CADETMatch/CADETMatch.pyproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>0067cb6f-0de6-4dd6-8086-20ea899a691d</ProjectGuid>
<ProjectHome>.</ProjectHome>
<StartupFile>generate_autocorr_graphs.py</StartupFile>
<StartupFile>match.py</StartupFile>
<SearchPath>
</SearchPath>
<WorkingDirectory>..</WorkingDirectory>
Expand All @@ -14,7 +14,7 @@
<IsWindowsApplication>False</IsWindowsApplication>
<InterpreterId>CondaEnv|CondaEnv|CADETMatch</InterpreterId>
<LaunchProvider>Standard Python launcher</LaunchProvider>
<CommandLineArguments>"C:\Users\kosh_000\Documents\Visual Studio 2017\Projects\CADETMatch\Examples\MCMC\Dextran\nsga3_mcmc_6_emcee12_new\mcmc_refine\MCMC_dextran_nsga3.json" 1</CommandLineArguments>
<CommandLineArguments>"C:\Users\kosh_000\Documents\Visual Studio 2017\Projects\CADETMatch\Examples\MCMC\Linear\fit\mcmc_refine\MCMC_linear.json" 6</CommandLineArguments>
<EnableNativeCodeDebugging>False</EnableNativeCodeDebugging>
<InterpreterArguments>
</InterpreterArguments>
Expand Down
2 changes: 1 addition & 1 deletion CADETMatch/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def run_command(module, json, number_of_jobs, additional=None):
if args.generate_corner:
sys.exit(run_command('CADETMatch.generate_corner_graphs', args.json, args.n))
if args.generate_graphs_autocorr:
sys.exit(run_command('CADETMatch.generate_graphs_autocorr', args.json, args.n))
sys.exit(run_command('CADETMatch.generate_autocorr_graphs', args.json, args.n))
if args.generate_graphs:
sys.exit(run_command('CADETMatch.generate_graphs', args.json, args.n, ['1']))
if args.generate_graphs_all:
Expand Down
2 changes: 1 addition & 1 deletion CADETMatch/generate_autocorr_graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def main(map_function):

graph_dir = cache.settings['resultsDirSpace'] / "mcmc"

input_headers = cache.parameter_headers
input_headers = cache.parameter_headers_actual

for chain in ("full_chain", "train_full_chain", "bounds_full_chain"):
if chain in mcmc_store.root:
Expand Down
11 changes: 10 additions & 1 deletion CADETMatch/search/mcmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,15 @@ def sampler_auto_bounds(cache, checkpoint, sampler, checkpointFile, mcmc_store):

parameters = len(cache.MIN_VALUE)

new_parameters = len(cache.settings['parameters']) - len(cache.settings.get('parameters_mcmc', []))
if 'mcmc_h5' in cache.settings:
data = cadet.H5()
data.filename = cache.settings['mcmc_h5']
data.load(paths='/bounds_change/center_trans')
previous_parameters = data.root.bounds_change.center_trans.shape[1]
else:
previous_parameters = 0

new_parameters = parameters - previous_parameters

finished = False

Expand Down Expand Up @@ -324,6 +332,7 @@ def sampler_auto_bounds(cache, checkpoint, sampler, checkpointFile, mcmc_store):
converged, lb, ub = converged_bounds(bounds_chain[:,:,:new_parameters], 200, 1e-3)

if converged:
#sys.exit()
finished = True

new_min_value, center, new_max_value = rescale(cache, lb, ub, numpy.array(cache.MIN_VALUE), numpy.array(cache.MAX_VALUE), mcmc_store)
Expand Down
44 changes: 31 additions & 13 deletions Examples/MCMC/Linear/MCMC_linear.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,37 @@
"resultsDir": "fit/",
"CSV": "linear_MCMC.csv",
"checkpointFile": "check",
"searchMethod": "MCMC",
"population": 100,
"roundParameters": 6,
"roundScores": 6,
"stopAverage": 1.1,
"stopBest": 1.1,
"gradCheck": 1.1,
"gradVector": 1,
"searchMethod": "NSGA3",
"mutationRate": 1.0,
"crossoverRate": 1.0,
"generations": 1000,
"population": 24,
"metaResultsOnly": 1,
"sobolGeneration":1,
"scoreMCMC":"score",
"graphSpearman": 0,
"stallGenerations": 50,
"normalizeOutput":1,
"graphMetaTime": 600,
"finalGradRefinement": 1,
"continueMCMC": 1,
"MCMCpopulationSet": 24,
"kde_synthetic": [
{
"file_path": "linear_pulse.h5",
"experimental_csv": "linear_pulse.csv",
"name": "main",
"units": [2],
"delay": [0.0, 2.0],
"flow": [1.0,0.007],
"load": [1.0,0.007],
"uv_noise": [0.0,1e-8],
"base": 100.0,
"count": 4000
}
],
"parameters": [
{
"transform": "norm_keq",
Expand All @@ -30,19 +52,15 @@
],
"experiments": [
{
"CSV": "F:/CADET_ParameterEstimation/adsorption/lrmp/linear/linear_pulse.csv",
"CSV": "linear_pulse.csv",
"isotherm": "/output/solution/unit_001/SOLUTION_OUTLET_COMP_000",
"HDF5": "F:/CADET_ParameterEstimation/adsorption/lrmp/linear/linear_pulse.h5",
"HDF5": "linear_pulse.h5",
"name": "main",
"timeout": 3.785061836242676,
"features": [
{
"name": "Pulse",
"type": "similarityHybrid2"
},
{
"name": "Deriv",
"type": "derivative_similarity_hybrid2"
"type": "ShapeDecay"
}
]
}
Expand Down

0 comments on commit 8adbcb6

Please sign in to comment.