Skip to content

Commit

Permalink
print proper error message
Browse files Browse the repository at this point in the history
  • Loading branch information
a-zakir committed Dec 16, 2024
1 parent 7fa9009 commit e422a17
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,36 @@
*/

#pragma once
#include <string>
#include <set>
#include <string>

namespace Antares::Data::ShortTermStorage
{

struct AdditionalConstraint
struct AdditionalConstraint
{
std::string name;
std::string cluster_id;
std::string variable;
std::string operatorType;
std::set<int> hours;
std::set<int> hours;
double rhs;

unsigned int globalIndex = 0;

bool validate() const;

bool isValidVariable() const;

bool isValidOperatorType() const;
bool isValidVariable() const;

bool isValidHoursRange() const;
bool isValidOperatorType() const;

mutable std::string error_message = "";
bool isValidHoursRange() const;

std::string getErrorMessage() const { return error_message; }
mutable std::string error_message = "";

std::string getErrorMessage() const
{
return error_message;
}
};
} // namespace Antares::Data::ShortTermStorage
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
*/
#include "antares/study/parts/short-term-storage/AdditionalConstraint.h"

#include <antares/logs/logs.h>

namespace Antares::Data::ShortTermStorage
{
bool AdditionalConstraint::validate() const
Expand Down Expand Up @@ -54,18 +52,19 @@ bool AdditionalConstraint::validate() const
return true;
}

bool AdditionalConstraint::isValidHoursRange() const {
// `hours` is a sorted set; begin() gives the smallest and prev(end()) gives the largest.
return !hours.empty() && *hours.begin() >= 1
&& *std::prev(hours.end()) <= 168;

}
bool AdditionalConstraint::isValidHoursRange() const
{
// `hours` is a sorted set; begin() gives the smallest and prev(end()) gives the largest.
return !hours.empty() && *hours.begin() >= 1 && *std::prev(hours.end()) <= 168;
}

bool AdditionalConstraint::isValidVariable() const {
return variable == "injection" || variable == "withdrawal" || variable == "netting";
}
bool AdditionalConstraint::isValidVariable() const
{
return variable == "injection" || variable == "withdrawal" || variable == "netting";
}

bool AdditionalConstraint::isValidOperatorType() const {
return operatorType == "less" || operatorType == "equal" || operatorType == "greater";
}
bool AdditionalConstraint::isValidOperatorType() const
{
return operatorType == "less" || operatorType == "equal" || operatorType == "greater";
}
} // namespace Antares::Data::ShortTermStorage

0 comments on commit e422a17

Please sign in to comment.