-
Notifications
You must be signed in to change notification settings - Fork 16
/
mnk_playground.R
59 lines (40 loc) · 1.33 KB
/
mnk_playground.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#remotes::install_github("jakobbossek/smoof")
#library(smoof)
load_all(".")
# NOTE: this is not working yet!It is just an exmaple of the planned "workflow"
# EXAMPLES: HOMOGENEOUS NK-LANDSCAPES
# ===
# Parameters
M = 2L
N = 10L
K = 2L
set.seed(123)
# examplary bit-string
x = sample(c(0, 1), size = N, replace = TRUE)
# generate two single-objective NK-landscapes
fn1 = makeNKFunction(N, K)
stop()
fn2 = makeNKFunction(N, K)
# export and import
path = "my_NK_function"
exportNKFunction(fn1, path)
fn1 = importNKFunction(path)
# build a two-objective MNK-landscape
moofn = makeMNKFunction(M, N, K)
# build "heterogenous" MNK-landscape (different k for every objective)
moofn = makeMNKFunction(M, N, K = c(2L, 5L))
# alternative constructor by passing two single-objective NK-landscapes
moofn = makeMNKFunction(funs = c(fn1, fn2))
# another alternative passing path names to exported single-objective NK-landscapes
moofn = makeMNKFunction(funs = c("instances/fn1", "instances/fn2"))
# call :)
moofn(x)
# EXAMPLES: HETEROGENEOUS NK-LANDSCAPES
# ===
K_min = 2L
K_max = 5L
# different K for every bit sampled from U(K_min, K_max)
K = sample(K_min:K_max, size = N, replace = TRUE)
# In addition: use Cauchy distribution (instead of Normal-distribution) to
# sample function values f_i, i = 1, ..., N
fn1 = makeNKFunction(N, K, distr = pcauchy)