Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Miniskar, Narasinga Rao
deffe
Commits
5cb79763
Commit
5cb79763
authored
Jun 27, 2020
by
Narasinga Rao Miniskar
Browse files
Supported Lattice Hypercube
parent
903ec538
Changes
3
Hide whitespace changes
Inline
Side-by-side
example/config_small_sampling.json
View file @
5cb79763
...
...
@@ -128,7 +128,7 @@
},
"sampling"
:
{
"pyscript"
:
"random_sampling.py"
,
"arguments"
:
"-method
box_behnken
"
,
"arguments"
:
"-method
lhs
"
,
"output_log"
:
"sampling.log"
},
"evaluate"
:
{
...
...
framework/random_sampling.py
View file @
5cb79763
...
...
@@ -97,6 +97,11 @@ class DeffeRandomSampling:
self
.
_seq
=
org_seq
else
:
sample_mat
=
None
param_dict_actual
=
param_dict
#param_dict = { k:np.array(v).astype('float').tolist() for k,v in param_dict_actual.items() }
#param_dict_hold = { k:np.array(v).astype('float').tolist() for k,v in param_dict_actual.items() }
param_dict
=
{
k
:[
index
for
index
in
range
(
len
(
v
))]
for
k
,
v
in
param_dict_actual
.
items
()
}
param_dict_hold
=
{
k
:[
index
for
index
in
range
(
len
(
v
))]
for
k
,
v
in
param_dict_actual
.
items
()
}
if
sampling_method
==
'frac_fact_res'
:
sample_mat
=
build
.
frac_fact_res
(
param_dict
)
elif
sampling_method
==
'plackett_burman'
:
...
...
@@ -125,14 +130,26 @@ class DeffeRandomSampling:
print
(
"[Error] Unknown method:{} of sampling!"
.
format
(
sampling
))
sys
.
exit
(
1
)
np_records
=
sample_mat
.
values
.
astype
(
"str"
)
np_hdrs
=
np
.
char
.
lower
(
np
.
array
(
list
(
sample_mat
.
columns
)).
astype
(
"str"
))
sel_param_hash
=
{
k
:
re
.
sub
(
r
'\.0$'
,
''
,
np_records
[
index
])
sample_mat_val
=
np
.
round
(
sample_mat
.
values
)
sample_mat
=
np
.
zeros
(
sample_mat_val
.
shape
,
dtype
=
int
)
for
i
in
range
(
sample_mat_val
.
shape
[
1
]):
id_keys
=
np
.
digitize
(
sample_mat_val
[:,
i
],
param_dict_hold
[
np_hdrs
[
i
]],
right
=
True
)
sample_mat
[:,
i
]
=
np
.
array
(
param_dict_actual
[
np_hdrs
[
i
]])[
id_keys
]
sample_mat
=
np
.
unique
(
sample_mat
,
axis
=
0
)
n_samples
=
sample_mat
.
shape
[
0
]
self
.
_n_samples
=
n_samples
np_records
=
sample_mat
.
astype
(
"str"
)
def
GetRecHash
(
rec
):
sel_param_hash
=
{
k
:
rec
[
index
]
for
index
,
k
in
enumerate
(
np_hdrs
)
}
return
sel_param_hash
self
.
_seq
=
np
.
array
([
self
.
parameters
.
EncodePermutation
(
sel_param_pash
)
\
self
.
parameters
.
EncodePermutation
(
\
GetRecHash
(
rec
)
\
)
\
for
rec
in
np_records
]).
astype
(
"int"
)
if
self
.
_shuffle
:
...
...
utils/param_data.py
View file @
5cb79763
import
os
import
pdb
import
re
import
sys
import
numpy
as
np
import
pandas
as
pd
import
argparse
import
shlex
class
ParamData
:
def
__init__
(
self
,
framework
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment