(working_set []int)
| 677 | } |
| 678 | |
| 679 | func (this *Solver) select_working_set(working_set []int) int { |
| 680 | // return i,j such that |
| 681 | // i: maximizes -y_i * grad(f)_i, i in I_up(\alpha) |
| 682 | // j: mimimizes the decrease of obj value |
| 683 | // (if quadratic coefficeint <= 0, replace it with tau) |
| 684 | // -y_j*grad(f)_j < -y_i*grad(f)_i, j in I_low(\alpha) |
| 685 | |
| 686 | Gmax := -INF |
| 687 | Gmax2 := -INF |
| 688 | Gmax_idx := -1 |
| 689 | Gmin_idx := -1 |
| 690 | obj_diff_min := INF |
| 691 | |
| 692 | for t := 0; t < this.active_size; t++ { |
| 693 | if this.y[t] == +1 { |
| 694 | if !this.is_upper_bound(t) { |
| 695 | if -this.G[t] >= Gmax { |
| 696 | Gmax = -this.G[t] |
| 697 | Gmax_idx = t |
| 698 | } |
| 699 | } |
| 700 | } else { |
| 701 | if !this.is_lower_bound(t) { |
| 702 | if this.G[t] >= Gmax { |
| 703 | Gmax = this.G[t] |
| 704 | Gmax_idx = t |
| 705 | } |
| 706 | } |
| 707 | } |
| 708 | } |
| 709 | i := Gmax_idx |
| 710 | var Q_i []float32 |
| 711 | Q_i = nil |
| 712 | |
| 713 | if i != -1 { // null Q_i not accessed: Gmax=-INF if i=-1 |
| 714 | Q_i = this.Q.get_Q(i, this.active_size) |
| 715 | } |
| 716 | |
| 717 | for j := 0; j < this.active_size; j++ { |
| 718 | if this.y[j] == +1 { |
| 719 | if !this.is_lower_bound(j) { |
| 720 | grad_diff := Gmax + this.G[j] |
| 721 | if this.G[j] >= Gmax2 { |
| 722 | Gmax2 = this.G[j] |
| 723 | } |
| 724 | if grad_diff > 0 { |
| 725 | var obj_diff float64 |
| 726 | // y []int8 |
| 727 | tmp := float64(this.y[i]) |
| 728 | tmp2 := float64(2 * Q_i[j]) |
| 729 | quad_coef := this.QD[i] + this.QD[j] - tmp*tmp2 |
| 730 | if quad_coef > 0 { |
| 731 | obj_diff = -(grad_diff * grad_diff) / quad_coef |
| 732 | } else { |
| 733 | obj_diff = -(grad_diff * grad_diff) / 1e-12 |
| 734 | } |
| 735 | |
| 736 | if obj_diff <= obj_diff_min { |
no test coverage detected