From e0bb22b6b5e32552ad9862dc14403e9f0365c02f Mon Sep 17 00:00:00 2001 From: craig-warren Date: Wed, 2 Mar 2016 11:45:52 +0000 Subject: [PATCH] Writing optimisation history/data using pickle to file. --- gprMax/optimisation_taguchi.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gprMax/optimisation_taguchi.py b/gprMax/optimisation_taguchi.py index d658426e..eef0704f 100644 --- a/gprMax/optimisation_taguchi.py +++ b/gprMax/optimisation_taguchi.py @@ -16,7 +16,7 @@ # You should have received a copy of the GNU General Public License # along with gprMax. If not, see . -import importlib, os +import importlib, os, pickle from collections import OrderedDict import numpy as np @@ -140,8 +140,11 @@ def run_opt_sim(args, numbermodelruns, inputfile, usernamespace): # break # Save optimisation parameters history and fitness values history to file - opthistfile = inputfileparts[0] + '_hist' - np.savez(opthistfile, dict(optparamshist), fitnessvalueshist=fitnessvalueshist, optparamsinit=optparamsinit) + opthistfile = inputfileparts[0] + '_hist.pickle' + with open(opthistfile, 'wb') as f: + pickle.dump(optparamshist, f) + pickle.dump(fitnessvalueshist, f) + pickle.dump(optparamsinit, f) print('\n{}\nTaguchi optimisation completed after {} iteration(s).\nHistory of optimal parameter values {} and of fitness values {}\n{}\n'.format(68*'*', iteration, dict(optparamshist), fitnessvalueshist, 68*'*'))