idol
A C++ Framework for Optimization
Loading...
Searching...
No Matches
read_from_file.h
1//
2// Created by henri on 04.03.24.
3//
4
5#ifndef IDOL_READ_FROM_FILE_H
6#define IDOL_READ_FROM_FILE_H
7
8#include <string>
9#include "idol/mixed-integer/modeling/models/Model.h"
10#include "Description.h"
11
12namespace idol::Bilevel {
13
14 namespace impl {
16 read_from_file(Env &t_env,
17 const std::string &t_path_to_aux,
18 idol::Bilevel::Description& t_lower_level_description,
19 const std::function<Model(Env &, const std::string &)> &t_mps_reader);
20 }
21
22 template<class BackendT> Model read_from_file(Env& t_env, const std::string& t_path_to_aux, Bilevel::Description& t_lower_level_description);
23
24 template<class BackendT> std::pair<Model, Bilevel::Description> read_from_file(Env& t_env, const std::string& t_path_to_aux);
25
26}
27
28template<class BackendT>
30idol::Bilevel::read_from_file(idol::Env& t_env,
31 const std::string& t_path_to_aux,
32 idol::Bilevel::Description& t_lower_level_description) {
33
34 return idol::Bilevel::impl::read_from_file(t_env, t_path_to_aux, t_lower_level_description, [](Env& t_env, const std::string& t_file) { return BackendT::read_from_file(t_env, t_file); });
35}
36
37template<class BackendT>
38std::pair<idol::Model, idol::Bilevel::Description>
39idol::Bilevel::read_from_file(idol::Env& t_env,
40 const std::string& t_path_to_aux) {
41
42 Bilevel::Description lower_level_description(t_env);
43
44 auto high_point_relaxation = Bilevel::impl::read_from_file(t_env, t_path_to_aux, lower_level_description,[](Env& t_env, const std::string& t_file) { return BackendT::read_from_file(t_env, t_file); });
45
46 return {
47 std::move(high_point_relaxation),
48 std::move(lower_level_description)
49 };
50}
51
52#endif //IDOL_READ_FROM_FILE_H