Skip to content

Commit

Permalink
Few improvements to solver specific options handling (#2487)
Browse files Browse the repository at this point in the history
Following comments left here #2466
  • Loading branch information
payetvin authored Nov 12, 2024
1 parent 3336eaf commit 5e17065
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 26 deletions.
6 changes: 3 additions & 3 deletions src/libs/antares/checks/checkLoadedInputData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

namespace Antares::Check
{
void checkOrtoolsUsage(Antares::Data::UnitCommitmentMode ucMode,
bool ortoolsUsed,
const std::string& solverName)
void checkSolverMILPincompatibility(Antares::Data::UnitCommitmentMode ucMode,
bool ortoolsUsed,
const std::string& solverName)
{
using namespace Antares::Data;
if (ucMode == UnitCommitmentMode::ucMILP)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
namespace Antares::Check
{

void checkOrtoolsUsage(Antares::Data::UnitCommitmentMode ucMode,
bool ortoolsUsed,
const std::string& solverName);
void checkSolverMILPincompatibility(Antares::Data::UnitCommitmentMode ucMode,
bool ortoolsUsed,
const std::string& solverName);

void checkStudyVersion(const AnyString& optStudyFolder);

Expand Down
2 changes: 1 addition & 1 deletion src/libs/antares/exception/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ target_include_directories(${PROJ}

install(DIRECTORY include/antares
DESTINATION "include"
)
)
13 changes: 6 additions & 7 deletions src/libs/antares/exception/LoadingError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,18 @@ InvalidSolver::InvalidSolver(const std::string& solver, const std::string& avail
{
}

static std::string InvalidSolverSpecificParametersHelper(const std::string& solver,
const std::string& specificParameters)
static std::string InvalidSolverParameterMessage(const std::string& solver,
const std::string& parameters)
{
std::ostringstream message;
message << "Specific parameters '" << specificParameters
message << "Specific parameters '" << parameters
<< "' are not valid or not supported for solver " << solver;
return message.str();
}

InvalidSolverSpecificParameters::InvalidSolverSpecificParameters(
const std::string& solver,
const std::string& specificParameters):
LoadingError(InvalidSolverSpecificParametersHelper(solver, specificParameters))
InvalidSolverSpecificParameters::InvalidSolverSpecificParameters(const std::string& solver,
const std::string& parameters):
LoadingError(InvalidSolverParameterMessage(solver, parameters))
{
}

Expand Down
6 changes: 3 additions & 3 deletions src/solver/application/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,9 @@ void Application::startSimulation(Data::StudyLoadOptions& options)
void Application::postParametersChecks() const
{ // Some more checks require the existence of pParameters, hence of a study.
// Their execution is delayed up to this point.
checkOrtoolsUsage(pParameters->unitCommitment.ucMode,
pParameters->optOptions.ortoolsUsed,
pParameters->optOptions.ortoolsSolver);
checkSolverMILPincompatibility(pParameters->unitCommitment.ucMode,
pParameters->optOptions.ortoolsUsed,
pParameters->optOptions.ortoolsSolver);

checkSimplexRangeHydroPricing(pParameters->simplexOptimizationRange,
pParameters->hydroPricing.hpMode);
Expand Down
2 changes: 1 addition & 1 deletion src/solver/misc/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ void checkOrtoolsSolver(const Antares::Solver::Optimization::OptimizationOptions
const std::list<std::string> availableSolverList = getAvailableOrtoolsSolverName();

// Check if solver is available
bool found = (std::find(availableSolverList.begin(), availableSolverList.end(), solverName)
bool found = (std::ranges::find(availableSolverList, solverName)
!= availableSolverList.end());
if (!found)
{
Expand Down
9 changes: 1 addition & 8 deletions src/tools/batchrun/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,7 @@ int main(int argc, const char* argv[])

if (not finder.list.empty())
{
if (finder.list.size() > 1)
{
logs.info() << "Found " << finder.list.size() << " studies";
}
else
{
logs.info() << "Found 1 study";
}
logs.info() << "Number of studies found : " << finder.list.size();
logs.info() << "Starting...";

// The folder that contains the solver
Expand Down

0 comments on commit 5e17065

Please sign in to comment.