File: 01-parameter.t

package info (click to toggle)
libalgorithm-lbfgs-perl 0.16-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 580 kB
  • sloc: perl: 2,765; makefile: 2
file content (76 lines) | stat: -rw-r--r-- 1,056 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
use strict;
use warnings;

use Test::More tests => 6;
use Test::Number::Delta within => 1e-5;

my $__;
sub NAME { $__ = shift };

###
NAME 'Load the module';
use_ok 'Algorithm::LBFGS',
$__;

###
NAME 'Create a L-BFGS optimizer';
my $o = Algorithm::LBFGS->new;
ok $o,
$__;

###
NAME 'Default parameters - 1';
delta_ok
[
    $o->get_param('epsilon'),
    $o->get_param('min_step'),
    $o->get_param('max_step'),
    $o->get_param('ftol'),
    $o->get_param('gtol'),
    $o->get_param('orthantwise_c')
],
[
    1e-5,
    1e-20,
    1e+20,
    1e-4,
    0.9,
    0.0
],
$__;

###
NAME 'Default parameters - 2';
is_deeply
[
    $o->get_param('m'),
    $o->get_param('max_iterations'),
    $o->get_param('max_linesearch')
],
[
    6,
    0,
    40
],
$__;

###
NAME 'Create a L-BFGS optimizer by customized parameters';
$o = Algorithm::LBFGS->new(gtol => 1.0, epsilon => 1e-6);
delta_ok
[
    $o->get_param('gtol'),
    $o->get_param('epsilon')
],
[
    1.0,
    1e-6
],
$__;

###
NAME 'Modify parameter';
$o->set_param(m => 4);
is $o->get_param('m'), 4,
$__;