Skip to content

Commit

Permalink
create opt problem formulation structure files
Browse files Browse the repository at this point in the history
  • Loading branch information
Milos-RTEi committed Nov 14, 2023
1 parent 492d8c8 commit be54e64
Show file tree
Hide file tree
Showing 9 changed files with 216 additions and 39 deletions.
7 changes: 7 additions & 0 deletions src/solver/ts-generator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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_)
{
Expand All @@ -88,6 +58,7 @@ void OptimizedThermalGenerator::createOptimizationProblemPerGroup(int optProblem
++pProgression;
}
}
// end play
}

void OptimizedThermalGenerator::createOptimizationProblemPerCluster(const Data::Area& area,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -85,8 +101,6 @@ class OptimizedThermalGenerator : public GeneratorTempData
std::array<double, DAYS_PER_YEAR> residualLoadDailyValues_;

public:
void run(); // calls private optimization problem construction methods

explicit OptimizedThermalGenerator(Data::Study& study,
Data::MaintenanceGroup& maintenanceGroup,
uint year,
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit be54e64

Please sign in to comment.