()
| 795 | } |
| 796 | |
| 797 | func (this *Solver) do_shrinking() { |
| 798 | var i int |
| 799 | Gmax1 := -INF // max { -y_i * grad(f)_i | i in I_up(\alpha) } |
| 800 | Gmax2 := -INF // max { y_i * grad(f)_i | i in I_low(\alpha) } |
| 801 | // find maximal violating pair first |
| 802 | for i = 0; i < this.active_size; i++ { |
| 803 | if this.y[i] == +1 { |
| 804 | if !this.is_upper_bound(i) { |
| 805 | if -this.G[i] >= Gmax1 { |
| 806 | Gmax1 = -this.G[i] |
| 807 | } |
| 808 | } |
| 809 | if !this.is_lower_bound(i) { |
| 810 | if this.G[i] >= Gmax2 { |
| 811 | Gmax2 = this.G[i] |
| 812 | } |
| 813 | } |
| 814 | } else { |
| 815 | if !this.is_upper_bound(i) { |
| 816 | if -this.G[i] >= Gmax2 { |
| 817 | Gmax2 = -this.G[i] |
| 818 | } |
| 819 | } |
| 820 | if !this.is_lower_bound(i) { |
| 821 | if this.G[i] >= Gmax1 { |
| 822 | Gmax1 = this.G[i] |
| 823 | } |
| 824 | } |
| 825 | } |
| 826 | } |
| 827 | |
| 828 | if this.unshrink == false && Gmax1+Gmax2 <= this.eps*10 { |
| 829 | this.unshrink = true |
| 830 | this.reconstruct_gradient() |
| 831 | this.active_size = this.l |
| 832 | } |
| 833 | |
| 834 | for i = 0; i < this.active_size; i++ { |
| 835 | if this.be_shrunk(i, Gmax1, Gmax2) { |
| 836 | this.active_size-- |
| 837 | for this.active_size > i { |
| 838 | if !this.be_shrunk(this.active_size, Gmax1, Gmax2) { |
| 839 | this.swap_index(i, this.active_size) |
| 840 | break |
| 841 | } |
| 842 | this.active_size-- |
| 843 | } |
| 844 | } |
| 845 | } |
| 846 | } |
| 847 | |
| 848 | func (this *Solver) calculate_rho() float64 { |
| 849 | var r float64 |
no test coverage detected