SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
flsa.h
Go to the documentation of this file.
1 /* This program is free software: you can redistribute it and/or modify
2  * it under the terms of the GNU General Public License as published by
3  * the Free Software Foundation, either version 3 of the License, or
4  * (at your option) any later version.
5  *
6  * This program is distributed in the hope that it will be useful,
7  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  * GNU General Public License for more details.
10  *
11  * You should have received a copy of the GNU General Public License
12  * along with this program. If not, see <http://www.gnu.org/licenses/>.
13  *
14  * Copyright (C) 2009 - 2012 Jun Liu and Jieping Ye
15  */
16 
17 #ifndef FLSA_SLEP
18 #define FLSA_SLEP
19 
20 #include <shogun/lib/config.h>
21 
22 /*
23 
24  In this file, we solve the Fused Lasso Signal Approximator (FLSA) problem:
25 
26  min_x 1/2 \|x-v\|^2 + lambda1 * \|x\|_1 + lambda2 * \|A x\|_1, (1)
27 
28  It can be shown that, if x* is the solution to
29 
30  min_x 1/2 \|x-v\|^2 + lambda2 \|A x\|_1, (2)
31 
32  then
33  x**= sgn(x*) max(|x*|-lambda_1, 0) (3)
34 
35  is the solution to (1).
36 
37  By some derivation (see the description in sfa.h), (2) can be solved by
38 
39  x*= v - A^T z*,
40 
41  where z* is the optimal solution to
42 
43  min_z 1/2 z^T A AT z - < z, A v>,
44  subject to \|z\|_{infty} \leq lambda2 (4)
45  */
46 
47 
48 
49 /*
50 
51  In flsa, we solve (1) corresponding to a given (lambda1, lambda2)
52 
53  void flsa(double *x, double *z, double *gap,
54  double * v, double *z0,
55  double lambda1, double lambda2, int n,
56  int maxStep, double tol, int flag)
57 
58  Output parameters:
59 x: the solution to problem (1)
60 z: the solution to problem (4)
61 infor: the information about running the subgradient finding algorithm
62 infor[0] = gap: the computed gap (either the duality gap
63 or the summation of the absolute change of the adjacent solutions)
64 infor[1] = steps: the number of iterations
65 infor[2] = lambad2_max: the maximal value of lambda2_max
66 infor[3] = numS: the number of elements in the support set
67 
68 Input parameters:
69 v: the input vector to be projected
70 z0: a guess of the solution of z
71 
72 lambad1: the regularization parameter
73 labmda2: the regularization parameter
74 n: the length of v and x
75 
76 maxStep: the maximal allowed iteration steps
77 tol: the tolerance parameter
78 tau: the program sfa is checked every tau iterations for termination
79 flag: the flag for initialization and deciding calling sfa
80 switch ( flag )
81 1-4, 11-14: sfa
82 
83 switch ( flag )
84 case 1, 2, 3, or 4:
85 z0 is a "good" starting point
86 (such as the warm-start of the previous solution,
87 or the user want to test the performance of this starting point;
88 the starting point shall be further projected to the L_{infty} ball,
89 to make sure that it is feasible)
90 
91 case 11, 12, 13, or 14: z0 is a "random" guess, and thus not used
92 (we shall initialize z as follows:
93 if lambda2 >= 0.5 * lambda_2^max, we initialize the solution of the linear system;
94 if lambda2 < 0.5 * lambda_2^max, we initialize with zero
95 this solution is projected to the L_{infty} ball)
96 
97 switch( flag )
98 5, 15: sfa_special
99 
100 switch( flag )
101 5: z0 is a good starting point
102 15: z0 is a bad starting point, use the solution of the linear system
103 
104 
105 switch( flag )
106 6, 16: sfa_one
107 
108 switch( flag )
109 6: z0 is a good starting point
110 16: z0 is a bad starting point, use the solution of the linear system
111 
112 Revision made on October 31, 2009.
113 The input variable z0 is not modified after calling sfa. For this sake, we allocate a new variable zz to replace z0.
114 */
115 void flsa(double *x, double *z, double *infor,
116  double * v, double *z0,
117  double lambda1, double lambda2, int n,
118  int maxStep, double tol, int tau, int flag);
119 #endif /* ----- #ifndef FLSA_SLEP ----- */

SHOGUN Machine Learning Toolbox - Documentation