-
Notifications
You must be signed in to change notification settings - Fork 0
/
RBBComp.R
94 lines (80 loc) · 2.68 KB
/
RBBComp.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
Configure = function(historyEnabled, path) {
dyn.load("RProxy.so", local=FALSE)
INIT = .C("R_init", status=as.integer(0))
if (INIT$status == 0)
return(0)
CONF = .C("R_configure", history = as.integer(historyEnabled), logPath = as.character(path), status = as.integer(0))
return(CONF$status)
}
Login = function(login, password) {
LOGIN = .C("R_login", log = as.character(login), pass = as.character(password), status = as.integer(0))
return(LOGIN$status)
}
NumberOfTracks = function() {
NO_TRACKS = .C("R_numberOfTracks", noTracks = as.integer(0), status = as.integer(0))
if (NO_TRACKS$status == 0)
return(0)
return(NO_TRACKS$noTracks)
}
TrackName = function(index) {
T_NAME = .C("R_trackName", trackIndex=as.integer(index), name=as.character(""), status = as.integer(0))
if (T_NAME$status == 0)
return("")
return(T_NAME$name)
}
SetTrack = function(t_name) {
SET_TRACK = .C("R_setTrack", name=as.character(t_name), status = as.integer(0))
return(SET_TRACK$status)
}
NumberOfProblems = function() {
NO_PROBLEMS = .C("R_numberOfProblems", n = as.integer(0), status = as.integer(0))
if (NO_PROBLEMS$status == 0)
return(-1)
return(NO_PROBLEMS$n)
}
SetProblem = function(n) {
SET_PROBLEM = .C("R_setProblem", n = as.integer(n), status = as.integer(0))
return(SET_PROBLEM$status)
}
Dimension = function() {
DIM = .C("R_dimension", n = as.integer(0), status = as.integer(0))
if (DIM$status == 0)
return(0)
return(DIM$n)
}
Budget = function() {
BUDGET = .C("R_budget", n = as.integer(0), status = as.integer(0))
if (BUDGET$status == 0)
return(0)
return(BUDGET$n)
}
Evaluations = function() {
EVALUATIONS = .C("R_evaluations", n = as.integer(0), status = as.integer(0))
if (EVALUATIONS$status == 0)
return(0)
return(EVALUATIONS$n)
}
Evaluate = function(points) {
N = max(1, nrow(points))
EVAL = .C("R_evaluate", point = as.double(t(points)), value = as.double(rep(1e100, N)), data_length=length(points), status = as.integer(0))
if (EVAL$status < N)
warning("Not all of requested points were calculated correctly.")
return(EVAL$value)
}
History = function(index, points) {
N = max(1, nrow(points))
HIST = .C("R_history", index=as.integer(index), point = as.double(points), value = as.double(rep(1e100, N)), data_length=length(points), status = as.integer(0))
if (HIST$status < N)
warning("Not all of requested points were calculated correctly.")
return(HIST$value)
}
ErrorMessage = function() {
MSG = .C("R_errorMessage", msg = as.character(""), status = as.integer(0))
if (MSG$status == 0)
return("")
return(MSG$msg)
}
# This doesn't really logout - it only unload DLL
Logout = function() {
dyn.unload("RProxy.so")
}