Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonMarechal25 committed Nov 14, 2024
1 parent 6472ebb commit 52da625
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
uc_type = expansion_fast
master = integer
optimality_gap = 10
solver = Xpress
additional-constraints = contraintes.txt
8 changes: 6 additions & 2 deletions src/cpp/lpnamer/main/ProblemGeneration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ std::filesystem::path ProblemGeneration::updateProblems() {
auto weights_file = options_.WeightsFile();
auto unnamed_problems = options_.UnnamedProblems();

SettingsReader settingsReader(study_dir / "user/expansion/settings.ini", logger.get());
solver_name_ = settingsReader.Solver();
set_solver(study_dir, logger.get());

RunProblemGeneration(xpansion_output_dir, master_formulation,
additionalConstraintFilename_l, archive_path, logger,
Expand Down Expand Up @@ -336,6 +335,11 @@ void ProblemGeneration::RunProblemGeneration(
<< "Problem Generation ran in: "
<< format_time_str(problem_generation_timer.elapsed()) << std::endl;
}
void ProblemGeneration::set_solver(std::filesystem::path study_dir, ProblemGenerationLog::ProblemGenerationLogger* logger) {
SettingsReader settingsReader(study_dir / "user/expansion/settings.ini", logger);
solver_name_ = settingsReader.Solver();
}

std::shared_ptr<ArchiveReader> InstantiateZipReader(
const std::filesystem::path& antares_archive_path) {
auto reader = std::make_shared<ArchiveReader>(antares_archive_path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class ProblemGeneration {
const std::vector<ProblemData>& mpsList, std::filesystem::path& lpDir_,
std::shared_ptr<ArchiveReader> reader,
const Antares::Solver::LpsFromAntares& lps);
virtual void set_solver(std::filesystem::path study_dir, ProblemGenerationLog::ProblemGenerationLogger* logger);

Antares::Solver::LpsFromAntares lps_;
std::optional<SimulationInputMode> mode_;
virtual std::filesystem::path performAntaresSimulation();
Expand Down
5 changes: 5 additions & 0 deletions tests/cpp/lp_namer/ProblemGenerationExeOptionsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ class ProblemGenerationSpyAndMock : public ProblemGeneration {
std::filesystem::path performAntaresSimulation() override {
return options_.StudyPath() / "simulation";
}
void set_solver(
std::filesystem::path study_dir,
ProblemGenerationLog::ProblemGenerationLogger* logger) override {

}

public:
std::filesystem::path xpansion_output_dir_;
Expand Down
10 changes: 9 additions & 1 deletion tests/end_to_end/cucumber/features/SolverE2E.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,12 @@ Feature:
When I run antares-xpansion with the benders method and 1 proc(s)
Then the simulation succeeds
And Simulator has been launched with solver "Xpress"
And Benders has been launched with solver "Xpress"
And Benders has been launched with solver "Xpress"

Scenario:
Given the study path is "examples/SmallTestFiveCandidatesWithWeights"
And solver is "Cbc"
When I run antares-xpansion with the benders method and 1 proc(s)
Then the simulation succeeds
And Simulator has been launched with solver "Sirius"
And Benders has been launched with solver "Coin"
4 changes: 3 additions & 1 deletion tests/end_to_end/cucumber/features/steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,6 @@ def check_simulator_solver(context, string):

@then('Benders has been launched with solver "{string}"')
def check_benders_solver(context, string):
assert context.options_data["SOLVER_NAME"].upper() == string.upper()
solver_in_benders = context.options_data["SOLVER_NAME"]
print(f"Solver in benders: {solver_in_benders}\n")
assert solver_in_benders.upper() == string.upper()

0 comments on commit 52da625

Please sign in to comment.