@@ -80,7 +80,8 @@ def grasp(
80
80
depth : Optional [int ] = 3 ,
81
81
maxP : Optional [float ] = None ,
82
82
parameters : Optional [Dict [str , Any ]] = None ,
83
- ) -> Dict [str , Any ]:
83
+ verbose : Optional [bool ] = True ,
84
+ ) -> GeneralGraph :
84
85
"""
85
86
Perform a greedy relaxation of the sparsest permutation (GRaSP) algorithm
86
87
@@ -96,6 +97,7 @@ def grasp(
96
97
parameters['lambda']: regularization parameter
97
98
parameters['dlabel']: for variables with multi-dimensions,
98
99
indicate which dimensions belong to the i-th variable.
100
+ verbose : whether to print the time cost and verbose output of the algorithm.
99
101
100
102
Returns
101
103
-------
@@ -206,13 +208,15 @@ def grasp(
206
208
order .bump_edges (len (y_parents ))
207
209
208
210
while dfs (depth - 1 , set (), [], order , score ):
209
- sys .stdout .write ("\r GRaSP edge count: %i " % order .get_edges ())
210
- sys .stdout .flush ()
211
+ if verbose :
212
+ sys .stdout .write ("\r GRaSP edge count: %i " % order .get_edges ())
213
+ sys .stdout .flush ()
211
214
212
215
runtime = time .perf_counter () - runtime
213
-
214
- sys .stdout .write ("\n GRaSP completed in: %.2fs \n " % runtime )
215
- sys .stdout .flush ()
216
+
217
+ if verbose :
218
+ sys .stdout .write ("\n GRaSP completed in: %.2fs \n " % runtime )
219
+ sys .stdout .flush ()
216
220
217
221
for y in range (p ):
218
222
for x in order .get_parents (y ):
0 commit comments