@@ -43,9 +43,6 @@ public class Linear {
4343 private static final Object OUTPUT_MUTEX = new Object ();
4444 private static PrintStream DEBUG_OUTPUT = System .out ;
4545
46- private static final long DEFAULT_RANDOM_SEED = 0L ;
47- static Random random = new Random (DEFAULT_RANDOM_SEED );
48-
4946 /**
5047 * @param target predicted classes
5148 */
@@ -63,7 +60,7 @@ public static void crossValidation(Problem prob, Parameter param, int nr_fold, d
6360 for (i = 0 ; i < l ; i ++)
6461 perm [i ] = i ;
6562 for (i = 0 ; i < l ; i ++) {
66- int j = i + random .nextInt (l - i );
63+ int j = i + param . random .nextInt (l - i );
6764 swap (perm , i , j );
6865 }
6966 for (i = 0 ; i <= nr_fold ; i ++)
@@ -115,7 +112,7 @@ public static ParameterSearchResult findParameters(Problem prob, Parameter param
115112 for (i = 0 ; i < l ; i ++)
116113 perm [i ] = i ;
117114 for (i = 0 ; i < l ; i ++) {
118- int j = i + random .nextInt (l - i );
115+ int j = i + param . random .nextInt (l - i );
119116 swap (perm , i , j );
120117 }
121118 for (i = 0 ; i <= nr_fold ; i ++)
@@ -694,7 +691,7 @@ private static int solve_l2r_l1l2_svc(Problem prob, Parameter param, double[] w,
694691 PGmin_new = Double .POSITIVE_INFINITY ;
695692
696693 for (i = 0 ; i < active_size ; i ++) {
697- int j = i + random .nextInt (active_size - i );
694+ int j = i + param . random .nextInt (active_size - i );
698695 swap (index , i , j );
699696 }
700697
@@ -867,7 +864,7 @@ private static int solve_l2r_l1l2_svr(Problem prob, Parameter param, double[] w,
867864 Gnorm1_new = 0 ;
868865
869866 for (i = 0 ; i < active_size ; i ++) {
870- int j = i + random .nextInt (active_size - i );
867+ int j = i + param . random .nextInt (active_size - i );
871868 swap (index , i , j );
872869 }
873870
@@ -1043,7 +1040,7 @@ private static int solve_l2r_lr_dual(Problem prob, Parameter param, double[] w,
10431040
10441041 while (iter < max_iter ) {
10451042 for (i = 0 ; i < l ; i ++) {
1046- int j = i + random .nextInt (l - i );
1043+ int j = i + param . random .nextInt (l - i );
10471044 swap (index , i , j );
10481045 }
10491046 int newton_iter = 0 ;
@@ -1206,7 +1203,7 @@ private static int solve_l1r_l2_svc(Problem prob_col, Parameter param, double[]
12061203 Gnorm1_new = 0 ;
12071204
12081205 for (j = 0 ; j < active_size ; j ++) {
1209- int i = j + random .nextInt (active_size - j );
1206+ int i = j + param . random .nextInt (active_size - j );
12101207 swap (index , i , j );
12111208 }
12121209
@@ -1556,7 +1553,7 @@ else if (Gp > Gmax_old / l && Gn < -Gmax_old / l) {
15561553 QP_Gnorm1_new = 0 ;
15571554
15581555 for (j = 0 ; j < QP_active_size ; j ++) {
1559- int i = random .nextInt (QP_active_size - j );
1556+ int i = param . random .nextInt (QP_active_size - j );
15601557 swap (index , i , j );
15611558 }
15621559
@@ -2190,7 +2187,7 @@ public static Model train(Problem prob, Parameter param) {
21902187 }
21912188 }
21922189
2193- SolverMCSVM_CS solver = new SolverMCSVM_CS (sub_prob , nr_class , weighted_C , param .eps );
2190+ SolverMCSVM_CS solver = new SolverMCSVM_CS (sub_prob , nr_class , weighted_C , param .eps , param . random );
21942191 solver .solve (model .w );
21952192 } else {
21962193 if (nr_class == 2 ) {
@@ -2537,9 +2534,8 @@ public static int getVersion() {
25372534 /**
25382535 * resets the PRNG
25392536 *
2540- * this is i.a. needed for regression testing (eg. the Weka wrapper)
2537+ * @deprecated Use {@link Parameter#setRandom(Random)} instead
25412538 */
25422539 public static void resetRandom () {
2543- random = new Random (DEFAULT_RANDOM_SEED );
25442540 }
25452541}
0 commit comments