MCPcopy Create free account
hub / github.com/datastream/libsvm / Solve

Method Solve

svm.go:422–677  ·  view source on GitHub ↗
(l int, Q QMatrix, p_ []float64, y_ []int8, alpha_ []float64, Cp, Cn, eps float64, si *SolutionInfo, shrinking int)

Source from the content-addressed store, hash-verified

420}
421
422func (this *Solver) Solve(l int, Q QMatrix, p_ []float64, y_ []int8, alpha_ []float64, Cp, Cn, eps float64, si *SolutionInfo, shrinking int) {
423 this.l = l
424 this.Q = Q
425 this.QD = Q.get_QD()
426 this.p = make([]float64, len(p_))
427 copy(this.p, p_)
428 this.y = make([]int8, len(y_))
429 copy(this.y, y_)
430 this.alpha = make([]float64, len(alpha_))
431 copy(this.alpha, alpha_)
432 this.Cp = Cp
433 this.Cn = Cn
434 this.eps = eps
435 this.unshrink = false
436
437 // initialize alpha_status
438 {
439 this.alpha_status = make([]int8, l)
440 for i := 0; i < l; i++ {
441 this.update_alpha_status(i)
442 }
443 }
444
445 // initialize active set (for shrinking)
446 {
447 this.active_set = make([]int, l)
448 for i := 0; i < l; i++ {
449 this.active_set[i] = i
450 }
451 this.active_size = l
452 }
453
454 // initialize gradient
455 {
456 this.G = make([]float64, l)
457 this.G_bar = make([]float64, l)
458 var i int
459 for i = 0; i < l; i++ {
460 this.G[i] = this.p[i]
461 this.G_bar[i] = 0
462 }
463 for i = 0; i < l; i++ {
464 if !this.is_lower_bound(i) {
465 Q_i := this.Q.get_Q(i, l)
466 alpha_i := this.alpha[i]
467 var j int
468 for j = 0; j < l; j++ {
469 this.G[j] += alpha_i * float64(Q_i[j])
470 }
471 if this.is_upper_bound(i) {
472 for j = 0; j < l; j++ {
473 this.G_bar[j] += this.get_C(i) * float64(Q_i[j])
474 }
475 }
476 }
477 }
478 }
479

Callers 5

Solve_c_svcMethod · 0.45
Solve_nu_svcMethod · 0.45
Solve_one_classMethod · 0.45
Solve_epsilon_svrMethod · 0.45
Solve_nu_svrMethod · 0.45

Calls 10

update_alpha_statusMethod · 0.95
is_lower_boundMethod · 0.95
is_upper_boundMethod · 0.95
get_CMethod · 0.95
do_shrinkingMethod · 0.95
select_working_setMethod · 0.95
reconstruct_gradientMethod · 0.95
calculate_rhoMethod · 0.95
get_QDMethod · 0.65
get_QMethod · 0.65

Tested by

no test coverage detected