-
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
Showing
8 changed files
with
59 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include <antares-xpansion/benders/benders_core/CouplingMapGenerator.h> | ||
#include <antares-xpansion/xpansion_interfaces/LogUtils.h> | ||
|
||
struct InvalidStructureFile | ||
: public LogUtils::XpansionError<std::runtime_error> { | ||
using LogUtils::XpansionError<std::runtime_error>::XpansionError; | ||
}; | ||
|
||
/*! | ||
* \brief Build the input from the structure file | ||
* | ||
* Function to build the map linking each problem name to its variables and | ||
*their id | ||
* | ||
* \param root : root of the structure file | ||
* | ||
* \param summary_name : name of the structure file | ||
* | ||
* \param coupling_map : empty map to increment | ||
* | ||
* \note The id in the coupling_map is that of the variable in the solver | ||
*responsible for the creation of the structure file. | ||
*/ | ||
CouplingMap CouplingMapGenerator::build_input( | ||
const std::filesystem::path &structure_path) { | ||
CouplingMap coupling_map; | ||
std::ifstream summary(structure_path, std::ios::in); | ||
if (!summary) { | ||
std::cout << "Cannot open structure file " << structure_path << std::endl; | ||
return coupling_map; | ||
} | ||
std::string line; | ||
|
||
while (std::getline(summary, line)) { | ||
std::stringstream buffer(line); | ||
std::string problem_name; | ||
std::string variable_name; | ||
int variable_id; | ||
buffer >> problem_name; | ||
buffer >> variable_name; | ||
buffer >> variable_id; | ||
coupling_map[problem_name][variable_name] = variable_id; | ||
} | ||
|
||
summary.close(); | ||
return coupling_map; | ||
} |
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
6 changes: 6 additions & 0 deletions
6
...benders/benders_core/include/antares-xpansion/benders/benders_core/CouplingMapGenerator.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,6 @@ | ||
#pragma once | ||
#include "common.h" | ||
|
||
struct CouplingMapGenerator { | ||
static CouplingMap build_input(const std::filesystem::path &structure_path); | ||
}; |
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