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

Feature/zip mps #492

Merged
merged 200 commits into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
200 commits
Select commit Hold shift + click to select a range
dfa8b04
work on zipped mps
a-zakir Jul 22, 2022
24d3a71
add compressed-archive reader
a-zakir Jul 27, 2022
deba679
add ArchiveWriter
a-zakir Jul 27, 2022
f1f30ac
read-write zipped mps in problem-generation step
a-zakir Jul 29, 2022
4960050
use Zipped mps in benders
a-zakir Aug 1, 2022
ebb9218
delete mps zip file
a-zakir Aug 1, 2022
d74fcb7
implementing zipped mps for bendersmpi
a-zakir Aug 1, 2022
2110cec
mps zip add tests
a-zakir Aug 2, 2022
667cb7a
force temporary antares-deps branch
a-zakir Aug 2, 2022
d18e960
run with deps pre-release
a-zakir Aug 2, 2022
f90f18e
test switch antares-deps branch
a-zakir Aug 3, 2022
d87619e
set mpi compiler only in benders mpi src
a-zakir Aug 4, 2022
e61ca27
fix: set CMAKE_CXX_COMPILER to MPI_CXX_COMPILER
a-zakir Aug 4, 2022
285386f
fix centos ci: use gtest legacy api
a-zakir Aug 4, 2022
daba54c
fix: test_problem_generation
a-zakir Aug 5, 2022
9efbac6
fix bug on windows
a-zakir Aug 5, 2022
8cc7a2f
delete unused file
a-zakir Aug 5, 2022
0fa2116
fix lp_namer E2E
a-zakir Aug 8, 2022
24ae1bf
avoid to dangling pointer
a-zakir Aug 8, 2022
559e35f
update some tests
a-zakir Aug 8, 2022
29917d9
fix: close subproblem file
a-zakir Aug 9, 2022
6357fcb
fix mininetwork test add zipped mps
a-zakir Aug 9, 2022
78e32d6
fix mini_instance_LP test
a-zakir Aug 9, 2022
b920d7b
fix: mini_instance_MIP
a-zakir Aug 9, 2022
d0af5fb
reset tests
a-zakir Aug 10, 2022
a0bdbc5
use tmp dir for benders E2E tests
a-zakir Aug 10, 2022
08c8fe7
check test result in tmp dir
a-zakir Aug 10, 2022
c94b59e
save results
a-zakir Aug 10, 2022
d98f76d
save results
a-zakir Aug 10, 2022
ff7d6e2
save results
a-zakir Aug 10, 2022
b0b0ee7
save results
a-zakir Aug 10, 2022
b9ca354
save results
a-zakir Aug 10, 2022
619274b
save results
a-zakir Aug 10, 2022
5db496e
save results
a-zakir Aug 10, 2022
604ea71
reset tests data
a-zakir Aug 11, 2022
70105d8
fix lpnamer tests
a-zakir Aug 11, 2022
cf58a4f
delete unused file
a-zakir Aug 11, 2022
d680eb5
expand zip-mps to merge-mps
a-zakir Aug 11, 2022
b081374
manage line breaker in tests mps output
a-zakir Aug 12, 2022
10791bb
comment
a-zakir Aug 22, 2022
752e8c9
delete comment
a-zakir Aug 22, 2022
2adc4f0
fix restart tests
a-zakir Aug 22, 2022
9ad135c
fix windows ci
a-zakir Aug 22, 2022
c89ec5a
update deps version
a-zakir Aug 22, 2022
27312dc
fix restart benders tests
a-zakir Aug 23, 2022
bfeb7ae
update E2E tests
a-zakir Aug 23, 2022
86fcb2c
update deps version
a-zakir Aug 23, 2022
69821b9
update antares-deps submodule
a-zakir Aug 23, 2022
9bdd3bc
roll back windows ci
a-zakir Aug 24, 2022
5f868e4
work on: adapt xpansion launcher to antares-study zip
a-zakir Aug 25, 2022
c79028c
extract max files in memory
a-zakir Aug 25, 2022
6eb4eb6
fix post pb_gen archive path
a-zakir Aug 25, 2022
4fefda4
fix benders step
a-zakir Aug 25, 2022
ef503e0
update
a-zakir Aug 26, 2022
5fa7dbf
fix benders et study-update step
a-zakir Aug 26, 2022
eafee19
add mps file immediatly
a-zakir Aug 26, 2022
295218d
after PR -1
a-zakir Aug 26, 2022
bafe5e6
Update src/cpp/helpers/ArchiveWriter.cpp
a-zakir Aug 26, 2022
e32677d
raise exception instead of redireting to std::cerr
a-zakir Aug 26, 2022
4430aa8
fix benders_drive unit tests
a-zakir Aug 29, 2022
1924c42
fix problem_genration unit tests
a-zakir Aug 29, 2022
ca9ce2f
fix test_yearly_weigth_writer.py
a-zakir Aug 29, 2022
60961b2
fix zip_mps_lib tests
a-zakir Aug 29, 2022
5b98b9f
fix tests/cpp/benders
a-zakir Aug 30, 2022
56f45a1
update tests
a-zakir Aug 30, 2022
65bb88f
lp_namer E2E tests ok
a-zakir Aug 30, 2022
95e2bb2
update restart
a-zakir Aug 30, 2022
2297299
ok restart
a-zakir Aug 30, 2022
d262610
close writer before rename zip
a-zakir Aug 31, 2022
acf51ec
handle Crlf/Lf
a-zakir Aug 31, 2022
7909887
minizip-ng to use zlib-ng
a-zakir Sep 16, 2022
2901a4d
update find minizip::
a-zakir Sep 19, 2022
f9f7cfc
update deps version
a-zakir Sep 19, 2022
96b371b
update after review
a-zakir Sep 19, 2022
7a35c04
try fix centos tests
a-zakir Sep 19, 2022
1d1c153
fix centos tests 2
a-zakir Sep 19, 2022
b0288bc
Revert "fix centos tests 2"
a-zakir Sep 20, 2022
76cda4b
fix restart test
a-zakir Sep 20, 2022
273e58f
fix error in tests/end_to_end/restart/test_restartBendersEndToEnd.py
a-zakir Sep 20, 2022
bade684
use parameterized values in test fixture
a-zakir Sep 20, 2022
1fc78c7
refactor
a-zakir Sep 20, 2022
7247134
clean tmp_path before tests
a-zakir Sep 20, 2022
795cc3a
avoid tmp_path in mpi tests
a-zakir Sep 21, 2022
b012c94
back to antares-deps v2.0.3
a-zakir Sep 21, 2022
08198a7
minizip-ng --> minizip
a-zakir Sep 21, 2022
fa195e9
Use minizip-ng package
JasonMarechal25 Sep 27, 2022
bc34853
Make zip manipulation thread safe
JasonMarechal25 Sep 28, 2022
492825e
Update antares deps to 2.0.5 Fix package missing minizip-ng
JasonMarechal25 Sep 29, 2022
826c850
copy master mps to tmp before run
a-zakir Oct 5, 2022
057e19c
link to antares-deps v2.0.5
a-zakir Oct 6, 2022
0ae7e21
fix: avoid dangling refs
a-zakir Oct 6, 2022
16e955a
work on zipped mps
a-zakir Jul 22, 2022
76d0e8e
add compressed-archive reader
a-zakir Jul 27, 2022
eb67e7c
add ArchiveWriter
a-zakir Jul 27, 2022
1f246b3
read-write zipped mps in problem-generation step
a-zakir Jul 29, 2022
f152604
use Zipped mps in benders
a-zakir Aug 1, 2022
df58bc2
delete mps zip file
a-zakir Aug 1, 2022
92f7a3d
implementing zipped mps for bendersmpi
a-zakir Aug 1, 2022
18aab1f
mps zip add tests
a-zakir Aug 2, 2022
03e87c9
force temporary antares-deps branch
a-zakir Aug 2, 2022
b3516f2
run with deps pre-release
a-zakir Aug 2, 2022
294f209
test switch antares-deps branch
a-zakir Aug 3, 2022
73c123e
set mpi compiler only in benders mpi src
a-zakir Aug 4, 2022
5e28308
fix: set CMAKE_CXX_COMPILER to MPI_CXX_COMPILER
a-zakir Aug 4, 2022
243b912
fix centos ci: use gtest legacy api
a-zakir Aug 4, 2022
9225e4a
fix: test_problem_generation
a-zakir Aug 5, 2022
4915a24
fix bug on windows
a-zakir Aug 5, 2022
b0deb75
delete unused file
a-zakir Aug 5, 2022
a19511d
fix lp_namer E2E
a-zakir Aug 8, 2022
8ac29cd
avoid to dangling pointer
a-zakir Aug 8, 2022
b67a0f7
update some tests
a-zakir Aug 8, 2022
37fefda
fix: close subproblem file
a-zakir Aug 9, 2022
437f5f1
fix mininetwork test add zipped mps
a-zakir Aug 9, 2022
a78c89d
fix mini_instance_LP test
a-zakir Aug 9, 2022
8816c7b
fix: mini_instance_MIP
a-zakir Aug 9, 2022
275142c
reset tests
a-zakir Aug 10, 2022
de4a276
use tmp dir for benders E2E tests
a-zakir Aug 10, 2022
f46e94a
check test result in tmp dir
a-zakir Aug 10, 2022
cc30e54
save results
a-zakir Aug 10, 2022
9ea86f4
save results
a-zakir Aug 10, 2022
c0043e8
save results
a-zakir Aug 10, 2022
b508de2
save results
a-zakir Aug 10, 2022
cf0ff97
save results
a-zakir Aug 10, 2022
3f4e203
save results
a-zakir Aug 10, 2022
e1d203b
save results
a-zakir Aug 10, 2022
26377f9
reset tests data
a-zakir Aug 11, 2022
95e1c4e
fix lpnamer tests
a-zakir Aug 11, 2022
8c0eccc
delete unused file
a-zakir Aug 11, 2022
8fff4bf
expand zip-mps to merge-mps
a-zakir Aug 11, 2022
93de9c3
manage line breaker in tests mps output
a-zakir Aug 12, 2022
d741f26
comment
a-zakir Aug 22, 2022
a951176
delete comment
a-zakir Aug 22, 2022
d43d395
fix restart tests
a-zakir Aug 22, 2022
2b44050
fix windows ci
a-zakir Aug 22, 2022
c0a14db
update deps version
a-zakir Aug 22, 2022
5b99c4f
fix restart benders tests
a-zakir Aug 23, 2022
c40974f
update E2E tests
a-zakir Aug 23, 2022
00d0192
update deps version
a-zakir Aug 23, 2022
479766e
update antares-deps submodule
a-zakir Aug 23, 2022
f3bb9cb
roll back windows ci
a-zakir Aug 24, 2022
386f5de
work on: adapt xpansion launcher to antares-study zip
a-zakir Aug 25, 2022
55db9da
extract max files in memory
a-zakir Aug 25, 2022
b45eb4d
fix post pb_gen archive path
a-zakir Aug 25, 2022
c5bc923
fix benders step
a-zakir Aug 25, 2022
329bb8b
update
a-zakir Aug 26, 2022
404a6d9
fix benders et study-update step
a-zakir Aug 26, 2022
4a471b9
add mps file immediatly
a-zakir Aug 26, 2022
bcb5ad3
after PR -1
a-zakir Aug 26, 2022
0a85592
Update src/cpp/helpers/ArchiveWriter.cpp
a-zakir Aug 26, 2022
634742b
raise exception instead of redireting to std::cerr
a-zakir Aug 26, 2022
6296b3b
fix benders_drive unit tests
a-zakir Aug 29, 2022
ec2c019
fix problem_genration unit tests
a-zakir Aug 29, 2022
52cabc9
fix test_yearly_weigth_writer.py
a-zakir Aug 29, 2022
44c6bef
fix zip_mps_lib tests
a-zakir Aug 29, 2022
d75f895
fix tests/cpp/benders
a-zakir Aug 30, 2022
7c4f1df
update tests
a-zakir Aug 30, 2022
203f936
lp_namer E2E tests ok
a-zakir Aug 30, 2022
84c8694
update restart
a-zakir Aug 30, 2022
9241c35
ok restart
a-zakir Aug 30, 2022
be86d95
close writer before rename zip
a-zakir Aug 31, 2022
0e03999
handle Crlf/Lf
a-zakir Aug 31, 2022
f335750
minizip-ng to use zlib-ng
a-zakir Sep 16, 2022
54faba6
update find minizip::
a-zakir Sep 19, 2022
fb3068e
update deps version
a-zakir Sep 19, 2022
9bba6e1
update after review
a-zakir Sep 19, 2022
4105685
try fix centos tests
a-zakir Sep 19, 2022
85d22d2
fix centos tests 2
a-zakir Sep 19, 2022
a6c86e5
Revert "fix centos tests 2"
a-zakir Sep 20, 2022
9137776
fix restart test
a-zakir Sep 20, 2022
9c3159e
fix error in tests/end_to_end/restart/test_restartBendersEndToEnd.py
a-zakir Sep 20, 2022
bcb4529
use parameterized values in test fixture
a-zakir Sep 20, 2022
140e6c9
refactor
a-zakir Sep 20, 2022
4feab37
clean tmp_path before tests
a-zakir Sep 20, 2022
0f849c5
avoid tmp_path in mpi tests
a-zakir Sep 21, 2022
fb77405
back to antares-deps v2.0.3
a-zakir Sep 21, 2022
5f7c454
minizip-ng --> minizip
a-zakir Sep 21, 2022
6234e67
Use minizip-ng package
JasonMarechal25 Sep 27, 2022
d826f2d
Make zip manipulation thread safe
JasonMarechal25 Sep 28, 2022
c1ff159
Update antares deps to 2.0.5 Fix package missing minizip-ng
JasonMarechal25 Sep 29, 2022
f4abb40
copy master mps to tmp before run
a-zakir Oct 5, 2022
478714e
link to antares-deps v2.0.5
a-zakir Oct 6, 2022
aa76378
fix: avoid dangling refs
a-zakir Oct 6, 2022
5ffdbae
Merge branch 'feature/zip_mps' of https://github.com/AntaresSimulator…
a-zakir Oct 7, 2022
36dc143
retore mps for lp_namer unit tests
a-zakir Oct 7, 2022
1d581e5
avoid deleting SP1.mps and SP2.mps by renaming them
a-zakir Oct 7, 2022
22dc856
fix smell code
a-zakir Oct 7, 2022
5df22ba
copy zip
a-zakir Oct 10, 2022
0c539dd
master.mps is nor in zip archive
a-zakir Oct 10, 2022
d2b708c
test
a-zakir Oct 10, 2022
21a7429
merge develop
a-zakir Oct 12, 2022
172059f
fix VariableFileReader ctor
a-zakir Oct 12, 2022
8d5f972
Merge remote-tracking branch 'origin/develop' into feature/zip_mps
JasonMarechal25 Oct 27, 2022
3f818e1
Use zip from simulator
JasonMarechal25 Oct 27, 2022
8a63971
Fix post merge
JasonMarechal25 Oct 27, 2022
15a1b55
Remove temporary code to zip data
JasonMarechal25 Oct 27, 2022
56b0062
Handle ts-numbers with zip data
JasonMarechal25 Nov 2, 2022
f838301
Upgrade simulator to 8.4
JasonMarechal25 Nov 28, 2022
118f104
Merge branch 'develop' into feature/zip_mps
JasonMarechal25 Nov 28, 2022
914699a
Fix post merge
JasonMarechal25 Nov 28, 2022
8c4b4e7
Clean up
JasonMarechal25 Nov 28, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ runs:

wget https://github.com/AntaresSimulatorTeam/Antares_Simulator/releases/download/v${{inputs.antares-version}}/rte-antares-${{inputs.antares-version}}-installer-64bits.zip
unzip rte-antares-${{inputs.antares-version}}-installer-64bits.zip
rm -rf rte-antares-${{inputs.antares-version}}-installer-64bits.zip
rm -rf rte-antares-${{inputs.antares-version}}-installer-64bits.zip
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ sbeParseJson(antares_version jsonContent)
#need to know antares solver version because antares-solver targets still refers to antares version
SET(ANTARES_VERSION ${antares_version.antares_version_executable})
SET(ANTARES_VERSION_TAG ${antares_version.antares_version})
SET(MINIZIP_TAG ${antares_version.minizip_ng_version})

sbeClearJson(antares_version)

Expand All @@ -183,7 +184,7 @@ endif()
add_subdirectory(antares-deps)

add_subdirectory(cmake/dependencies ${CMAKE_CURRENT_BINARY_DIR}/build_deps)

find_package(minizip-ng REQUIRED)
# ---------------------------------------------------------------------------
# Boost
# ---------------------------------------------------------------------------
Expand Down
7 changes: 4 additions & 3 deletions antares-version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"antares_version": "8.3.2",
"antares_version_executable": "8.3",
"antares_version": "8.4.0-rc2",
"antares_version_executable": "8.4",
"antares_xpansion_version": "0.8.0",
"antares_deps_version": "2.0.5"
"antares_deps_version": "2.0.5",
"minizip_ng_version": "3.0.6"
}
1 change: 1 addition & 0 deletions cmake/dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ if (NOT antares-solver_FOUND)
endif()

endif()

Binary file added data_test/mini_instance_LP/MPS_ZIP_FILE.zip
Binary file not shown.
13 changes: 0 additions & 13 deletions data_test/mini_instance_LP/SP1.mps

This file was deleted.

13 changes: 0 additions & 13 deletions data_test/mini_instance_LP/SP2.mps

This file was deleted.

Binary file added data_test/mini_instance_MIP/MPS_ZIP_FILE.zip
Binary file not shown.
12 changes: 0 additions & 12 deletions data_test/mini_instance_MIP/SP1.mps

This file was deleted.

12 changes: 0 additions & 12 deletions data_test/mini_instance_MIP/SP2.mps

This file was deleted.

5 changes: 3 additions & 2 deletions data_test/mini_instance_MIP/options_default.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
"CSV_NAME": "benders_output_trace",
"BOUND_ALPHA": true,
"JSON_FILE": "./expansion/out.json",
"LAST_ITERATION_JSON_FILE": "./expansion/last_iteration.json"
}
"LAST_ITERATION_JSON_FILE": "./expansion/last_iteration.json",
"MPS_ZIP_FILE": "MPS_ZIP_FILE.zip"
}
Binary file added data_test/mini_network/MPS_ZIP_FILE.zip
Binary file not shown.
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions data_test/mini_network/options_default.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
"BOUND_ALPHA": true,
"SOLVER_NAME": "COIN",
"JSON_FILE": "./expansion/out.json",
"LAST_ITERATION_JSON_FILE": "./expansion/last_iteration.json"
}
"LAST_ITERATION_JSON_FILE": "./expansion/last_iteration.json",
"MPS_ZIP_FILE": "MPS_ZIP_FILE.zip"
}
Binary file added data_test/mps_zip/archive1.zip
Binary file not shown.
1 change: 1 addition & 0 deletions data_test/mps_zip/archive1/file1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DATA in file 1
Empty file.
7 changes: 7 additions & 0 deletions data_test/mps_zip/archive1/file3
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
File 3 content
1
2
4
2
2
3
7 changes: 7 additions & 0 deletions src/cpp/benders/benders_core/BendersBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,13 @@ std::filesystem::path BendersBase::get_structure_path() const {
return std::filesystem::path(_options.INPUTROOT) / _options.STRUCTURE_FILE;
}

/*!
* \brief Get path to mps zip file from options
*/
std::filesystem::path BendersBase::GetMpsZipPath() const {
return std::filesystem::path(_options.INPUTROOT) / _options.MPS_ZIP_FILE;
}

LogData BendersBase::bendersDataToLogData(const BendersData &data) const {
auto optimal_gap(data.best_ub - data.lb);
return {data.lb,
Expand Down
1 change: 1 addition & 0 deletions src/cpp/benders/benders_core/SimulationOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ BaseOptions SimulationOptions::get_base_options() const {
result.SOLVER_NAME = SOLVER_NAME;
result.weights = _weights;
result.RESUME = RESUME;
result.MPS_ZIP_FILE = MPS_ZIP_FILE;

return result;
}
Expand Down
1 change: 1 addition & 0 deletions src/cpp/benders/benders_core/include/BendersBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class BendersBase {
std::string const &name) const;
[[nodiscard]] std::filesystem::path get_master_path() const;
[[nodiscard]] std::filesystem::path get_structure_path() const;
[[nodiscard]] std::filesystem::path GetMpsZipPath() const;
[[nodiscard]] LogData bendersDataToLogData(const BendersData &data) const;
virtual void build_input_map();
void push_in_trace(const WorkerMasterDataPtr &worker_master_data);
Expand Down
3 changes: 3 additions & 0 deletions src/cpp/benders/benders_core/include/SimulationOptions.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@ BENDERS_OPTIONS_MACRO(RESUME, bool, false, asBool())
// Name of the last master basis file
BENDERS_OPTIONS_MACRO(LAST_MASTER_BASIS, std::string, "master_last_basis",
asString())

// Name of the MPS ZIP file
BENDERS_OPTIONS_MACRO(MPS_ZIP_FILE, std::string, "MPS_ZIP_FILE.zip", asString())
1 change: 1 addition & 0 deletions src/cpp/benders/benders_core/include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ struct BaseOptions {
bool RESUME = false;

Str2Dbl weights;
std::string MPS_ZIP_FILE;
};
typedef BaseOptions MergeMPSOptions;
struct BendersBaseOptions : public BaseOptions {
Expand Down
13 changes: 12 additions & 1 deletion src/cpp/benders/benders_mpi/BendersMPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ BendersMpi::BendersMpi(BendersBaseOptions const &options, Logger &logger,
mpi::communicator &world)
: BendersBase(options, logger, std::move(writer)),
_env(env),
_world(world) {}
_world(world) {
reader_.SetArchivePath(GetMpsZipPath());
reader_.Open();
}

/*!
* \brief Method to load each problem in a thread
Expand Down Expand Up @@ -41,8 +44,12 @@ void BendersMpi::initialize_problems() {
process_to_feed ==
_world
.rank()) { // Assign [problemNumber % processCount] to processID

const auto subProblemFilePath = GetSubproblemPath(problem.first);
reader_.ExtractFile(subProblemFilePath.filename());
addSubproblem(problem);
AddSubproblemName(problem.first);
std::filesystem::remove(subProblemFilePath);
}
current_problem_id++;
}
Expand Down Expand Up @@ -277,6 +284,10 @@ void BendersMpi::launch() {

initialize_problems();
_world.barrier();
if (_world.rank() == rank_0) {
reader_.Close();
reader_.Delete();
}
a-zakir marked this conversation as resolved.
Show resolved Hide resolved

run();
_world.barrier();
Expand Down
2 changes: 2 additions & 0 deletions src/cpp/benders/benders_mpi/include/BendersMPI.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "ArchiveReader.h"
#include "BendersBase.h"
#include "BendersStructsDatas.h"
#include "SubproblemCut.h"
Expand Down Expand Up @@ -52,6 +53,7 @@ class BendersMpi : public BendersBase {
void check_if_some_proc_had_a_failure(int success);
[[nodiscard]] bool shouldParallelize() const final { return false; }

ArchiveReader reader_;
mpi::environment &_env;
mpi::communicator &_world;
const unsigned int rank_0 = 0;
Expand Down
9 changes: 9 additions & 0 deletions src/cpp/benders/benders_sequential/BendersSequential.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <iomanip>
#include <utility>

#include "ArchiveReader.h"
#include "Timer.h"
#include "glog/logging.h"
#include "solver_utils.h"
Expand All @@ -27,10 +28,18 @@ void BendersSequential::initialize_problems() {
reset_master(new WorkerMaster(master_variable_map, get_master_path(),
get_solver_name(), get_log_level(),
_data.nsubproblem, log_name(), IsResumeMode()));
auto reader = ArchiveReader(GetMpsZipPath());
reader.Open();
for (const auto &problem : coupling_map) {
const auto subProblemFilePath = GetSubproblemPath(problem.first);
reader.ExtractFile(subProblemFilePath.filename());
addSubproblem(problem);
AddSubproblemName(problem.first);
std::filesystem::remove(subProblemFilePath);
}

reader.Close();
reader.Delete();
a-zakir marked this conversation as resolved.
Show resolved Hide resolved
}

/*!
Expand Down
20 changes: 14 additions & 6 deletions src/cpp/benders/merge_mps/MergeMPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

#include <filesystem>

#include "ArchiveReader.h"
#include "Timer.h"
#include "glog/logging.h"
MergeMPS::MergeMPS(const MergeMPSOptions &options, Logger &logger,
Writer writer)
: _options(options), _logger(logger), _writer(writer) {}

void MergeMPS::launch() {
auto structure_path(std::filesystem::path(_options.INPUTROOT) /
_options.STRUCTURE_FILE);
const auto inputRootDir = std::filesystem::path(_options.INPUTROOT);
auto structure_path(inputRootDir / _options.STRUCTURE_FILE);
CouplingMap input = build_input(structure_path);

SolverFactory factory;
Expand All @@ -25,16 +26,18 @@ void MergeMPS::launch() {
int cntProblems_l(0);

LOG(INFO) << "Merging problems..." << std::endl;
auto reader = ArchiveReader(inputRootDir / _options.MPS_ZIP_FILE);
reader.Open();
for (auto const &kvp : input) {
auto problem_name(std::filesystem::path(_options.INPUTROOT) /
(kvp.first + MPS_SUFFIX));

auto problem_name(inputRootDir / (kvp.first + MPS_SUFFIX));
SolverAbstract::Ptr solver_l = factory.create_solver(solver_to_use);
solver_l->init();
solver_l->set_output_log_level(_options.LOG_LEVEL);
solver_l->read_prob_mps(problem_name);

if (kvp.first != _options.MASTER_NAME) {
reader.ExtractFile(problem_name.filename());
solver_l->read_prob_mps(problem_name);
std::filesystem::remove(problem_name);
int mps_ncols(solver_l->get_ncols());

DblVector o(mps_ncols);
Expand All @@ -48,6 +51,8 @@ void MergeMPS::launch() {
c *= weigth;
}
solver_l->chg_obj(sequence, o);
} else {
solver_l->read_prob_mps(problem_name);
}
StandardLp lpData(solver_l);
std::string varPrefix_l = "prob" + std::to_string(cntProblems_l) + "_";
Expand All @@ -73,6 +78,9 @@ void MergeMPS::launch() {
++cntProblems_l;
}

reader.Close();
reader.Delete();

IntVector mstart;
IntVector cindex;
DblVector values;
Expand Down
6 changes: 5 additions & 1 deletion src/cpp/exe/lpnamer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ namespace po = boost::program_options;
int main(int argc, char **argv) {
try {
std::filesystem::path root;
std::filesystem::path archivePath;
std::string master_formulation;
std::string additionalConstraintFilename_l;

Expand All @@ -47,6 +48,8 @@ int main(int argc, char **argv) {
desc.add_options()("help,h", "produce help message")(
"output,o", po::value<std::filesystem::path>(&root)->required(),
"antares-xpansion study output")(
"archive,a", po::value<std::filesystem::path>(&archivePath)->required(),
"antares-xpansion study zip")(
"formulation,f",
po::value<std::string>(&master_formulation)->default_value("relaxed"),
"master formulation (relaxed or integer)")(
Expand Down Expand Up @@ -98,7 +101,8 @@ int main(int argc, char **argv) {
std::vector<ActiveLink> links = linkBuilder.getLinks();
LinkProblemsGenerator linkProblemsGenerator(links, solver_name, logger,
log_file_path);
linkProblemsGenerator.treatloop(root, couplings);
linkProblemsGenerator.treatloop(root, archivePath, couplings);


MasterGeneration master_generation(root, links, additionalConstraints,
couplings, master_formulation,
Expand Down
55 changes: 55 additions & 0 deletions src/cpp/helpers/ArchiveIO.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#ifndef _ARCHIVEIO_H
#define _ARCHIVEIO_H

extern "C" {
#include <mz.h>
#include <mz_strm.h>
#include <mz_zip.h>
#include <mz_zip_rw.h>
}
#include <stdexcept>
#include <string>

class ArchiveIOGeneralException : public std::runtime_error {
public:
ArchiveIOGeneralException(int32_t status, const std::string& action,
int32_t expectedStatus = MZ_OK)
: std::runtime_error("Failed to " + action +
" invalid status: " + std::to_string(status) + " (" +
std::to_string(expectedStatus) + " expected)") {}
};
class ArchiveIOSpecificException : public std::runtime_error {
public:
ArchiveIOSpecificException(int32_t status, const std::string& errMessage,
int32_t expectedStatus = MZ_OK)
: std::runtime_error(
errMessage + "\ninvalid status: " + std::to_string(status) + " (" +
std::to_string(expectedStatus) + " expected)") {}
};
#include <filesystem>
#include <shared_mutex>
class ArchiveIO {
private:
std::filesystem::path archivePath_;

protected:
mutable std::shared_mutex mutex_;

virtual void Create() = 0;

public:
explicit ArchiveIO(const std::filesystem::path& archivePath)
: archivePath_(archivePath) {}
ArchiveIO() = default;
std::filesystem::path ArchivePath() const { return archivePath_; }
void SetArchivePath(const std::filesystem::path& archivePath) {
archivePath_ = archivePath;
};

virtual int32_t Close() = 0;
virtual void Delete() = 0;

virtual int Open() = 0;
};

#endif // _ARCHIVEIO_H
Loading