diff --git a/src/solver/ts-generator/CMakeLists.txt b/src/solver/ts-generator/CMakeLists.txt index 75846dde21..b401f671a2 100644 --- a/src/solver/ts-generator/CMakeLists.txt +++ b/src/solver/ts-generator/CMakeLists.txt @@ -17,6 +17,13 @@ set(SRC_OPTIMIZEDGENERATORS optimized-thermal-generator/pre-scenario-builder.cpp optimized-thermal-generator/OptimizedGenerator.h optimized-thermal-generator/OptimizedGenerator.cpp + optimized-thermal-generator/CreateVariables.cpp + optimized-thermal-generator/SetVariableBounds.cpp + optimized-thermal-generator/SetProblemConstraints.cpp + optimized-thermal-generator/SetProblemCost.cpp + optimized-thermal-generator/ResetProblem.cpp + optimized-thermal-generator/SolveProbem.cpp + ) source_group("ts-generator\\optimized-thermal-generator" FILES ${SRC_OPTIMIZEDGENERATORS}) diff --git a/src/solver/ts-generator/optimized-thermal-generator/CreateVariables.cpp b/src/solver/ts-generator/optimized-thermal-generator/CreateVariables.cpp new file mode 100644 index 0000000000..24651c8380 --- /dev/null +++ b/src/solver/ts-generator/optimized-thermal-generator/CreateVariables.cpp @@ -0,0 +1,40 @@ +// +// Created by milos on 14/11/23. +// + +#include "OptimizedGenerator.h" + +namespace Antares::Solver::TSGenerator +{ +void OptimizedThermalGenerator::buildProblemVariables() +{ + countVariables(); + buildEnsAndSpillageVariables(); + buildUnitPowerOutputVariables(); + buildStartEndMntVariables(); +} + +void OptimizedThermalGenerator::countVariables() +{ + return; +} + +// create VARIABLES per day - ENS[t], Spill[t] +void OptimizedThermalGenerator::buildEnsAndSpillageVariables() +{ + return; +} + +// create VARIABLES per day and per cluster-unit - P[t][u] +void OptimizedThermalGenerator::buildUnitPowerOutputVariables() +{ + return; +} + +// create VARIABLES per day, per cluster-unit and per maintenance - s[t][u][m] & e[t][u][m] +void OptimizedThermalGenerator::buildStartEndMntVariables() +{ + return; +} + +} // namespace Antares::Solver::TSGenerator diff --git a/src/solver/ts-generator/optimized-thermal-generator/OptimizedGenerator.cpp b/src/solver/ts-generator/optimized-thermal-generator/OptimizedGenerator.cpp index b0f7df9816..79f283c3a2 100644 --- a/src/solver/ts-generator/optimized-thermal-generator/OptimizedGenerator.cpp +++ b/src/solver/ts-generator/optimized-thermal-generator/OptimizedGenerator.cpp @@ -42,39 +42,9 @@ void OptimizedThermalGenerator::GenerateOptimizedThermalTimeSeries() void OptimizedThermalGenerator::createOptimizationProblemPerGroup(int optProblemStart, int optProblemEnd) { - // TODO CR27: create methods - each line separate method - maybe new/separate class ??@!! - // group methods by var/bounds/cost/constraint in separate *.h and *.cpp files - - // create VARIABLES per day - ENS[t], Spill[t] - // - we just need optProblemStart and optProblemEnd for that - - // create VARIABLES per day and per cluster-unit - P[t][u] - - // create VARIABLES per day, per cluster-unit and per maintenance - s[t][u][m] & e[t][u][m] - - // BOUNDS per each day - bounds-per-each-day[t] - ENS[t] >= 0, Spill[t] >= 0 - - // BOUNDS per day and per each unit - bounds-per-each-day+unit[t][u] - P[t][u] >= 0 - - // BOUNDS per day, per each unit and per each mnt - bounds-per-each-day+unit+mnt[t][u][m] - // - s[t][u][m]-> [0, 1] and e[t][u][m]-> [0, 1] - - // create OBJECTIVE FUNCTION - sum through [t] and sum through [u] - - // load balance CONSTRAINTS - constraint-per-each-day[t] - we have sum through [u] inside of it - - // CONSTRAINTS per units - constraint-per-each-unit[t-fixed][u][m-fixed] - - // CONSTRAINTS per units and per maintenance - constraint-per-each-unit+mnt[t-fixed=0/T][u][m] - - // CONSTRAINTS per days, per units and per maintenance - constraint-per-each-day+unit+mnt[t][u][m] - - // CONSTRAINTS per days and per units - constraint-per-each-day+unit[t][u][m-sum per m] - - // solve problem - - // reset problem structure + runOptimizationProblem(); + // just playing here - will ue this loops later for opt problem formulation // loop through the elements of weightMap weights_ for (const auto& entryWeightMap : maintenanceGroup_) { @@ -88,6 +58,7 @@ void OptimizedThermalGenerator::createOptimizationProblemPerGroup(int optProblem ++pProgression; } } + // end play } void OptimizedThermalGenerator::createOptimizationProblemPerCluster(const Data::Area& area, diff --git a/src/solver/ts-generator/optimized-thermal-generator/OptimizedGenerator.h b/src/solver/ts-generator/optimized-thermal-generator/OptimizedGenerator.h index 3109d2245f..bf61ea8b8b 100644 --- a/src/solver/ts-generator/optimized-thermal-generator/OptimizedGenerator.h +++ b/src/solver/ts-generator/optimized-thermal-generator/OptimizedGenerator.h @@ -24,15 +24,31 @@ class OptimizedThermalGenerator : public GeneratorTempData // define here variables/structures that will help us build optimization problem // optimization problem construction methods - void calculateParameters(); void buildProblemVariables(); + void countVariables(); + void buildEnsAndSpillageVariables(); + void buildUnitPowerOutputVariables(); + void buildStartEndMntVariables(); + void setVariableBounds(); - void buildProblemConstraintsLHS(); - void buildProblemConstraintsRHS(); + void setEnsAndSpillageBounds(); + void setUnitPowerOutputBounds(); + void setStartEndMntBounds(); + void setFirstMntStartBounds(); + void setAllMntMustStartBounds(); + + void buildProblemConstraints(); + void buildLoadBalanceConstraints(); + void setStartEndMntLogicConstraints(); + void setMaxUnitOutputConstraints(); + // void buildProblemConstraintsRHS(); // let's do LHS & RHS in one go. Easier!? + void setProblemCost(); void solveProblem(); - void allocateProblem(); // this one should be called in constructor. It basically resets all the - // vectors in PROBLEME_ANTARES_A_RESOUDRE for new opt problem. + void resetProblem(); + + void runOptimizationProblem(); + // optimization problem - methods - private void createOptimizationProblemPerGroup(int start, int end); @@ -85,8 +101,6 @@ class OptimizedThermalGenerator : public GeneratorTempData std::array residualLoadDailyValues_; public: - void run(); // calls private optimization problem construction methods - explicit OptimizedThermalGenerator(Data::Study& study, Data::MaintenanceGroup& maintenanceGroup, uint year, diff --git a/src/solver/ts-generator/optimized-thermal-generator/ResetProblem.cpp b/src/solver/ts-generator/optimized-thermal-generator/ResetProblem.cpp new file mode 100644 index 0000000000..37f836700d --- /dev/null +++ b/src/solver/ts-generator/optimized-thermal-generator/ResetProblem.cpp @@ -0,0 +1,14 @@ +// +// Created by milos on 14/11/23. +// + +#include "OptimizedGenerator.h" + +namespace Antares::Solver::TSGenerator +{ +void OptimizedThermalGenerator::resetProblem() +{ + return; +} + +} // namespace Antares::Solver::TSGenerator diff --git a/src/solver/ts-generator/optimized-thermal-generator/SetProblemConstraints.cpp b/src/solver/ts-generator/optimized-thermal-generator/SetProblemConstraints.cpp new file mode 100644 index 0000000000..7c09f6c45b --- /dev/null +++ b/src/solver/ts-generator/optimized-thermal-generator/SetProblemConstraints.cpp @@ -0,0 +1,33 @@ +// +// Created by milos on 14/11/23. +// + +#include "OptimizedGenerator.h" + +namespace Antares::Solver::TSGenerator +{ +void OptimizedThermalGenerator::buildProblemConstraints() +{ + buildLoadBalanceConstraints(); + setStartEndMntLogicConstraints(); + setMaxUnitOutputConstraints(); +} + +// load balance CONSTRAINTS - constraint-per-each-day[t] - we have sum through [u] inside of it +void OptimizedThermalGenerator::buildLoadBalanceConstraints() +{ + return; +} + +// CONSTRAINTS per days, per units and per maintenance - constraint-per-each-day+unit+mnt[t][u][m] +void OptimizedThermalGenerator::setStartEndMntLogicConstraints() +{ + return; +} +// CONSTRAINTS per days and per units - constraint-per-each-day+unit[t][u][m-sum per m] +void OptimizedThermalGenerator::setMaxUnitOutputConstraints() +{ + return; +} + +} // namespace Antares::Solver::TSGenerator diff --git a/src/solver/ts-generator/optimized-thermal-generator/SetProblemCost.cpp b/src/solver/ts-generator/optimized-thermal-generator/SetProblemCost.cpp new file mode 100644 index 0000000000..70a5b68e0d --- /dev/null +++ b/src/solver/ts-generator/optimized-thermal-generator/SetProblemCost.cpp @@ -0,0 +1,15 @@ +// +// Created by milos on 14/11/23. +// + +#include "OptimizedGenerator.h" + +namespace Antares::Solver::TSGenerator +{ +// create OBJECTIVE FUNCTION - sum through [t] and sum through [u] +void OptimizedThermalGenerator::setProblemCost() +{ + return; +} + +} // namespace Antares::Solver::TSGenerator diff --git a/src/solver/ts-generator/optimized-thermal-generator/SetVariableBounds.cpp b/src/solver/ts-generator/optimized-thermal-generator/SetVariableBounds.cpp new file mode 100644 index 0000000000..e46c80308b --- /dev/null +++ b/src/solver/ts-generator/optimized-thermal-generator/SetVariableBounds.cpp @@ -0,0 +1,58 @@ +// +// Created by milos on 14/11/23. +// + +#include "OptimizedGenerator.h" + +namespace Antares::Solver::TSGenerator +{ +void OptimizedThermalGenerator::setVariableBounds() +{ + setEnsAndSpillageBounds(); + setUnitPowerOutputBounds(); + setStartEndMntBounds(); + setFirstMntStartBounds(); + setAllMntMustStartBounds(); +} + +// BOUNDS per each day - bounds-per-each-day[t] - ENS[t] >= 0, Spill[t] >= 0 +void OptimizedThermalGenerator::setEnsAndSpillageBounds() +{ + return; +} + +// BOUNDS per day and per each unit - bounds-per-each-day+unit[t][u] - P[t][u] >= 0 +void OptimizedThermalGenerator::setUnitPowerOutputBounds() +{ + return; +} + +// BOUNDS per day, per each unit and per each mnt - bounds-per-each-day+unit+mnt[t][u][m] +// - s[t][u][m]-> [0, 1] and e[t][u][m]-> [0, 1] +void OptimizedThermalGenerator::setStartEndMntBounds() +{ + return; +} + +// TODO CR27: see if to make this bound or constraint - +// it is definitely easier to do set it as a fix bound - +// but the solver might go crazy - as for adq.patch + +// BOUNDS/CONSTRAINTS per units - constraint-per-each-unit[t-fixed][u][m-fixed] +// first maintenance must start between tauLower and tauUpper +// start[tauLower-1][u][1] = 0 +// start[tauUpper][u][1] = 1 +void OptimizedThermalGenerator::setFirstMntStartBounds() +{ + return; +} + +// BOUNDS/CONSTRAINTS per units and per maintenance - constraint-per-each-unit+mnt[t-fixed=0/T][u][m] +// end[0][u][q] = 0 // no maintenance can end in first day +// start[T][u][q] = 1 // T - end Day (simulation end) // all maintenance must start till last day +void OptimizedThermalGenerator::setAllMntMustStartBounds() +{ + return; +} + +} // namespace Antares::Solver::TSGenerator diff --git a/src/solver/ts-generator/optimized-thermal-generator/SolveProbem.cpp b/src/solver/ts-generator/optimized-thermal-generator/SolveProbem.cpp new file mode 100644 index 0000000000..cf51648c72 --- /dev/null +++ b/src/solver/ts-generator/optimized-thermal-generator/SolveProbem.cpp @@ -0,0 +1,25 @@ +// +// Created by milos on 14/11/23. +// + +#include "OptimizedGenerator.h" + +namespace Antares::Solver::TSGenerator +{ +// call all methods +void OptimizedThermalGenerator::runOptimizationProblem() +{ + buildProblemVariables(); + setVariableBounds(); + buildProblemConstraints(); + setProblemCost(); + solveProblem(); + resetProblem(); +} +// retrieve and check the results if optimization was successful +void OptimizedThermalGenerator::solveProblem() +{ + return; +} + +} // namespace Antares::Solver::TSGenerator