Feature/robust checks#229
Merged
Merged
Conversation
007e76d to
f365c07
Compare
* update links to GEMS repo * transparent pictures * fix png image link * scheme -> schema
91d6ad6 to
85626cd
Compare
f365c07 to
56488ee
Compare
20 tasks
Juliette-Gerbaux
approved these changes
Jun 11, 2026
aoustry
reviewed
Jun 11, 2026
adaebe2 to
05d6819
Compare
aoustry
approved these changes
Jun 11, 2026
tbittar
added a commit
that referenced
this pull request
Jun 11, 2026
* feat/ add operators abs & round (#217) * Add abs and round unary operators (#216) Two new unary operators that mirror the floor/ceil pattern: - abs(x): absolute value - round(x): banker's rounding (round-half-to-even), matching np.round and Python 3's built-in round. Like floor/ceil, both operators have degree 0 when their argument has degree 0, so they are usable inside constraints, binding-constraints, objective contributions, and variable lower/upper bounds whenever the argument is constant (parameters and literals). Inside extra-outputs they may wrap any expression — including ones depending on decision variables — since extra-outputs are evaluated as numeric xr.DataArrays post-solve. * feat(readme): modernize the design of the readme file (#223) * Restyle README with modern layout * Add GEMS favicon next to 'The GEMS framework' heading * Remove top logo image from README header * Replace 'no-code' with 'low-code' in README * Use GEMS favicon in quick-link nav * Vendor GEMS favicon under docs/images and reference it locally * Add uv install instructions to README * Prepare develop/ for release v0.1.2 (#225) * Prepare release v0.1.2 Bump version from 0.1.1 to 0.1.2 in pyproject.toml and uv.lock, and finalize the CHANGELOG with the abs/round operators and the README modernization that landed since 0.1.1. https://claude.ai/code/session_01AfUVdznMY9SayUVt5f3K4T * Update v0.1.2 release date to 2026-06-11 https://claude.ai/code/session_01AfUVdznMY9SayUVt5f3K4T --------- Co-authored-by: Claude <[email protected]> * Fix imports in doc (#227) * Update agents.md (#228) * Handle dual and reduced cost (#221) * Initial commit * delete unnecessary issue templae * exclude compatibility file * remove compatibility file from issue templates * delete changelog file * fix step 9 in issue templates * add notify workflow * add token for antares legacy converter * add issue creation for GemsViewsBuilder repo * fix/Update links to GEMS repo (#219) * update links to GEMS repo * transparent pictures * fix png image link * scheme -> schema * remove duplicate ci (#222) * Add tests * WIP * Use visitor pattern * Use visitor pattern * Support xpress, gurobi * Fix solver specific test and mypy * Formatting * Pre-commit consistency * Reorganize tests * Update docs * Update xhangelog * Formatting * Complete new visitor implementation following rebase * Fix usage in ports * Update tests * Apply suggestion from @aoustry * update docstring --------- Co-authored-by: nikolaredstork <[email protected]> Co-authored-by: Guillaume_RTEi <[email protected]> Co-authored-by: Antoine Oustry, PhD <[email protected]> * feat(library <-> taxonomy check) (#214) * feat(properties): add properties field to support system parsing * fix(tests): remove unnecessary blank line in test_systemschema_from_file.py * refactor: remove unused import PortsConnection from resolve_components.py * feat(schema): add optional taxonomy_category field to ModelSchema and implement corresponding unit test for YAML parsing * Apply suggestion from @dusanparipovic * Update gemspy version to 0.1.0 and clean up whitespace in ModelSchema taxonomy_category field * feat(changelog): add new features for component properties and taxonomy category - Introduced optional `properties` for components in `system.yml`, allowing key/value pairs that are normalized into a dictionary. - Added optional `taxonomy-category` field for models in library YAML files, accessible via `ModelSchema.taxonomy_category`. - Updated documentation to reflect these changes and provided examples in the user guide. * fix(docs): clarify properties key naming in documentation and tests - Updated documentation to replace "key" with "id" in the context of component properties in `system.yml`. - Adjusted test assertions to reflect the change from "key" to "id" for consistency with the updated documentation. - Ensured that error messages for duplicate properties also refer to "id" instead of "key". * feat(study): introduce Study class to encapsulate System and DataBase - Added a new `Study` dataclass that combines `System` and `DataBase`, centralizing consistency checks. - Updated `build_problem()` and `build_decomposed_problems()` to accept `Study` directly. - Refactored related functions and tests to utilize the new `Study` structure, ensuring seamless integration. - Removed redundant parameters and streamlined the API for better clarity and usability. * feat(changelog): add changelog * fix(ruff): fix ruff format on new files * Apply suggestion from @tbittar Co-authored-by: tbittar <[email protected]> * Apply suggestion from @tbittar Co-authored-by: tbittar <[email protected]> * Apply suggestion from @tbittar Co-authored-by: tbittar <[email protected]> * Apply suggestion from @aoustry * Apply suggestion from @aoustry * Update CHANGELOG.md * Update input documentation on duplicate id handling Clarified that duplicate ids for properties are rejected. * fix(taxonomy): import ConstraintSchema and PortFieldDefinitionSchema (#230) Fixes mypy [name-defined] errors on TaxonomyCategory fields. Co-authored-by: Claude <[email protected]> * Address pending review comments: taxonomy field-group validation + model-declared properties (#231) * feat(taxonomy/models): validate all taxonomy field groups and model-declared properties Address pending review comments on PR #214: - check_library_against_taxonomy now validates every field group declared in a taxonomy category (variables, parameters, ports, port-field-definitions, constraints, binding-constraints, extra-outputs, properties) instead of ports only. - Add an optional `properties` list to ModelSchema and Model (declared keys). When resolving a component, every property key declared by its model must be present in the component's properties; extra undeclared properties are allowed. - Add per-field-group taxonomy tests and component model-property tests. - Remove redundant tests in test_systemschema_from_file.py (covered by test_components_parsing.py). * docs(changelog): fold property/taxonomy notes into 0.1.2 Integrate the model-properties and taxonomy field-group changes into the upcoming 0.1.2 section instead of a separate Unreleased block, merging with the existing close entries to avoid redundancy. * test: move model-property library tests to lib_parsing (#232) The tests asserting that a library exposes model-declared properties (parse + resolve) only exercise library parsing/resolution and do not involve system/component resolution, so they belong in the lib_parsing test file rather than test_components_parsing.py. --------- Co-authored-by: Antoine Oustry, PhD <[email protected]> Co-authored-by: tbittar <[email protected]> * Feature/robust checks (#229) --------- Co-authored-by: Claude <[email protected]> Co-authored-by: Juliette-Gerbaux <[email protected]> Co-authored-by: tbittar <[email protected]> Co-authored-by: nikolaredstork <[email protected]> Co-authored-by: Guillaume_RTEi <[email protected]> Co-authored-by: Dušan <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This PR strengthens correctness guarantees of the library-resolution and simulation pipeline in three areas: the linearity check in constraints and objectives is generalized from dual/reduced_cost detection to a proper non-linearity test; two new semantic rules on port-field expressions are enforced at library-resolve time; and the system-level `sum_connections` robustness check is made more general.
Behavior changes
1. Constraint / objective linearity check — `_forbid_dual_or_rc` → `_forbid_nonlinear`
The previous guard (`contains_dual_or_reduced_cost`) only caught `dual()` and `reduced_cost()`. It is replaced by `is_linear()`, which correctly rejects all non-linear expressions.
The same generalisation is applied in `optimization.py`: port-field definitions that are non-linear (not just dual/rc) are now correctly skipped during the LP build phase and deferred to the extra-output post-solve evaluator.
2. New rule: bare `port.field` is not allowed outside `sum_connections`
A bare `PortFieldNode` (e.g. `balance_port.flow`) in any binding constraint, plain constraint, extra-output, or objective contribution now raises a `ValueError` at `resolve_library()` time. `sum_connections(...)` is not recursed into, so the `PortFieldNode` inside remains valid.
3. New rule: `sum_connections` cannot refer to a port field defined in the current model
If a model's `port-field-definitions` already provides a definition for `port.field`, any expression that contains `sum_connections(port.field)` — in a binding constraint, plain constraint, extra-output, or objective — now raises a `ValueError` at `resolve_library()` time.
4. System-level `sum_connections` robustness — `_check_no_dual_rc_sum_connections` → `_check_linear_sum_connections`
The system-level guard that prevents aggregating a non-linear port-field definition via `sum_connections` previously only detected `dual()`/`reduced_cost()`. It now uses `is_linear()`, catching all non-linear definitions.
Other changes
Checklist