Skip to content

Commit

Permalink
Merge pull request #32 from SciNim/exportLinesearch
Browse files Browse the repository at this point in the history
export linesearch and test it
  • Loading branch information
HugoGranstrom authored Nov 21, 2022
2 parents 856c10a + 8883cbd commit aaa7bb6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/numericalnim/optimize.nim
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ proc secant*(f: proc(x: float64): float64, start: array[2, float64], precision:
## Multidimensional methods ##
##############################

type LineSearchCriterion = enum
type LineSearchCriterion* = enum
Armijo, Wolfe, WolfeStrong, NoLineSearch

type
Expand Down
7 changes: 7 additions & 0 deletions tests/test_optimize.nim
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ suite "Multi-dim":
for x in abs(correct - xSol):
check x < 7e-10

test "Line Search options":
for ls in LineSearchCriterion:
let op = lbfgsOptions[float](lineSearchCriterion=ls)
let xSol = lbfgs(bananaFunc, x0.clone, options=op, analyticGradient=bananaBend)
for x in abs(correct - xSol):
check x < 7e-8

let correctParams = [10.4, -0.45].toTensor()
proc fitFunc(params: Tensor[float], x: float): float =
params[0] * exp(params[1] * x)
Expand Down

0 comments on commit aaa7bb6

Please sign in to comment.