Skip to content

Commit d40e044

Browse files
author
Sancar Adali
committed
add test script for comparing with C binary
1 parent f47d529 commit d40e044

File tree

2 files changed

+87
-13
lines changed

2 files changed

+87
-13
lines changed

man/run_graph_match.Rd

+7-7
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ algo_fw_xeps=0.01 ,
4949
algo_fw_feps=0.01 ,
5050
# 0 - just add a set of isolated nodes to the smallest graph
5151
# 1 - double size
52-
dummy_nodes=0,
52+
dummy_nodes=as.integer(0),
5353
# fill for dummy nodes (0.5 - these nodes will be connected with all other
5454
# by edges of weight 0.5(min_weight+max_weight))
55-
dummy_nodes_fill=0,
55+
dummy_nodes_fill=as.integer(0),
5656
# fill for linear matrix C, usually that's the minimum (dummy_nodes_c_coef=0),
5757
# but may be the maximum (dummy_nodes_c_coef=1)
5858
dummy_nodes_c_coef=0.01,
@@ -62,21 +62,21 @@ qcvqcc_lambda_min=1E-5,
6262

6363

6464
# 0 - all matching are possible, 1-only matching with positive local similarity are possible
65-
blast_match=1 ,
66-
blast_match_proj=0 ,
65+
blast_match=as.integer(1) ,
66+
blast_match_proj=as.integer(0) ,
6767

6868

6969
#****************OUTPUT***************************************
7070
#output file and its format
7171
exp_out_file="exp_out_file" ,
7272
exp_out_format="Parameters Compact Permutation",
7373
#other
74-
debugprint=1 ,
74+
debugprint=as.integer(1) ,
7575
debugprint_file="debug.txt",
76-
verbose_mode=1 ,
76+
verbose_mode=as.integer(1) ,
7777
# verbose file may be a file or just a screen:cout
7878
verbose_file="verbose_debug.txt",
79-
graph_dot_print = 1
79+
graph_dot_print = as.integer(1)
8080
)
8181
print( algorithm_params)
8282
print ("Dimensions of A")

test/testGraphM.R

+80-6
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,97 @@
4646
# //verbose file may be a file or just a screen:cout
4747
# verbose_file=cout s
4848

49+
test_algo_pars<-list(
50+
# Already provided as A and B matrices
51+
# *******************ALGORITHMS********************************
52+
# used algorithms and what should be used as
53+
#initial solution in corresponding algorithms
54+
algo="I QCV PATH",
55+
algo_init_sol="unif unif unif",
56+
solution_file="solution_im.txt",
57+
# coeficient of linear combination between
58+
# (1-alpha_ldh)*||graph_1-P*graph_2*P^T||^2_F +alpha_ldh*C_matrix
59+
alpha_ldh=0 ,
60+
cdesc_matrix="A" ,
61+
cscore_matrix="A" ,
62+
C_matrix = "none",
63+
# **************PARAMETERS SECTION*****************************
64+
hungarian_max=10000 ,
65+
algo_fw_xeps=0.01 ,
66+
algo_fw_feps=0.01 ,
67+
# 0 - just add a set of isolated nodes to the smallest graph
68+
# 1 - double size
69+
dummy_nodes=as.integer(0),
70+
# fill for dummy nodes (0.5 - these nodes will be connected with all other
71+
# by edges of weight 0.5(min_weight+max_weight))
72+
dummy_nodes_fill=as.integer(0),
73+
# fill for linear matrix C, usually that's the minimum (dummy_nodes_c_coef=0),
74+
# but may be the maximum (dummy_nodes_c_coef=1)
75+
dummy_nodes_c_coef=0.01,
76+
77+
qcvqcc_lambda_M=10,
78+
qcvqcc_lambda_min=1E-5,
79+
80+
81+
# 0 - all matching are possible, 1-only matching with positive local similarity are possible
82+
blast_match=as.integer(1) ,
83+
blast_match_proj=as.integer(0) ,
84+
85+
86+
87+
#****************OUTPUT***************************************
88+
#output file and its format
89+
exp_out_file="exp_out_file" ,
90+
exp_out_format="Parameters Compact Permutation",
91+
#other
92+
debugprint=as.integer(1) ,
93+
debugprint_file="debug.txt",
94+
verbose_mode=as.integer(1) ,
95+
# verbose file may be a file or just a screen:cout
96+
verbose_file="verbose_debug.txt",
97+
graph_dot_print = as.integer(1)
98+
)
99+
49100

50101
test_graph_match <- function(A,B,algorithm_params) {
51102
writeMat(A,"./src/graphm/Rpkgtest/testA")
52103
writeMat(B,"./src/graphm/Rpkgtest/testB")
53104
write_config("./src/graphm/Rpkgtest/config.txt",A,B,algorithm_params)
54-
system("./src/graphm/bin/graphm config.txt")
105+
system("./src/graphm/bin/graphm.exe ./src/graphm/Rpkgtest/config.txt",show.output.on.console = T)
55106
}
56107

57108
writeMat <- function (A,filepath) {
58109

59-
writeLines(A,filepath)
110+
write.table(A,file = filepath,row.names= F, col.names=F)
60111
}
61112
write_config <- function (filepath,A,B,algo_params){
62-
writeLines("graph_1=./src/graphm/Rpkgtest/testA",filepath)
63-
writeLines("graph_2=./src/graphm/Rpkgtest/testB",filepath)
64-
for ( par in algo_params) {
65-
writeLines(names(par),'=', par ," " ,"s" ,filepath)
113+
new_f = file(filepath,open = 'wt')
114+
#open(new_f)
115+
writeLines(text= "graph_1=./src/graphm/Rpkgtest/testA s",new_f)
116+
writeLines(text= "graph_2=./src/graphm/Rpkgtest/testB s",new_f)
117+
close(new_f)
118+
for ( par_name in names(algo_params)) {
119+
par = algo_params[[par_name]]
120+
print (par)
121+
if (is.numeric(par)) {
122+
if (is.double(par)) {
123+
type = 'd'
124+
}
125+
else if (is.integer(par)) {
126+
type = 'i'
127+
}
128+
} else if (is.character(par)){
129+
if (nchar(par)==0) {
130+
print ("invalid parameter value for " + names(par))
131+
}
132+
if (nchar(par)==1) {
133+
type = 'c'
134+
} else {
135+
type = 's'
136+
}
137+
138+
}
139+
write(paste0(par_name,'=', par ," " ,type ,collapse = ""),file = filepath, append = TRUE)
66140

67141
}
68142

0 commit comments

Comments
 (0)