diff --git a/matsim/calibration/constraints.py b/matsim/calibration/constraints.py index 240ef51..0efb04b 100644 --- a/matsim/calibration/constraints.py +++ b/matsim/calibration/constraints.py @@ -19,3 +19,11 @@ def negative(param, val): def zero(param, val): """ A parameter is always 0 """ return 0 + + +def bounds(lower: float = float('-inf'), upper: float = float('inf')) -> F: + """ A parameter is bound by lower and upper value """ + def f(param, val): + return max(lower, min(upper, val)) + + return f