From 8adbcb6d19d7ec5d4ae4abdaf7430c01a3fde768 Mon Sep 17 00:00:00 2001 From: William Heymann Date: Fri, 21 Feb 2020 12:45:35 +0100 Subject: [PATCH] generate_graphs_autocorr works from the command line 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 --- .gitignore | 1 + CADETMatch.egg-info/PKG-INFO | 2 +- CADETMatch.egg-info/SOURCES.txt | 1 + CADETMatch/CADETMatch.pyproj | 4 +-- CADETMatch/__main__.py | 2 +- CADETMatch/generate_autocorr_graphs.py | 2 +- CADETMatch/search/mcmc.py | 11 ++++++- Examples/MCMC/Linear/MCMC_linear.json | 44 ++++++++++++++++++-------- 8 files changed, 48 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 0df39c4..fb8c8e6 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/CADETMatch.egg-info/PKG-INFO b/CADETMatch.egg-info/PKG-INFO index 7f8d9af..c004e49 100644 --- a/CADETMatch.egg-info/PKG-INFO +++ b/CADETMatch.egg-info/PKG-INFO @@ -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 diff --git a/CADETMatch.egg-info/SOURCES.txt b/CADETMatch.egg-info/SOURCES.txt index 5c47fd0..cd2afaf 100644 --- a/CADETMatch.egg-info/SOURCES.txt +++ b/CADETMatch.egg-info/SOURCES.txt @@ -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 diff --git a/CADETMatch/CADETMatch.pyproj b/CADETMatch/CADETMatch.pyproj index 5911bef..f665d86 100644 --- a/CADETMatch/CADETMatch.pyproj +++ b/CADETMatch/CADETMatch.pyproj @@ -4,7 +4,7 @@ 2.0 0067cb6f-0de6-4dd6-8086-20ea899a691d . - generate_autocorr_graphs.py + match.py .. @@ -14,7 +14,7 @@ False CondaEnv|CondaEnv|CADETMatch Standard Python launcher - "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 + "C:\Users\kosh_000\Documents\Visual Studio 2017\Projects\CADETMatch\Examples\MCMC\Linear\fit\mcmc_refine\MCMC_linear.json" 6 False diff --git a/CADETMatch/__main__.py b/CADETMatch/__main__.py index 2f5793e..97b93e5 100644 --- a/CADETMatch/__main__.py +++ b/CADETMatch/__main__.py @@ -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: diff --git a/CADETMatch/generate_autocorr_graphs.py b/CADETMatch/generate_autocorr_graphs.py index 259aa7b..bb9596f 100644 --- a/CADETMatch/generate_autocorr_graphs.py +++ b/CADETMatch/generate_autocorr_graphs.py @@ -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: diff --git a/CADETMatch/search/mcmc.py b/CADETMatch/search/mcmc.py index 6ef8f0c..276991b 100644 --- a/CADETMatch/search/mcmc.py +++ b/CADETMatch/search/mcmc.py @@ -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 @@ -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) diff --git a/Examples/MCMC/Linear/MCMC_linear.json b/Examples/MCMC/Linear/MCMC_linear.json index 6a04e01..ce6d55f 100644 --- a/Examples/MCMC/Linear/MCMC_linear.json +++ b/Examples/MCMC/Linear/MCMC_linear.json @@ -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", @@ -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" } ] }