Skip to content
This repository was archived by the owner on Nov 23, 2018. It is now read-only.

Commit 6f5e867

Browse files
committed
functions: add YanaiOzawaKaneko function
1 parent 0e67fdc commit 6f5e867

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

functions/functions.go

+43
Original file line numberDiff line numberDiff line change
@@ -1733,3 +1733,46 @@ func (f Plassmann) Grad(grad, x []float64) {
17331733
grad[0] += 1
17341734
}
17351735
}
1736+
1737+
// YanaiOzawaKaneko is an univariate convex function where the values of Beta1
1738+
// and Beta2 control the curvature around the minimum. Far away from the
1739+
// minimum the function approximates an absolute value function. Near the
1740+
// minimum, the function can either be sharply curved or flat, controlled by
1741+
// the parameter values.
1742+
//
1743+
// References:
1744+
// - More, J.J., and Thuente, D.J.: Line Search Algorithms with Guaranteed Sufficient Decrease.
1745+
// ACM Transactions on Mathematical Software 20(3) (1994), 286–307, eq. (5.4)
1746+
// - Yanai, H., Ozawa, M., and Kaneko, S.: Interpolation methods in one dimensional
1747+
// optimization. Computing 27 (1981), 155–163
1748+
type YanaiOzawaKaneko struct {
1749+
Beta1 float64
1750+
Beta2 float64
1751+
}
1752+
1753+
func (f YanaiOzawaKaneko) Func(x []float64) float64 {
1754+
if len(x) != 1 {
1755+
panic("dimension of the problem must be 1")
1756+
}
1757+
a := x[0]
1758+
b1 := f.Beta1
1759+
b2 := f.Beta2
1760+
g1 := math.Sqrt(1+b1*b1) - b1
1761+
g2 := math.Sqrt(1+b2*b2) - b2
1762+
return g1*math.Sqrt((a-1)*(a-1)+b2*b2) + g2*math.Sqrt(a*a+b1*b1)
1763+
}
1764+
1765+
func (f YanaiOzawaKaneko) Grad(grad, x []float64) {
1766+
if len(x) != 1 {
1767+
panic("dimension of the problem must be 1")
1768+
}
1769+
if len(x) != len(grad) {
1770+
panic("incorrect size of the gradient")
1771+
}
1772+
a := x[0]
1773+
b1 := f.Beta1
1774+
b2 := f.Beta2
1775+
g1 := math.Sqrt(1+b1*b1) - b1
1776+
g2 := math.Sqrt(1+b2*b2) - b2
1777+
grad[0] = g1*(a-1)/math.Sqrt(b2*b2+(a-1)*(a-1)) + g2*a/math.Sqrt(b1*b1+a*a)
1778+
}

0 commit comments

Comments
 (0)