Skip to content

Commit 2c4cf3a

Browse files
not checking objective
1 parent 0de59af commit 2c4cf3a

File tree

1 file changed

+33
-38
lines changed

1 file changed

+33
-38
lines changed

selectiveInference/src/debias.c

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -90,34 +90,32 @@ int update_ever_active(int coord,
9090
return(0);
9191
}
9292

93-
int check_KKT(double *theta, /* current theta */
93+
int check_KKT(double *theta, /* current theta */
9494
double *gradient_ptr, /* Sigma times theta */
95-
int nrow, /* how many rows in Sigma */
96-
double bound) /* Lagrange multipler for \ell_1 */
95+
int nrow, /* how many rows in Sigma */
96+
double bound) /* Lagrange multipler for \ell_1 */
9797
{
9898
// First check inactive
9999

100100
int irow;
101101
int fail = 0;
102-
double tol = 1.e-4;
103-
double *theta_ptr = theta;
104-
double *gradient_ptr_tmp = gradient_ptr;
102+
double tol = 1.e-6;
103+
double *theta_ptr, *gradient_ptr_tmp;
105104
double gradient;
106105

107106
for (irow=0; irow<nrow; irow++) {
108-
109-
gradient = *gradient_ptr_tmp;
107+
theta_ptr = ((double *) theta + irow);
108+
gradient_ptr_tmp = ((double *) gradient_ptr + irow);
110109

111110
// Compute this coordinate of the gradient
112111

113-
if (fabs(*theta_ptr) > tol) { // these coordinates of gradients should be equal to \pm bound
114-
if (fabs(fabs(gradient) - bound) > tol * bound) {
115-
return(0);
116-
}
117-
else if ((*theta_ptr > 0) && (gradient > 0)) {
112+
gradient = *gradient_ptr_tmp;
113+
114+
if (*theta_ptr != 0) { // these coordinates of gradients should be equal to -bound
115+
if ((*theta_ptr > 0) && (fabs(gradient + bound) > tol * bound)) {
118116
return(0);
119117
}
120-
else if ((*theta_ptr < 0) && (gradient < 0)) {
118+
else if ((*theta_ptr < 0) && (fabs(gradient - bound) > tol * bound)) {
121119
return(0);
122120
}
123121
}
@@ -126,12 +124,9 @@ int check_KKT(double *theta, /* current theta */
126124
return(0);
127125
}
128126
}
129-
theta_ptr++;
130-
gradient_ptr_tmp++;
131127
}
132128

133-
return(fail == 0);
134-
129+
return(1);
135130
}
136131

137132
double update_one_coord(double *Sigma_ptr, /* A covariance matrix: X^TX/n */
@@ -232,13 +227,13 @@ int find_one_row_(double *Sigma_ptr, /* A covariance matrix: X^TX/n */
232227
int iactive = 0;
233228
int *active_ptr;
234229

235-
double old_value = objective(Sigma_ptr,
236-
linear_func_ptr,
237-
ever_active_ptr,
238-
nactive_ptr,
239-
nrow,
240-
bound,
241-
theta);
230+
/* double old_value = objective(Sigma_ptr, */
231+
/* linear_func_ptr, */
232+
/* ever_active_ptr, */
233+
/* nactive_ptr, */
234+
/* nrow, */
235+
/* bound, */
236+
/* theta); */
242237
double new_value;
243238
double tol=1.e-8;
244239

@@ -298,19 +293,19 @@ int find_one_row_(double *Sigma_ptr, /* A covariance matrix: X^TX/n */
298293
break;
299294
}
300295

301-
new_value = objective(Sigma_ptr,
302-
linear_func_ptr,
303-
ever_active_ptr,
304-
nactive_ptr,
305-
nrow,
306-
bound,
307-
theta);
308-
309-
if (((old_value - new_value) < tol * fabs(new_value)) && (iter > 0)) {
310-
break;
311-
}
312-
313-
old_value = new_value;
296+
/* new_value = objective(Sigma_ptr, */
297+
/* linear_func_ptr, */
298+
/* ever_active_ptr, */
299+
/* nactive_ptr, */
300+
/* nrow, */
301+
/* bound, */
302+
/* theta); */
303+
304+
/* if (((old_value - new_value) < tol * fabs(new_value)) && (iter > 0)) { */
305+
/* break; */
306+
/* } */
307+
308+
// old_value = new_value;
314309
}
315310
return(iter);
316311
}

0 commit comments

Comments
 (0)