Comments (2)
Analyse
Lors de la création du terme de la contrainte couplante, le front-end utilise le endpoint POST /v1/studies/{study_id}/bindingconstraints/{area_id}/term
avec le body :
{"data":{"area":"area2","cluster":"Base"},"weight":7}
Dans la configuration de l'étude, au niveau du fichier /input/thermal/clusters/area2/list.ini
, on a :
[Base]
group = Nuclear
name = Base
co2 = 0.0
➡ L’ identifiant du cluster correspond bien au nom de la section, c'est-à-dire "Base", avec une majuscule.
Le fonction qui implémente ce endpoint est la fonction add_constraint_term
située dans antarest/study/web/study_data_blueprint.py
.
Cette fonction utilise la méthode BindingConstraintManager.get_constraint_id
pour générer un identifiant de contrainte à partir de l'identifiant de Zone et de l'identifiant du cluster. Dans le cadre de la gestion des contrainte couplantes, l'identifiant doit être en minuscules. Or, cette fonction utilise l'identifiant de cluster sans conversion.
Solution
La solution consiste à corriger la fonction get_constraint_id
afin qu'elle calcule des identifiants de contraintes couplantes en minuscules.
D'autre part, la fonction de lecture des contraintes couplantes BindingConstraintManager.get_binding_constraint
doit aussi être corrigée car, actuellement, elle retourne une liste d'objets BindingConstraintDTO
comportant des IDs de cluster thermiques en minuscules. En conséquence, le front-end n'est pas en mesure de les afficher correctement ni de contrôler les doublons lors de la création de nouveaux termes.
Guide de développement
Le calcul des IDs de contrainte couplantes peut être implémenté comme suit, ce qui est beaucoup plus simple que l'actuel fonction statique get_constraint_id
:
class LinkInfoDTO(BaseModel):
area1: str
area2: str
@property
def constraint_id(self) -> str:
area1 = min(self.area1, self.area2)
area2 = max(self.area1, self.area2)
return f"{area1}%{area2}"
class ClusterInfoDTO(BaseModel):
area: str
cluster: str
@property
def constraint_id(self) -> str:
return f"{self.area}%{self.cluster.lower()}"
La fonction get_binding_constraint
doit récupérer les IDs réels des clusters thermiques afin d'avoir un moyen de retrouver les IDs réels connaissant les IDs en minuscules. Cela peut être réalisé à l'aide du dictionnaire suivant :
# Create an index of thermal clusters for each area.
# This index is used to find the real cluster ID base on its ID in lower case.
thermals_index = {
area_id: {cl.id.lower(): cl.id for cl in area_obj.thermals}
for area_id, area_obj in file_study.config.areas.items()
}
Une méthode de classe dans le classe BindingConstraintDTO
doit permettre de créer les objets plus simplement à partir des données lues depuis le fichier INI et de ce dictionnaire thermals_index
. On pourrait utiliser des regex pour faire le parsing des clefs et des valeurs.
➡ Un refactoring est nécessaire pour avoir un code plus simple et plus "pyrthonnique".
from antarest.
Contournement possible : nommer les zones de sorte que name == id
, donc minuscules, pas d'espaces, caractères spéciaux. Pas testé
from antarest.
Related Issues (20)
- Extend Map Layers Functionality to Study Areas Side Menu HOT 2
- Impossible to unarchive a study HOT 2
- Add verification for fields in thermals, renewables and storages HOT 1
- Storages: use percentage value for `initialLevel` and `efficiency` fields
- Add a dialog to define a name when duplicate a cluster or a storage
- Use `min` and `max` from "/v1/launcher/nbcores" in LauncherDialog HOT 1
- [ANT-667] Binding constraint matrices length is wrong and makes the solver crash HOT 2
- [ANT-947] Forbid duplicate in binding constraint names HOT 1
- Some test are random on Ubuntu / Windows
- Modification of the relaxed optimality gap does not yield the correct change in the settings.ini file HOT 1
- Cannot set decimal values for some properties HOT 2
- Invalid value for thermal param "gen-ts"
- Missing columns in results view HOT 3
- [AntaresWeb] Study notes are not always saved in variants HOT 3
- [AntaresWeb] Output disappeared HOT 1
- Selecting "Xpress (>= 8.3)" conflict with "Sensibilité" for Xpansion launch HOT 4
- Use Antares-Study-Version for study upgrade
- Revamping Matrices: Data Format Changes and Integration of Apache Arrow IPC Binary Format HOT 1
- Cannot delete 2 areas in a row HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from antarest.