Skip to content

Commit

Permalink
add bounds constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow committed Mar 24, 2024
1 parent dc484de commit 209a70b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions matsim/calibration/constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 209a70b

Please sign in to comment.