Skip to content

Commit

Permalink
add functions for matrix checks
Browse files Browse the repository at this point in the history
  • Loading branch information
payetvin committed Jan 27, 2025
1 parent 89e46bb commit 3ce38d3
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 43 deletions.
45 changes: 24 additions & 21 deletions src/libs/antares/study/area/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,28 @@ static void readAdqPatchMode(Study& study, Area& area)
}
}

static bool checkMatrixPositive(const Matrix<>& m, const std::string& buffer, unsigned limit)
{
logs.debug() << "Checking : " << buffer;
if (m.width and m.height and limit)
{
for (unsigned x = 0; x < limit; ++x)
{
auto& column = m.entry[x];
for (unsigned y = 0; y < m.height; ++y)
{
if (column[y] < 0.)
{
logs.error() << buffer << ": negative value detected (at column " << x
<< ", row: " << y << ')';
return false;
}
}
}
}
return true;
}

template<class StringT>
static bool AreaListLoadFromFolderSingleArea(Study& study,
AreaList* list,
Expand Down Expand Up @@ -871,27 +893,8 @@ static bool AreaListLoadFromFolderSingleArea(Study& study,
&& ret;

// Check misc gen
{
buffer.clear() << "Misc Gen: `" << area.id << '`';
logs.debug() << "Checking : " << buffer;
const auto& m = area.miscGen;
if (m.width and m.height and fhhPSP)
{
for (uint x = 0; x < fhhPSP; ++x)
{
auto& column = m.entry[x];
for (uint y = 0; y < m.height; ++y)
{
if (column[y] < 0.)
{
logs.error() << buffer << ": negative value detected (at column " << x
<< ", row: " << y << ')';
ret = false;
}
}
}
}
}
buffer.clear() << "Misc Gen: `" << area.id << '`';
ret = checkMatrixPositive(area.miscGen, buffer, fhhPSP) && ret;

// Links
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ class ThermalCluster final: public Cluster, public std::enable_shared_from_this<
bool checkMinStablePowerWithNewModulation(uint idx, double value);
//@}

bool checkModulation();

bool doWeGenerateTS(bool globalTSgeneration) const;

// Check & correct availability timeseries for thermal availability
Expand Down
49 changes: 27 additions & 22 deletions src/libs/antares/study/parts/thermal/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,28 +424,7 @@ bool Data::ThermalCluster::integrityCheck()
}

// Modulation
if (modulation.height > 0)
{
CString<ant_k_cluster_name_max_length + ant_k_area_name_max_length + 50, false> buffer;
buffer << "Thermal cluster: " << parentArea->name << '/' << pName << ": Modulation";

if (modulation.width and modulation.height)
{
for (int x = 0; x < modulation.width; ++x)
{
const Matrix<>::ColumnType& col = modulation.entry[x];
for (int y = 0; y < modulation.height; ++y)
{
if (col[y] < 0.)
{
logs.error() << buffer << ": Negative value detected (at the position " << x
<< ',' << y << ')';
ret = false;
}
}
}
}
}
ret = checkModulation() && ret;

// la valeur minStablePower should not be modified
/*
Expand All @@ -461,6 +440,32 @@ bool Data::ThermalCluster::integrityCheck()
return ret;
}

bool ThermalCluster::checkModulation()
{
if (modulation.height <= 0)
{
return true;
}

std::string buffer = "Thermal cluster: " + parentArea->name + '/' + pName + ": Modulation";
if (modulation.width and modulation.height)
{
for (int x = 0; x < modulation.width; ++x)
{
for (int y = 0; y < modulation.height; ++y)
{
if (modulation[x][y] < 0.)
{
logs.error() << buffer << ": Negative value detected (at the position " << x
<< ',' << y << ')';
return false;
}
}
}
}
return true;
}

void ThermalCluster::calculatMinDivModulation()
{
minDivModulation.value = (modulation[thermalModulationCapacity][0]
Expand Down

0 comments on commit 3ce38d3

Please sign in to comment.