1
2
3
4
5 """
6 Proposes a way to create a composite criterion
7 """
8
9 __all__ = ['criterion']
10
11 from criteria import IterationCriterion, RelativeValueCriterion, RelativeParametersCriterion, GradientCriterion
12 from composite_criteria import OrComposition
13
15 """
16 Creates a composite criterion based on the formal parameters :
17 - iterations_max indicates the maximum number of iteration
18 - ftol is the maximum relative change of the value function
19 - xtol is the maximum relative change of the parameters
20 - gtol is the maximum gradient
21 """
22 l = []
23 if 'iterations_max' in kwargs:
24 l.append(IterationCriterion(kwargs['iterations_max']))
25 if 'ftol' in kwargs:
26 l.append(RelativeValueCriterion(kwargs['ftol']))
27 if 'xtol' in kwargs:
28 l.append(RelativeParametersCriterion(kwargs['xtol']))
29 if 'gtol' in kwargs:
30 l.append(GradientCriterion(kwargs['gtol']))
31
32 return OrComposition(*l)
33