Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call to solver : trial for simplification #2452

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
54d88cb
Remove Sirius direct call : all developments in one
guilpier-code Oct 2, 2024
4fb3544
Remove Sirius direct call : more tests on CI
guilpier-code Oct 2, 2024
1bb4a6c
Remove Sirius direct call : clang format
guilpier-code Oct 2, 2024
8b5f1cc
Remove Sirius direct call : cucumber is adapted to current changes (C…
guilpier-code Oct 4, 2024
27fc92e
Trial to simplify solver call : solver ptr a bit more clear
guilpier-code Oct 4, 2024
a4f1d80
Trial to simplify solver call : crash correction
guilpier-code Oct 4, 2024
c8d5896
Trial to simplify solver call : omission in previous commit corrected
guilpier-code Oct 4, 2024
343f2d8
Trial to simplify solver call : correct a crash on infeasible problems
guilpier-code Oct 7, 2024
91de738
Trial to simplify solver call : try to improve solver liberation
guilpier-code Oct 7, 2024
ef66d4c
Trial to simplify solver call : towards more improvement on solver li…
guilpier-code Oct 7, 2024
59348c7
Trial to simplify solver call : improve solvers passing among all run…
guilpier-code Oct 7, 2024
e36b6dd
Trial to simplify solver call : avoid code duplication in resetting s…
guilpier-code Oct 7, 2024
c2ab575
Trial to simplify solver call : no need to import basic status into c…
guilpier-code Oct 7, 2024
1b4ebd0
Trial to simplify solver call : for solver, case SPX_ERREUR_INTERNE i…
guilpier-code Oct 7, 2024
15851b6
Trial to simplify solver call : trial to remove status transfers betw…
guilpier-code Oct 7, 2024
668ce02
[skip ci] Revert "Trial to simplify solver call : trial to remove sta…
guilpier-code Oct 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ jobs:
run: |
git submodule update --init --remote --recursive src/tests/resources/Antares_Simulator_Tests_NR

- name: Run named mps tests
if: ${{ env.RUN_SIMPLE_TESTS == 'true' && !cancelled() }}
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
batch-name: valid-named-mps
os: ${{ env.os }}
variant: "named-mps"
#- name: Run named mps tests
# if: ${{ env.RUN_SIMPLE_TESTS == 'true' && !cancelled() }}
# uses: ./.github/workflows/run-tests
# with:
# simtest-tag: ${{ env.SIMTEST }}
# batch-name: valid-named-mps
# os: ${{ env.os }}
# variant: "named-mps"

- name: Run unfeasibility-related tests
if: ${{ env.RUN_SIMPLE_TESTS == 'true' && !cancelled() }}
Expand Down Expand Up @@ -240,13 +240,13 @@ jobs:
with:
feature: "features/short_tests.feature"

- name: Run mps tests
if: ${{ env.RUN_SIMPLE_TESTS == 'true' && !cancelled() }}
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
batch-name: valid-mps
os: ${{ env.os }}
# - name: Run mps tests
# if: ${{ env.RUN_SIMPLE_TESTS == 'true' && !cancelled() }}
# uses: ./.github/workflows/run-tests
# with:
# simtest-tag: ${{ env.SIMTEST }}
# batch-name: valid-mps
# os: ${{ env.os }}

- name: Run tests for adequacy patch (CSR)
if: ${{ env.RUN_SIMPLE_TESTS == 'true' && !cancelled() }}
Expand All @@ -257,7 +257,7 @@ jobs:
os: ${{ env.os }}

- name: Run parallel tests
if: ${{ env.RUN_EXTENDED_TESTS == 'true' && !cancelled() }}
if: ${{ env.RUN_SIMPLE_TESTS == 'true' && !cancelled() }}
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
Expand All @@ -275,7 +275,7 @@ jobs:
variant: "tsgenerator"

- name: Run medium-tests
if: ${{ env.RUN_EXTENDED_TESTS == 'true' && !cancelled() }}
if: ${{ env.RUN_SIMPLE_TESTS == 'true' && !cancelled() }}
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
Expand All @@ -288,23 +288,23 @@ jobs:
feature: "features/medium_tests.feature"

- name: Run long-tests-1
if: ${{ env.RUN_EXTENDED_TESTS == 'true' && !cancelled() }}
if: ${{ env.RUN_SIMPLE_TESTS == 'true' && !cancelled() }}
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
batch-name: long-tests-1
os: ${{ env.os }}

- name: Run long-tests-2
if: ${{ env.RUN_EXTENDED_TESTS == 'true' && !cancelled() }}
if: ${{ env.RUN_SIMPLE_TESTS == 'true' && !cancelled() }}
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
batch-name: long-tests-2
os: ${{ env.os }}

- name: Run long-tests-3
if: ${{ env.RUN_EXTENDED_TESTS == 'true' && !cancelled() }}
if: ${{ env.RUN_SIMPLE_TESTS == 'true' && !cancelled() }}
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
Expand Down
56 changes: 28 additions & 28 deletions .github/workflows/windows-vcpkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ jobs:
- name: Install pip dependencies if necessary
run: pip install -r src/tests/examples/requirements.txt

- name: Init submodule Antares_Simulator_Tests
run: |
git submodule update --init --remote src/tests/resources/Antares_Simulator_Tests

- name: Init submodule Antares_Simulator_Tests_NR
run: |
git submodule update --init --remote src/tests/resources/Antares_Simulator_Tests_NR

- name: Enable git longpaths
run: git config --system core.longpaths true

Expand Down Expand Up @@ -144,22 +152,14 @@ jobs:
run: |
echo "SIMTEST=${{ fromJson(env.SIMTEST_JSON).version }}" >> $GITHUB_ENV

- name: Init submodule Antares_Simulator_Tests
run: |
git submodule update --init --remote src/tests/resources/Antares_Simulator_Tests

- name: Init submodule Antares_Simulator_Tests_NR
run: |
git submodule update --init --remote src/tests/resources/Antares_Simulator_Tests_NR

- name: Run named mps tests
if: ${{ env.RUN_SIMPLE_TESTS == 'true' && ! cancelled() }}
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
batch-name: valid-named-mps
os: ${{ env.os }}
variant: "named-mps"
# - name: Run named mps tests
# if: ${{ env.RUN_SIMPLE_TESTS == 'true' && ! cancelled() }}
# uses: ./.github/workflows/run-tests
# with:
# simtest-tag: ${{ env.SIMTEST }}
# batch-name: valid-named-mps
# os: ${{ env.os }}
# variant: "named-mps"

- name: Run unfeasibility-related tests
if: ${{ env.RUN_SIMPLE_TESTS == 'true' && ! cancelled() }}
Expand Down Expand Up @@ -250,16 +250,16 @@ jobs:
with:
feature: "features/short_tests.feature"

- name: Run mps tests
if: ${{ env.RUN_SIMPLE_TESTS == 'true' && !cancelled() }}
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
batch-name: valid-mps
os: ${{ env.os }}
# - name: Run mps tests
# if: ${{ env.RUN_SIMPLE_TESTS == 'true' && !cancelled() }}
# uses: ./.github/workflows/run-tests
# with:
# simtest-tag: ${{ env.SIMTEST }}
# batch-name: valid-mps
# os: ${{ env.os }}

- name: Run parallel tests
if: ${{ env.RUN_EXTENDED_TESTS == 'true' && !cancelled() }}
if: ${{ env.RUN_SIMPLE_TESTS == 'true' && !cancelled() }}
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
Expand All @@ -277,7 +277,7 @@ jobs:
variant: "tsgenerator"

- name: Run medium-tests
if: ${{ env.RUN_EXTENDED_TESTS == 'true' && !cancelled() }}
if: ${{ env.RUN_SIMPLE_TESTS == 'true' && !cancelled() }}
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
Expand All @@ -290,23 +290,23 @@ jobs:
feature: "features/medium_tests.feature"

- name: Run long-tests-1
if: ${{ env.RUN_EXTENDED_TESTS == 'true' && !cancelled() }}
if: ${{ env.RUN_SIMPLE_TESTS == 'true' && !cancelled() }}
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
batch-name: long-tests-1
os: ${{ env.os }}

- name: Run long-tests-2
if: ${{ env.RUN_EXTENDED_TESTS == 'true' && !cancelled() }}
if: ${{ env.RUN_SIMPLE_TESTS == 'true' && !cancelled() }}
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
batch-name: long-tests-2
os: ${{ env.os }}

- name: Run long-tests-3
if: ${{ env.RUN_EXTENDED_TESTS == 'true' && !cancelled() }}
if: ${{ env.RUN_SIMPLE_TESTS == 'true' && !cancelled() }}
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
Expand Down
16 changes: 2 additions & 14 deletions src/libs/antares/InfoCollection/StudyInfoCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ void StudyInfoCollector::toFileContent(FileContent& file_content)
unitCommitmentModeToFileContent(file_content);
maxNbYearsInParallelToFileContent(file_content);
solverVersionToFileContent(file_content);
ORToolsUsed(file_content);
ORToolsSolver(file_content);
}

Expand Down Expand Up @@ -144,21 +143,10 @@ void StudyInfoCollector::solverVersionToFileContent(FileContent& file_content)
file_content.addItemToSection("study", "antares version", version);
}

void StudyInfoCollector::ORToolsUsed(FileContent& file_content)
{
const bool& ortoolsUsed = study_.parameters.optOptions.ortoolsUsed;
file_content.addItemToSection("study", "ortools used", ortoolsUsed ? "true" : "false");
}

void StudyInfoCollector::ORToolsSolver(FileContent& file_content)
{
const bool& ortoolsUsed = study_.parameters.optOptions.ortoolsUsed;
std::string ortoolsSolver = "none";
if (ortoolsUsed)
{
ortoolsSolver = study_.parameters.optOptions.ortoolsSolver;
}
file_content.addItemToSection("study", "ortools solver", ortoolsSolver);
std::string solverName = study_.parameters.optOptions.ortoolsSolver;
file_content.addItemToSection("study", "ortools solver", solverName);
}

// Collecting data optimization problem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class StudyInfoCollector
void maxNbYearsInParallelToFileContent(FileContent& file_content);
void solverVersionToFileContent(FileContent& file_content);

void ORToolsUsed(FileContent& file_content);
void ORToolsSolver(FileContent& file_content);

// Member data
Expand Down
16 changes: 3 additions & 13 deletions src/libs/antares/checks/checkLoadedInputData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,12 @@

namespace Antares::Check
{
void checkOrtoolsUsage(Antares::Data::UnitCommitmentMode ucMode,
bool ortoolsUsed,
const std::string& solverName)
void checkOrtoolsUsage(Antares::Data::UnitCommitmentMode ucMode, const std::string& solverName)
{
using namespace Antares::Data;
if (ucMode == UnitCommitmentMode::ucMILP)
if (ucMode == UnitCommitmentMode::ucMILP && solverName == "sirius")
{
if (!ortoolsUsed)
{
throw Error::IncompatibleMILPWithoutOrtools();
}

if (solverName == "sirius")
{
throw Error::IncompatibleMILPOrtoolsSolver();
}
throw Error::IncompatibleMILPOrtoolsSolver();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
namespace Antares::Check
{

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

void checkStudyVersion(const AnyString& optStudyFolder);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ namespace Antares::Solver::Optimization

struct OptimizationOptions
{
//! Force ortools use
bool ortoolsUsed = false;
//! The solver name, sirius is the default
std::string ortoolsSolver = "sirius";
bool solverLogs = false;
Expand Down
9 changes: 2 additions & 7 deletions src/libs/antares/study/parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,6 @@ bool Parameters::loadFromINI(const IniFile& ini, const StudyVersion& version)
void Parameters::handleOptimizationOptions(const StudyLoadOptions& options)
{
// Options only set from the command-line
optOptions.ortoolsUsed = options.optOptions.ortoolsUsed;
optOptions.ortoolsSolver = options.optOptions.ortoolsSolver;
optOptions.solverParameters = options.optOptions.solverParameters;

Expand Down Expand Up @@ -1730,12 +1729,8 @@ void Parameters::prepareForSimulation(const StudyLoadOptions& options)
logs.info() << " :: ignoring hurdle costs";
}

// Indicate ortools solver used
if (options.optOptions.ortoolsUsed)
{
logs.info() << " :: ortools solver " << options.optOptions.ortoolsSolver
<< " used for problem resolution";
}
logs.info() << " :: solver " << options.optOptions.ortoolsSolver
<< " is used for problem resolution";

// indicated that Problems will be named
if (namedProblems)
Expand Down
4 changes: 1 addition & 3 deletions src/solver/application/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,7 @@ 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);
checkOrtoolsUsage(pParameters->unitCommitment.ucMode, pParameters->optOptions.ortoolsSolver);

checkSimplexRangeHydroPricing(pParameters->simplexOptimizationRange,
pParameters->hydroPricing.hpMode);
Expand Down
31 changes: 10 additions & 21 deletions src/solver/misc/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,11 @@ std::unique_ptr<Yuni::GetOpt::Parser> CreateParser(Settings& settings, StudyLoad
"force-parallel",
"Override the max number of years computed simultaneously");

// add option for ortools use
// --use-ortools
parser->addFlag(options.optOptions.ortoolsUsed,
' ',
"use-ortools",
"Use ortools library to launch solver");

//--ortools-solver
parser->add(options.optOptions.ortoolsSolver,
' ',
"ortools-solver",
"Ortools solver used for simulation (only available with use-ortools "
"option)\nAvailable solver list : "
"solver",
"Solver used for simulation\nAvailable solver list : "
+ availableOrToolsSolversString());

//--xpress-parameters
Expand Down Expand Up @@ -266,18 +258,15 @@ void checkAndCorrectSettingsAndOptions(Settings& settings, Data::StudyLoadOption

void checkOrtoolsSolver(const Antares::Solver::Optimization::OptimizationOptions& optOptions)
{
if (optOptions.ortoolsUsed)
{
const std::string& solverName = optOptions.ortoolsSolver;
const std::list<std::string> availableSolverList = getAvailableOrtoolsSolverName();
const std::string& solverName = optOptions.ortoolsSolver;
const std::list<std::string> availableSolverList = getAvailableOrtoolsSolverName();

// Check if solver is available
bool found = (std::find(availableSolverList.begin(), availableSolverList.end(), solverName)
!= availableSolverList.end());
if (!found)
{
throw Error::InvalidSolver(optOptions.ortoolsSolver, availableOrToolsSolversString());
}
// Check if solver is available
bool found = (std::find(availableSolverList.begin(), availableSolverList.end(), solverName)
!= availableSolverList.end());
if (!found)
{
throw Error::InvalidSolver(optOptions.ortoolsSolver, availableOrToolsSolversString());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include "opt_constants.h"

using namespace operations_research;
/*--------------------------------------------------------------------------------------*/

/* Le probleme a resoudre */
Expand Down Expand Up @@ -90,7 +91,7 @@ struct PROBLEME_ANTARES_A_RESOUDRE
matrice de base reguliere, et dans ce cas il n'y a pas de solution
*/

std::vector<void*> ProblemesSpx;
std::vector<MPSolver*> ProblemesSpx;

std::vector<int>
PositionDeLaVariable; /* Vecteur a passer au Simplexe pour recuperer la base optimale */
Expand All @@ -106,9 +107,6 @@ struct PROBLEME_ANTARES_A_RESOUDRE
std::vector<std::string> NomDesContraintes;

std::vector<bool> VariablesEntieres; // true = int, false = continuous

// PIMPL is used to break dependency to OR-Tools' linear_solver.h (big header)
Antares::Optimization::BasisStatus basisStatus;
};

#endif /* __SOLVER_OPTIMISATION_STRUCTURE_PROBLEME_A_RESOUDRE_H__ */
Loading
Loading