@@ -26,8 +26,6 @@ sigma=NULL, alpha=0.1,
26
26
27
27
else {
28
28
29
-
30
-
31
29
checkargs.xy(x ,y )
32
30
if (missing(beta ) || is.null(beta )) stop(" Must supply the solution beta" )
33
31
if (missing(lambda ) || is.null(lambda )) stop(" Must supply the tuning parameter value lambda" )
@@ -338,7 +336,8 @@ InverseLinfty <- function(sigma, n, e, resol=1.2, mu=NULL, maxiter=50, threshold
338
336
return (M )
339
337
}
340
338
341
- InverseLinftyOneRow <- function (Sigma , i , mu , maxiter = 50 , soln_result = NULL , kkt_tol = 1.e-6 , objective_tol = 1.e-6 ) {
339
+ InverseLinftyOneRow <- function (Sigma , i , mu , maxiter = 50 , soln_result = NULL , kkt_tol = 1.e-6 , objective_tol = 1.e-6 ,
340
+ use_QP = TRUE ) {
342
341
343
342
# If soln_result is not Null, it is used as a warm start.
344
343
# It should be a list
@@ -352,31 +351,30 @@ InverseLinftyOneRow <- function (Sigma, i, mu, maxiter=50, soln_result=NULL, kkt
352
351
ever_active [1 ] = i - 1 # 0-based
353
352
ever_active = as.integer(ever_active )
354
353
nactive = as.integer(1 )
355
- linear_func = rep(0 , p )
356
- linear_func [i ] = - 1
357
- linear_func = as.numeric(linear_func )
358
- gradient = 1 . * linear_func
354
+ if (use_QP ) {
355
+ linear_func = rep(0 , p )
356
+ linear_func [i ] = - 1
357
+ linear_func = as.numeric(linear_func )
358
+ gradient = 1 . * linear_func
359
+ } else {
360
+ gradient = rep(0 , p )
361
+ }
359
362
}
360
363
else {
361
364
soln = soln_result $ soln
362
365
gradient = soln_result $ gradient
363
366
ever_active = as.integer(soln_result $ ever_active )
364
367
nactive = as.integer(soln_result $ nactive )
365
- linear_func = soln_result $ linear_func
368
+ if (use_QP ) {
369
+ linear_func = soln_result $ linear_func
370
+ }
366
371
}
367
372
368
- soln1 = rep(0 , p )
369
- gradient1 = rep(0 , p )
370
- ever_active1 = rep(0 , p )
371
- ever_active1 [1 ] = i - 1
372
- nactive1 = as.integer(1 )
373
- result1 = find_one_row_debiasingM(Sigma , i - 1 , mu , maxiter , soln1 , gradient1 , ever_active1 , nactive1 , kkt_tol , objective_tol ) # C function uses 0-based indexing
374
- result = solve_QP(Sigma , mu , maxiter , soln , linear_func , gradient , ever_active , nactive , kkt_tol , objective_tol )
375
- print(" close?" )
376
- print(c(sqrt(sum((result1 $ soln - result $ soln )^ 2 )/ sum(result $ soln ^ 2 )), sum(result $ soln ^ 2 )))
377
- print(c(result1 $ iter , result $ iter , sum(result1 $ soln ^ 2 )))
378
-
379
- # result = find_one_row_debiasingM(Sigma, i-1, mu, maxiter, soln, gradient, ever_active, nactive, kkt_tol, objective_tol) # C function uses 0-based indexing
373
+ if (use_QP ) {
374
+ result = solve_QP(Sigma , mu , maxiter , soln , linear_func , gradient , ever_active , nactive , kkt_tol , objective_tol )
375
+ } else {
376
+ result = find_one_row_debiasingM(Sigma , i - 1 , mu , maxiter , soln , gradient , ever_active , nactive , kkt_tol , objective_tol ) # C function uses 0-based indexing
377
+ }
380
378
381
379
# Check feasibility
382
380
0 commit comments