コード例 #1
0
ファイル: search.go プロジェクト: jgcarvalho/zdd
func nm(params *score.Parameters, l *ligand.Ligand, p *protein.Protein) {
	orig := l.Center()
	method := &optimize.NelderMead{}
	method.SimplexSize = 0.01
	initX := []float64{orig[0] + rand.Float64(), orig[1] + rand.Float64(), orig[2] + rand.Float64(), 0.0, 0.0, 0.0}
	problem := &optimize.Problem{}
	fmt.Println("INICIO", params.Score(p, l))
	fmt.Println("Center: ", orig)
	problem.Func = func(x []float64) float64 {
		l.Move(x[0], x[1], x[2], x[3]-l.Angles[0], x[4]-l.Angles[1], x[5]-l.Angles[2])
		fmt.Println(x)
		sc := params.Score(p, l)
		fmt.Println(sc)
		return sc
	}
	result, err := optimize.Local(*problem, initX, nil, method)
	if err != nil {
		fmt.Println("Erro minimização:", err)
	}
	fmt.Println("###RESULT:", result)
	fmt.Println("Location:", result.Location.X)
	l.Move(result.Location.X[0], result.Location.X[1], result.Location.X[2], result.Location.X[3], result.Location.X[4], result.Location.X[5])
	fmt.Println(params.Score(p, l))
	l.SavePDB("")
}
コード例 #2
0
ファイル: train.go プロジェクト: jgcarvalho/zdd
func trainMain5() {
	method := &optimize.CMAES{}
	// initX := []float64{0.5, 1.5, 3.0, 2.0, 2.0, 3.0, 4.0, 3.5, 2.0, 3.0, 2.0, 4.5, 3.5, 2.5, 3.0, 3.5, 3.5, 3.0, 3.0, 3.5, 4.0, 4.0}
	initX := []float64{0, 3.0, 0.0, 1.0, 3.0, 0.0, 1.0, 3.0, 0.0, 1.0, 3.0, 0.0, 1.0, 3.0, 0.0, 1.0, 3.0, 0.0, 1.0, 3.0, 0.0, 1.0}
	problem := &optimize.Problem{}
	problem.Func = func(x []float64) float64 {
		penal := (x[0] * 1.0) + 3.0
		metalDbest := x[1]
		metalAlpha := x[2]
		metalBeta := x[3]
		repulsiveDbest := x[4]
		repulsiveAlpha := x[5]
		repulsiveBeta := x[6]
		buriedDbest := x[7]
		buriedAlpha := x[8]
		buriedBeta := x[9]
		hbondDbest := x[10]
		hbondAlpha := x[11]
		hbondBeta := x[12]
		haDbest := x[13]
		haAlpha := x[14]
		haBeta := x[15]
		harepDbest := x[16]
		harepAlpha := x[17]
		harepBeta := x[18]
		npolarDbest := x[19]
		npolarAlpha := x[20]
		npolarBeta := x[21]

		for k := range params.Inter {
			tmp := params.Inter[k]
			tmp.Penal = penal
			if tmp.Type == "metal" {
				tmp.Dbest = metalDbest
				tmp.Alpha = metalAlpha
				tmp.Beta = metalBeta
			} else if tmp.Type == "repulsive" {
				tmp.Dbest = repulsiveDbest
				tmp.Alpha = repulsiveAlpha
				tmp.Beta = repulsiveBeta
			} else if tmp.Type == "buried" {
				tmp.Dbest = buriedDbest
				tmp.Alpha = buriedAlpha
				tmp.Beta = buriedBeta
			} else if tmp.Type == "hbond" {
				tmp.Dbest = hbondDbest
				tmp.Alpha = hbondAlpha
				tmp.Beta = hbondBeta
			} else if tmp.Type == "ha" {
				tmp.Dbest = haDbest
				tmp.Alpha = haAlpha
				tmp.Beta = haBeta
			} else if tmp.Type == "ha-repulsive" {
				tmp.Dbest = harepDbest
				tmp.Alpha = harepAlpha
				tmp.Beta = harepBeta
			} else if tmp.Type == "npolar" {
				tmp.Dbest = npolarDbest
				tmp.Alpha = npolarAlpha
				tmp.Beta = npolarBeta
			} else {
				fmt.Println("Que tipo é esse?", tmp.Type)
			}
			params.Inter[k] = tmp
		}
		fmt.Println(x)
		return cost3(params, trainset)
	}

	result, err := optimize.Local(*problem, initX, nil, method)
	if err != nil {
		fmt.Println("Erro minimização:", err)
	}
	fmt.Println("###RESULT:", result)
}
コード例 #3
0
ファイル: train.go プロジェクト: jgcarvalho/zdd
func trainMain4() {
	method := &optimize.CMAES{}
	// initX := []float64{0.5, 1.5, 3.0, 2.0, 2.0, 3.0, 4.0, 3.5, 2.0, 3.0, 2.0, 4.5, 3.5, 2.5, 3.0, 3.5, 3.5, 3.0, 3.0, 3.5, 4.0, 4.0}
	initX := []float64{0.44439817749423544, 1.861654501650633, 3.111182936447595, 1.662812245597922, 1.859229396738397, 2.596714801210651, 3.6612720109641352, 3.4187361480475005, 1.815317344258246, 3.1602223435925882, 2.0340215689027836, 4.008073061952763, 3.834808533112463, 2.349631328558668, 3.1409644294863917, 3.3930732169666062, 3.3577472259547574, 2.7405711507780564, 2.7396958878034745, 3.802195324120163, 4.555449200453119, 4.335640603745485, 0.0, 0.0, 0.0, 0.0, 0.0}
	problem := &optimize.Problem{}
	problem.Func = func(x []float64) float64 {
		penal := (x[0] * 15000.0) + 30000.0
		metalDbest := x[1] * 1.0
		metalAlpha := x[2] * -4500.0
		metalBeta := x[3] * 0.3
		repulsiveDbest := x[4] * 1.0
		repulsiveAlpha := x[5] * 50.0
		repulsiveBeta := x[6] * 0.3
		buriedDbest := x[7] * 1.0
		buriedAlpha := x[8] * -5.0
		buriedBeta := x[9] * 0.3
		hbondDbest := x[10] * 1.0
		hbondAlpha := x[11] * 0.1
		hbondBeta := x[12] * -1500.0
		haDbest := x[13] * 1.0
		haAlpha := x[14] * -1000.0
		haBeta := x[15] * 0.3
		harepDbest := x[16] * 1.0
		harepAlpha := x[17] * 100.0
		harepBeta := x[18] * 0.3
		npolarDbest := x[19] * 1.0
		npolarAlpha := x[20] * -50.0
		npolarBeta := x[21] * 0.3
		params.Wnp = x[22] * 1000.0
		params.Enp = x[23]
		params.Wp = x[24] * 1000.0
		params.Ep = x[25]
		// params.Wrb = x[26]
		// params.Erb = x[27]
		params.C = x[26] * 1000.0
		for k := range params.Inter {
			tmp := params.Inter[k]
			tmp.Penal = penal
			if tmp.Type == "metal" {
				tmp.Dbest = metalDbest
				tmp.Alpha = metalAlpha
				tmp.Beta = metalBeta
			} else if tmp.Type == "repulsive" {
				tmp.Dbest = repulsiveDbest
				tmp.Alpha = repulsiveAlpha
				tmp.Beta = repulsiveBeta
			} else if tmp.Type == "buried" {
				tmp.Dbest = buriedDbest
				tmp.Alpha = buriedAlpha
				tmp.Beta = buriedBeta
			} else if tmp.Type == "hbond" {
				tmp.Dbest = hbondDbest
				tmp.Alpha = hbondAlpha
				tmp.Beta = hbondBeta
			} else if tmp.Type == "ha" {
				tmp.Dbest = haDbest
				tmp.Alpha = haAlpha
				tmp.Beta = haBeta
			} else if tmp.Type == "ha-repulsive" {
				tmp.Dbest = harepDbest
				tmp.Alpha = harepAlpha
				tmp.Beta = harepBeta
			} else if tmp.Type == "npolar" {
				tmp.Dbest = npolarDbest
				tmp.Alpha = npolarAlpha
				tmp.Beta = npolarBeta
			} else {
				fmt.Println("Que tipo é esse?", tmp.Type)
			}
			params.Inter[k] = tmp
		}
		fmt.Println(x)
		return cost2(params, trainset)
	}
	result, err := optimize.Local(*problem, initX, nil, method)
	if err != nil {
		fmt.Println("Erro minimização:", err)
	}
	fmt.Println("###RESULT:", result)
}
コード例 #4
0
ファイル: train.go プロジェクト: jgcarvalho/zdd
func trainMain2() {
	method := &optimize.NelderMead{}
	method.Shrink = 0.95
	method.Contraction = 0.95
	method.Reflection = 2.0
	method.Expansion = 2.0
	method.SimplexSize = 1.0
	initX := []float64{0.5, 1.5, 3.0, 2.0, 2.0, 3.0, 4.0, 3.5, 2.0, 3.0, 2.0, 4.5, 3.5, 2.5, 3.0, 3.5, 3.5, 3.0, 3.0, 3.5, 4.0, 4.0}
	problem := &optimize.Problem{}
	problem.Func = func(x []float64) float64 {
		penal := (x[0] * 15000.0) + 30000.0
		metalDbest := x[1] * 1.0
		metalAlpha := x[2] * -4500.0
		metalBeta := x[3] * 0.3
		repulsiveDbest := x[4] * 1.0
		repulsiveAlpha := x[5] * 50.0
		repulsiveBeta := x[6] * 0.3
		buriedDbest := x[7] * 1.0
		buriedAlpha := x[8] * -5.0
		buriedBeta := x[9] * 0.3
		hbondDbest := x[10] * 1.0
		hbondAlpha := x[11] * 0.1
		hbondBeta := x[12] * -1500.0
		haDbest := x[13] * 1.0
		haAlpha := x[14] * -1000.0
		haBeta := x[15] * 0.3
		harepDbest := x[16] * 1.0
		harepAlpha := x[17] * 100.0
		harepBeta := x[18] * 0.3
		npolarDbest := x[19] * 1.0
		npolarAlpha := x[20] * -50.0
		npolarBeta := x[21] * 0.3
		for k := range params.Inter {
			tmp := params.Inter[k]
			tmp.Penal = penal
			if tmp.Type == "metal" {
				tmp.Dbest = metalDbest
				tmp.Alpha = metalAlpha
				tmp.Beta = metalBeta
			} else if tmp.Type == "repulsive" {
				tmp.Dbest = repulsiveDbest
				tmp.Alpha = repulsiveAlpha
				tmp.Beta = repulsiveBeta
			} else if tmp.Type == "buried" {
				tmp.Dbest = buriedDbest
				tmp.Alpha = buriedAlpha
				tmp.Beta = buriedBeta
			} else if tmp.Type == "hbond" {
				tmp.Dbest = hbondDbest
				tmp.Alpha = hbondAlpha
				tmp.Beta = hbondBeta
			} else if tmp.Type == "ha" {
				tmp.Dbest = haDbest
				tmp.Alpha = haAlpha
				tmp.Beta = haBeta
			} else if tmp.Type == "ha-repulsive" {
				tmp.Dbest = harepDbest
				tmp.Alpha = harepAlpha
				tmp.Beta = harepBeta
			} else if tmp.Type == "npolar" {
				tmp.Dbest = npolarDbest
				tmp.Alpha = npolarAlpha
				tmp.Beta = npolarBeta
			} else {
				fmt.Println("Que tipo é esse?", tmp.Type)
			}
			params.Inter[k] = tmp
		}
		fmt.Println(x)
		return cost(params, trainset)
	}

	result, err := optimize.Local(*problem, initX, nil, method)
	if err != nil {
		fmt.Println("Erro minimização:", err)
	}
	fmt.Println("###RESULT:", result)
}