1
2
3
4
5 """
6 A simple line search, in fact no searches at all
7 """
8
10 """
11 A simple line search, takes a point, adds a step and returns it
12 """
13 - def __init__(self, alpha_step = 1., **kwargs):
14 """
15 Needs to have :
16 - nothing
17 Can have :
18 - a step modifier, a factor to modulate the step (alpha_step = 1.)
19 """
20 self.stepSize = alpha_step
21
22 - def __call__(self, origin, state, **kwargs):
23 """
24 Returns a good candidate
25 Parameters :
26 - origin is the origin of the search
27 - state is the state of the optimizer
28 """
29 direction = state['direction']
30 if 'initial_alpha_step' in state:
31 state['alpha_step'] = state['initial_alpha_step']
32 else:
33 state['alpha_step'] = self.stepSize
34 return origin + state['alpha_step'] * direction
35