-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e4db64e
commit f778faf
Showing
13 changed files
with
117 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
#include <antares-xpansion/benders/benders_core/SolverIO.h> | ||
#include <antares-xpansion/benders/benders_core/ProblemFormatStream.h> | ||
#include <fmt/format.h> | ||
|
||
void SolverIO::write(SolverAbstract* solver, | ||
const std::filesystem::path& path) const { | ||
switch (format_) { | ||
case ProblemsFormat::MPS_FILE: | ||
solver->write_prob_mps(path); | ||
break; | ||
case ProblemsFormat::SAVED_FILE: | ||
solver->save_prob(path); | ||
break; | ||
default: | ||
throw LogUtils::XpansionError<std::runtime_error>( | ||
fmt::format("Unknown file format {} for problem file: {}", format_, path.string()), LOGLOCATION); | ||
} | ||
} | ||
void SolverIO::read(SolverAbstract* solver, | ||
const std::filesystem::path& path) const { | ||
switch (format_) { | ||
case ProblemsFormat::MPS_FILE: | ||
solver->read_prob_mps(path); | ||
break; | ||
case ProblemsFormat::SAVED_FILE: | ||
solver->restore_prob(path); | ||
break; | ||
default: | ||
throw LogUtils::XpansionError<std::runtime_error>( | ||
fmt::format("Unknown file format {} for problem file: {}", format_, path.string()), LOGLOCATION); | ||
} | ||
} | ||
void SolverIO::configure(const std::string& solver_name, ProblemsFormat format) { | ||
solver_config_ = solver_name; | ||
format_ = format; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/cpp/benders/benders_core/include/antares-xpansion/benders/benders_core/SolverIO.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
|
||
#include "ProblemFormat.h" | ||
#include "antares-xpansion/multisolver_interface/SolverAbstract.h" | ||
#include "antares-xpansion/multisolver_interface/SolverConfig.h" | ||
|
||
class SolverIO { | ||
SolverConfig solver_config_{"Coin"}; | ||
ProblemsFormat format_; | ||
public: | ||
void configure(const std::string& solver_name, ProblemsFormat format); | ||
void write(SolverAbstract* solver, const std::filesystem::path& path) const; | ||
void read(SolverAbstract* solver, const std::filesystem::path& path) const; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters