From f3bef45f7c1d195ee7d3654f5aff14a7cb0a1780 Mon Sep 17 00:00:00 2001 From: Craig Warren Date: Tue, 1 Mar 2016 09:32:37 +0000 Subject: [PATCH] Moved plotting of results to a separate script/module. --- gprMax/optimisation_taguchi.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/gprMax/optimisation_taguchi.py b/gprMax/optimisation_taguchi.py index 4f497349..62c3ff24 100644 --- a/gprMax/optimisation_taguchi.py +++ b/gprMax/optimisation_taguchi.py @@ -132,22 +132,19 @@ def run_opt_sim(args, numbermodelruns, inputfile, usernamespace): break # Stop optimisation if successive fitness values are within a percentage threshold - if iteration > 2: - fitnessvaluesclose = (np.abs(fitnessvalueshist[iteration - 2] - fitnessvalueshist[iteration - 1]) / fitnessvalueshist[iteration - 1]) * 100 - fitnessvaluesthres = 0.1 - if fitnessvaluesclose < fitnessvaluesthres: - print('\nTaguchi optimisation stopped as successive fitness values within {}%'.format(fitnessvaluesthres)) - break +# if iteration > 2: +# fitnessvaluesclose = (np.abs(fitnessvalueshist[iteration - 2] - fitnessvalueshist[iteration - 1]) / fitnessvalueshist[iteration - 1]) * 100 +# fitnessvaluesthres = 0.1 +# if fitnessvaluesclose < fitnessvaluesthres: +# print('\nTaguchi optimisation stopped as successive fitness values within {}%'.format(fitnessvaluesthres)) +# break # Save optimisation parameters history and fitness values history to file opthistfile = inputfileparts[0] + '_hist' - np.savez(opthistfile, dict(optparamshist), fitnessvalueshist) + np.savez(opthistfile, dict(optparamshist), fitnessvalueshist=fitnessvalueshist, optparamsinit=optparamsinit) 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*'*')) - # Plot the history of fitness values and each optimised parameter values for the optimisation - plot_optimisation_history(fitnessvalueshist, optparamshist, optparamsinit) - def taguchi_code_blocks(inputfile, taguchinamespace): """Looks for and processes a Taguchi code block (containing Python code) in the input file. It will ignore any lines that are comments, i.e. begin with a double hash (##), and any blank lines.