def test_exe_mask_wrapper_debug(self): from functools import partial import numpy as np from pyeee import ee from pyeee.utils import exe_mask_wrapper, standard_parameter_writer, standard_objective_reader ishi = ['python3', 'tests/ishiexe.py'] npars = 3 parameterfile = 'params.txt' objectivefile = 'obj.txt' x0 = np.ones(npars) mask = np.ones(npars, dtype=np.bool) mask[1] = False func = partial(exe_mask_wrapper, ishi, x0, mask, parameterfile, standard_parameter_writer, objectivefile, standard_objective_reader, {'debug':True}) lb = np.ones(npars) * (-np.pi) ub = np.ones(npars) * np.pi out = ee(func, lb[mask], ub[mask], nt=self.nt, ntotal=self.ntotal, nsteps=self.nsteps, processes=1) self.assertEqual(list(np.around(out[:,0],3)), [287.258, 0.])
def test_func_mask_wrapper(self): from functools import partial import numpy as np from pyeee import ee from pyeee.functions import ishigami_homma from pyeee.utils import func_mask_wrapper func = ishigami_homma npars = 3 x0 = np.ones(npars) mask = np.ones(npars, dtype=np.bool) mask[1] = False arg = [1., 3.] kwarg = {} obj = partial(func_mask_wrapper, func, x0, mask, arg, kwarg) lb = np.ones(npars) * (-np.pi) ub = np.ones(npars) * np.pi out = ee(obj, lb[mask], ub[mask], nt=self.nt, ntotal=self.ntotal, nsteps=self.nsteps, processes=1) self.assertEqual(list(np.around(out[:,0],3)), [287.258, 0.])
def test_ee_k(self): from functools import partial import os import numpy as np from pyeee import ee from pyeee.functions import bratley from pyeee.utils import func_wrapper # Function and parameters func = bratley npars = 10 params = [] # k # Screening lb = np.zeros(npars) ub = np.ones(npars) out = ee(func, lb, ub, self.nt, x0=None, mask=None, ntotal=self.ntotal, nsteps=self.nsteps, processes=1) # Check self.assertEqual( list(np.around(out[:, 0], 3)), [0.586, 0.219, 0.082, 0.055, 0.02, 0.068, 0.009, 0.007, 0., 0.])
def test_ee_g(self): from functools import partial import numpy as np from pyeee import ee from pyeee.functions import G from pyeee.utils import func_wrapper # Function and parameters func = G npars = 6 params = [78., 12., 0.5, 2., 97., 33.] # G # Partialise function with fixed parameters arg = [params] kwarg = {} obj = partial(func_wrapper, func, arg, kwarg) # Screening lb = np.zeros(npars) ub = np.ones(npars) out = ee(obj, lb, ub, self.nt, x0=None, mask=None, ntotal=self.ntotal, nsteps=self.nsteps, processes=1) # Check self.assertEqual(list(np.around(out[:, 0], 3)), [0.045, 0.24, 1.624, 0.853, 0.031, 0.084])
def test_ee_g_1(self): from functools import partial import numpy as np from pyeee import ee from pyeee.functions import G from pyeee.utils import func_wrapper # Function and parameters func = G npars = 6 params = [78., 12., 0.5, 2., 97., 33.] # G # Partialise function with fixed parameters arg = [params] kwarg = {} obj = partial(func_wrapper, func, arg, kwarg) # Screening lb = np.zeros(npars) ub = np.ones(npars) out = ee(obj, lb, ub, npars, processes=4) # Check self.assertEqual(list(np.around(out[:, 0], 3)), [0.047, 0.233, 1.539, 0.747, 0.025, 0.077])
def test_ee_fmorris(self): from functools import partial import numpy as np from pyeee import ee from pyeee.functions import fmorris from pyeee.utils import func_wrapper # Function and parameters func = fmorris npars = 20 beta0 = 0. beta1 = np.random.standard_normal(npars) beta1[:10] = 20. beta2 = np.random.standard_normal((npars, npars)) beta2[:6, :6] = -15. beta3 = np.zeros((npars, npars, npars)) beta3[:5, :5, :5] = -10. beta4 = np.zeros((npars, npars, npars, npars)) beta4[:4, :4, :4, :4] = 5. # Partialise Morris function with fixed parameters beta0-4 arg = [beta0, beta1, beta2, beta3, beta4] kwarg = {} obj = partial(func_wrapper, func, arg, kwarg) # Screening lb = np.zeros(npars) ub = np.ones(npars) # Check out = ee(obj, lb, ub, self.nt, x0=None, mask=None, ntotal=self.ntotal, nsteps=self.nsteps, processes=4) self.assertEqual(list(np.around(out[:, 0], 3)), [ 66.261, 48.363, 20.133, 62.42, 37.87, 26.031, 30.211, 39.714, 42.633, 43.776, 4.996, 3.701, 4.734, 8.031, 5.734, 3.564, 5.068, 7.635, 3.129, 5.224 ])
def test_func_wrapper(self): from functools import partial import numpy as np from pyeee import ee from pyeee.functions import ishigami_homma from pyeee.utils import func_wrapper func = ishigami_homma npars = 3 arg = [1., 3.] kwarg = {} obj = partial(func_wrapper, func, arg, kwarg) lb = np.ones(npars) * (-np.pi) ub = np.ones(npars) * np.pi out = ee(obj, lb, ub, nt=self.nt, ntotal=self.ntotal, nsteps=self.nsteps, processes=4) self.assertEqual(list(np.around(out[:,0],3)), [369.614, 0.576, 184.987])
def test_exe_wrapper4_shell_debug(self): from functools import partial import numpy as np from pyeee import ee from pyeee.utils import exe_wrapper, standard_parameter_writer, standard_objective_reader ishi = './tests/ishiexe.sh' npars = 3 parameterfile = 'params.txt' objectivefile = 'obj.txt' func = partial(exe_wrapper, ishi, parameterfile, standard_parameter_writer, objectivefile, standard_objective_reader, {'pid':True, 'shell':True, 'debug':True}) lb = np.ones(npars) * (-np.pi) ub = np.ones(npars) * np.pi out = ee(func, lb, ub, nt=self.nt, ntotal=self.ntotal, nsteps=self.nsteps, processes=4) self.assertEqual(list(np.around(out[:,0],3)), [369.614, 0.576, 184.987])
def test_ee_g_mask(self): from functools import partial import numpy as np from pyeee import ee from pyeee.functions import G from pyeee.utils import func_wrapper # Function and parameters func = G npars = 6 params = [78., 12., 0.5, 2., 97., 33.] # G # Partialise function with fixed parameters arg = [params] kwarg = {} obj = partial(func_wrapper, func, arg, kwarg) # Screening lb = np.zeros(npars) ub = np.ones(npars) x0 = np.ones(npars) * 0.5 mask = np.ones(npars, dtype=np.bool) mask[1] = False out = ee(obj, lb, ub, self.nt, x0=x0, mask=mask, ntotal=self.ntotal, nsteps=self.nsteps, processes=1) # Check self.assertEqual(list(np.around(out[:, 0], 3)), [0.038, 0.0, 1.582, 1.136, 0.04, 0.102])
def test_exe_wrapper(self): from functools import partial import numpy as np from pyeee import ee from pyeee.functions import ishigami_homma from pyeee.utils import exe_wrapper, standard_parameter_writer, standard_objective_reader ishi = ['python3', 'tests/ishiexe.py'] npars = 3 parameterfile = 'params.txt' objectivefile = 'obj.txt' func = partial(exe_wrapper, ishi, parameterfile, standard_parameter_writer, objectivefile, standard_objective_reader, {}) lb = np.ones(npars) * (-np.pi) ub = np.ones(npars) * np.pi out = ee(func, lb, ub, nt=self.nt, ntotal=self.ntotal, nsteps=self.nsteps, processes=1) self.assertEqual(list(np.around(out[:,0],3)), [369.614, 0.576, 184.987])