Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow properties to specify monotonicity constraints (e.g. height increasing) #33

Open
mcgibbon opened this issue Jun 15, 2018 · 6 comments

Comments

@mcgibbon
Copy link
Owner

A common property of components is requiring that the vertical dimension has a certain ordering, either starting at the bottom or the top of the domain. We can frame this in a general way by saying the component requires that a certain input (e.g. height or air_pressure) has a certain ordering (e.g. "increasing" or "decreasing") along a certain dimension (e.g. "mid_levels").

I propose this be indicated in the input properties dictionary following this example:

input_properties = {
    'air_pressure': {
        'dims': ['mid_levels', '*'],
        'units': 'Pa',
        'constraints': {'mid_levels': 'decreasing'},
    }
}

I'm open to suggestions on a better word than "constraints". Sympl would check to see that all constraints present for each dimension are either already satisfied (trivially if there aren't any), or would be satisfied if the dimension was flipped (in which case it would do so) or cannot be satisfied (in which case it would error).

@JoyMonteiro
Copy link
Collaborator

I think this would be a good property to add, and could also be used to enforce nonzero for example. constraints sounds ok, but requirements might be clearer.

@mcgibbon
Copy link
Owner Author

mcgibbon commented Jul 9, 2018

I'll push this back to the next version after 0.4.0. I think requirements like nonzero should be accommodated by allowing functions to be provided which take in the quantity as input and return True if it's satisfied and False if not. For example nonnegative would be lambda x: x>=0. We would do the np.all call when necessary within the Sympl code.

@JoyMonteiro
Copy link
Collaborator

JoyMonteiro commented Jul 10, 2018

you mean allow constraints/requirements to accept a dictionary whose values can be functions?

@mcgibbon
Copy link
Owner Author

I mean where there would be the string 'nonnegative' you could instead give a function. I'm not quite sure the best place to put such a requirement.

@JoyMonteiro
Copy link
Collaborator

yes, that's what I meant. sounds good. what do you mean by best place to put such a requirement? you mean the correct place to put the function? I think replacing the string with a function sounds just fine to me.

@mcgibbon
Copy link
Owner Author

I mean I don't know the best way to specify all of this in a property dictionary. I'm thinking about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants