-
Notifications
You must be signed in to change notification settings - Fork 22
/
study_option.go
101 lines (87 loc) · 2.59 KB
/
study_option.go
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package goptuna
// StudyOption to pass the custom option
type StudyOption func(study *Study) error
// StudyOptionDirection change the direction of optimize
func StudyOptionDirection(direction StudyDirection) StudyOption {
return func(s *Study) error {
s.direction = direction
return nil
}
}
// StudyOptionLogger sets Logger.
func StudyOptionLogger(logger Logger) StudyOption {
return func(s *Study) error {
if logger == nil {
s.logger = &StdLogger{Logger: nil}
} else {
s.logger = logger
}
return nil
}
}
// StudyOptionStorage sets the storage object.
func StudyOptionStorage(storage Storage) StudyOption {
return func(s *Study) error {
s.Storage = storage
return nil
}
}
// StudyOptionSampler sets the sampler object.
func StudyOptionSampler(sampler Sampler) StudyOption {
return func(s *Study) error {
s.Sampler = sampler
return nil
}
}
// StudyOptionRelativeSampler sets the relative sampler object.
func StudyOptionRelativeSampler(sampler RelativeSampler) StudyOption {
return func(s *Study) error {
s.RelativeSampler = sampler
return nil
}
}
// StudyOptionPruner sets the pruner object.
func StudyOptionPruner(pruner Pruner) StudyOption {
return func(s *Study) error {
s.Pruner = pruner
return nil
}
}
// StudyOptionIgnoreError is an option to continue even if
// it receive error while running Optimize method.
func StudyOptionIgnoreError(ignore bool) StudyOption {
return func(s *Study) error {
s.ignoreErr = ignore
return nil
}
}
// StudyOptionTrialNotifyChannel to subscribe the finished trials.
func StudyOptionTrialNotifyChannel(notify chan FrozenTrial) StudyOption {
return func(s *Study) error {
s.trialNotification = notify
return nil
}
}
// StudyOptionLoadIfExists to load the study if exists.
func StudyOptionLoadIfExists(loadIfExists bool) StudyOption {
return func(s *Study) error {
s.loadIfExists = loadIfExists
return nil
}
}
// StudyOptionDefineSearchSpace to use RelativeSampler from the first trial.
// This option is useful for Define-and-Run interface.
func StudyOptionDefineSearchSpace(space map[string]interface{}) StudyOption {
return func(s *Study) error {
s.definedSearchSpace = space
return nil
}
}
// StudyOptionSetLogger sets Logger.
// Deprecated: please use StudyOptionLogger instead.
var StudyOptionSetLogger = StudyOptionLogger
// StudyOptionSetDirection change the direction of optimize
// Deprecated: please use StudyOptionDirection instead.
var StudyOptionSetDirection = StudyOptionDirection
// StudyOptionSetTrialNotifyChannel to subscribe the finished trials.
var StudyOptionSetTrialNotifyChannel = StudyOptionTrialNotifyChannel