Skip to content

Modeler > Port field definition : allow non linear expressions [ANT-4646]#3483

Merged
flomnes merged 24 commits intodevelopfrom
feature/relax-expr-in-port-definition
Mar 24, 2026
Merged

Modeler > Port field definition : allow non linear expressions [ANT-4646]#3483
flomnes merged 24 commits intodevelopfrom
feature/relax-expr-in-port-definition

Conversation

@guilpier-code
Copy link
Copy Markdown
Contributor

@guilpier-code guilpier-code commented Mar 12, 2026

Fixes ticket ANT-4646

Ticket ANT-4646 is addressed (hopefully) : we relaxed the prohibition in expression of models' port-field-definitions (any non-linear operator is allowed), and we made sure that, once components and connections are read, port field resolution in binding constraint section leads to linear expressions only.

While addressing ANT-4646, what was done (more precisely) :

  • code about forbidden node was moved in a independent target forbidden-nodes so that it can easily be accessible from both convert model (model creation) and convert system (components creation and connections). In this context, source files about forbidden nodes were moved to another location.
  • Class ForbiddenNodesVisitor was modified to be able to make port field resolution and check linearity.
  • we need to modify class SystemModel::Constraint in order to be able to distinguish simple constraints and binding constraints
  • determination of port field role (sender or receiver) was moved from system conversion into model conversion (thus, earlier) : we don't have to wait until system conversion in order to find out these roles.
  • Tests :
    • study (full modeler) for cucumber, to check that defining a thermal cluster income works
    • Unit tests to check that prohibition works
  • updating documentation

@@ -87,58 +87,43 @@ static void CommonPreSolve(ForbiddenNodes& f)

static ForbiddenNodes ForbiddenInConstraint()
Copy link
Copy Markdown
Contributor Author

@guilpier-code guilpier-code Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code about defining node prohibition in an expression (depending on use context) was simplified.

  • What remains : static functions are still called once.
  • What we loose : calls to these functions are eager (they are called once exactly, even if not needed). Code used to be lazy (calls were made once, and only if needed).
  • What we gain : code is more readable, more simple, has less lines

…+ change node prohibition for port field definition
@pull-request-size pull-request-size bot added size/L and removed size/M labels Mar 12, 2026
Copy link
Copy Markdown
Member

@flomnes flomnes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic for port field role is unclear

Comment on lines +142 to +147
const ForbiddenNodes forbiddenInConstraint = ForbidNodesInConstraint();
const ForbiddenNodes forbiddenInBindingConstraint = ForbidNodesInBindingConstraint();
const ForbiddenNodes forbiddenInVariableBounds = ForbidNodesInVariableBounds();
const ForbiddenNodes forbiddenInPortFieldDef = ForbidNodesInPortFieldDef();
const ForbiddenNodes forbiddenInObjective = ForbidNodesInObjective();
const ForbiddenNodes forbiddenInExtraOutput = ForbidNodesInExtraOutput();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why this needs to be added

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did that for performance reason : otherwise we would have to call the same function each time we need it.
Here the result of this call is store in a constant.

Comment thread src/io/inputs/model-converter/modelConverter.cpp
@flomnes flomnes changed the title Modeler > Port field definition : allow non linear expressions Modeler > Port field definition : allow non linear expressions [ANT-4646] Mar 17, 2026
guilpierre added 2 commits March 18, 2026 17:27
…lax-expr-in-port-definition

# Conflicts:
#	src/io/inputs/model-converter/modelConverter.cpp
#	src/study/system-model/include/antares/study/system-model/constraint.h
Copy link
Copy Markdown
Member

@flomnes flomnes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of refactoring / renaming, can you split this PR in 2 ?

  1. Refactor / rename
  2. Implement the actual feature

Thank you

@guilpier-code
Copy link
Copy Markdown
Contributor Author

The logic for port field role is unclear

what do you mean by unclear ? unclear in what way ?

@guilpier-code guilpier-code marked this pull request as ready for review March 19, 2026 17:16
Comment thread src/io/inputs/model-converter/modelConverter.cpp Outdated
Comment thread src/io/inputs/forbidden-nodes/ForbiddenNodesVisitor.cpp Outdated
Comment thread src/io/inputs/forbidden-nodes/ForbiddenNodesVisitor.cpp Outdated
guilpierre and others added 2 commits March 24, 2026 11:11
Co-authored-by: guilpier-code <62292552+guilpier-code@users.noreply.github.com>
Co-authored-by: guilpierre <guillaume.pierre_externe@rte-france.com>
Co-authored-by: Jason Maréchal <45510813+JasonMarechal25@users.noreply.github.com>
Co-authored-by: Josh <139483907+YoshuaLisasi@users.noreply.github.com>
@pull-request-size
Copy link
Copy Markdown

This PR is too big. Please break it up into smaller PRs.

@sonarqubecloud
Copy link
Copy Markdown

@flomnes flomnes merged commit 2694c8b into develop Mar 24, 2026
10 checks passed
@flomnes flomnes deleted the feature/relax-expr-in-port-definition branch March 24, 2026 11:53
guilpier-code added a commit that referenced this pull request Apr 2, 2026
…3536)

This PR is about [ticket
ANT-4646](https://gopro-tickets.rte-france.com/browse/ANT-4646).

A first PR ([PR
3483](#3483))
was merged into **develop**.

After tests by @Juliette-Gerbaux, some fixes were recommended : 
- relax port field definitions expressions, so that non linear operators
**min**, **max**, **ceil**, **floor** can accept variable nodes
(**VariableNode**).
- restore prohibition of operator **sum_connections** (node
**PortFieldSumNode**) in port field definitions

---------

Co-authored-by: guilpierre <guillaume.pierre_externe@rte-france.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants