Antares Simulator
Power System Simulator
optimization.h
1 /*
2  * Copyright 2007-2025, RTE (https://www.rte-france.com)
3  * See AUTHORS.txt
4  * SPDX-License-Identifier: MPL-2.0
5  * This file is part of Antares-Simulator,
6  * Adequacy and Performance assessment for interconnected energy networks.
7  *
8  * Antares_Simulator is free software: you can redistribute it and/or modify
9  * it under the terms of the Mozilla Public Licence 2.0 as published by
10  * the Mozilla Foundation, either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * Antares_Simulator is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * Mozilla Public Licence 2.0 for more details.
17  *
18  * You should have received a copy of the Mozilla Public Licence 2.0
19  * along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
20  */
21 #ifndef __ANTARES_APPLICATION_WINDOWS_OPTIONS_OPTIMIZATION_PREFS_H__
22 #define __ANTARES_APPLICATION_WINDOWS_OPTIONS_OPTIMIZATION_PREFS_H__
23 
24 #include "toolbox/components/button.h"
25 #include <wx/dialog.h>
26 
27 #include <antares/study/UnfeasibleProblemBehavior.hpp>
28 #include "application/menus.h"
29 
30 namespace Antares::Window::Options
31 {
35 class Optimization final: public wxDialog
36 {
37 public:
39 
40 
45  Optimization(wxWindow* parent);
47  virtual ~Optimization();
49 
50 private:
51  class PopupInfo final
52  {
53  public:
54  PopupInfo(bool& r, const wxChar* const t):
55  rval(r),
56  text(t)
57  {
58  }
59 
60  bool& rval;
61  const wxChar* const text;
62  };
63 
64 private:
65  void refresh();
66  void onClose(void*);
67  void onResetToDefault(void*);
68 
69  void onSelectModeInclude(wxCommandEvent& evt);
70  void onSelectModeIgnore(wxCommandEvent& evt);
71  void onSelectSimplexDay(wxCommandEvent& evt);
72  void onSelectSimplexWeek(wxCommandEvent& evt);
73 
74  void setTransmissionCapacity(Data::GlobalTransmissionCapacities newCapacity);
75  template<Data::GlobalTransmissionCapacities>
76  void onSelectTransmissionCapacity(wxCommandEvent&);
77 
78  template<Data::GlobalTransmissionCapacities>
79  void createGlobalTransmissionCapacitiesItemIntoMenu(wxMenu& menu);
80 
81  void onSelectLinkTypeLocal(wxCommandEvent& evt);
82  void onSelectLinkTypeAC(wxCommandEvent& evt);
83 
84  // Export MPS functions
85  void onSelectExportMPS(const Data::mpsExportStatus& mps_export_status);
86 
87  template<Data::mpsExportStatus>
88  void onSelectExportMPS(wxCommandEvent&);
89 
90  template<Data::mpsExportStatus>
91  void createMPSexportItemIntoMenu(wxMenu& menu);
92 
93  // Unfeasible behavior problem functions
94  void onSelectUnfeasibleBehaviorWarningDry(wxCommandEvent& evt);
95  void onSelectUnfeasibleBehaviorWarningMps(wxCommandEvent& evt);
96  void onSelectUnfeasibleBehaviorErrorDry(wxCommandEvent& evt);
97  void onSelectUnfeasibleBehaviorErrorMps(wxCommandEvent& evt);
98  void onSelectUnfeasibleBehavior(
99  const Data::UnfeasibleProblemBehavior& unfeasibleProblemBehavior);
100 
101  void onPopupMenu(Component::Button&, wxMenu& menu, void*, const PopupInfo& info);
102  void onPopupMenuSimplex(Component::Button&, wxMenu& menu, void*);
103  void onPopupMenuSpecify(Component::Button&, wxMenu& menu, void*, const PopupInfo& info);
104  void onPopupMenuTransmissionCapacities(Component::Button&, wxMenu& menu, void*);
105  void onPopupMenuLinkType(Component::Button&, wxMenu& menu, void*);
106  void onPopupMenuExportMPSstatus(Component::Button&, wxMenu& menu, void*);
107  void onPopupMenuUnfeasibleBehavior(Component::Button&, wxMenu& menu, void*);
108 
109  void onInternalMotion(wxMouseEvent&);
110 
111 private:
112  Component::Button* pBtnConstraints;
113  Component::Button* pBtnHurdleCosts;
114  Component::Button* pBtnTransmissionCapacities;
115  Component::Button* pBtnLinkType;
116  Component::Button* pBtnThermalClusterMinStablePower;
117  Component::Button* pBtnThermalClusterMinUPTime;
118  Component::Button* pBtnDayAheadReserve;
119  Component::Button* pBtnStrategicReserve;
120  Component::Button* pBtnPrimaryReserve;
121  Component::Button* pBtnSpinningReserve;
122  Component::Button* pBtnSimplexOptimizationRange;
123 
124  Component::Button* pBtnExportMPS;
125  Component::Button* pBtnUnfeasibleProblemBehavior;
126  bool* pTargetRef;
127 
128 }; // class Optimization
129 
130 const char* mpsExportIcon(const Data::mpsExportStatus& mps_export_status);
131 
132 template<Data::mpsExportStatus MPS_EXPORT_STATUS>
133 void Optimization::onSelectExportMPS(wxCommandEvent&)
134 {
135  Optimization::onSelectExportMPS(MPS_EXPORT_STATUS);
136 }
137 
138 template<Data::mpsExportStatus MPS_EXPORT_STATUS>
139 void Optimization::createMPSexportItemIntoMenu(wxMenu& menu)
140 {
141  const wxMenuItem* it = Menu::CreateItem(&menu,
142  wxID_ANY,
143  mpsExportStatusToString(MPS_EXPORT_STATUS),
144  mpsExportIcon(MPS_EXPORT_STATUS),
145  wxEmptyString);
146 
147  menu.Connect(it->GetId(),
148  wxEVT_COMMAND_MENU_SELECTED,
149  wxCommandEventHandler(Optimization::onSelectExportMPS<MPS_EXPORT_STATUS>),
150  nullptr,
151  this);
152 }
153 
154 const char* transmissionCapacityIcon(Data::GlobalTransmissionCapacities capacity);
155 
156 template<Data::GlobalTransmissionCapacities CAPACITY>
157 void Optimization::createGlobalTransmissionCapacitiesItemIntoMenu(wxMenu& menu)
158 {
159  const wxMenuItem* it = Menu::CreateItem(&menu,
160  wxID_ANY,
161  GlobalTransmissionCapacitiesToString_Display(CAPACITY),
162  transmissionCapacityIcon(CAPACITY),
163  wxEmptyString);
164 
165  menu.Connect(it->GetId(),
166  wxEVT_COMMAND_MENU_SELECTED,
167  wxCommandEventHandler(Optimization::onSelectTransmissionCapacity<CAPACITY>),
168  nullptr,
169  this);
170 }
171 
172 } // namespace Antares::Window::Options
173 
174 #endif // __ANTARES_APPLICATION_WINDOWS_OPTIONS_OPTIMIZATION_PREFS_H__
Definition: button.h:32
Startup Wizard User Interface.
Definition: optimization.h:36
virtual ~Optimization()
Destructor.
Definition: optimization.cpp:371
Optimization(wxWindow *parent)
Default constructor.
Definition: optimization.cpp:92