Add auto_mask parameter to Model class #555
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Disclaimer
Im not sure how much value this adds, as i didnt use masking that much before. Im happy to discuss the ups and downsides of such a feature. I would have raised an issue, but i thought adding a benchmark and proof of concept would be more valuable.
Summary
Adds
auto_maskparameter toModelthat automatically masks variables and constraints where input data contains NaN values.Benefits
np.whereinstead of xarraywhere= 38x faster)Auto-mask conditions
Variables masked out where:
loweris NaN, ORupperis NaNConstraints masked out where:
rhsis NaNPerformance (30% NaN, includes external mask creation)
Variables
Constraints
Auto-mask is equal or faster than manual masking due to optimized numpy operations.
Checklist