1
2
3
4
5 """
6 An hyperbolic line search, in fact no searches at all
7 """
8
10 """
11 An inverse line search, takes a point, adds a step (1/(1+iterations)) 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 alpha = state['initial_alpha_step'] /( 1 + state['iteration'])
32 state['alpha_step'] = alpha
33 else:
34 alpha = self.stepSize /( 1 + state['iteration'])
35 state['alpha_step'] = alpha
36 return origin + alpha * direction
37