Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
mps_utils.h
1/*
2** Copyright 2007-2024, RTE (https://www.rte-france.com)
3** See AUTHORS.txt
4** SPDX-License-Identifier: MPL-2.0
5** This file is part of Antares-Simulator,
6** Adequacy and Performance assessment for interconnected energy networks.
7**
8** Antares_Simulator is free software: you can redistribute it and/or modify
9** it under the terms of the Mozilla Public Licence 2.0 as published by
10** the Mozilla Foundation, either version 2 of the License, or
11** (at your option) any later version.
12**
13** Antares_Simulator is distributed in the hope that it will be useful,
14** but WITHOUT ANY WARRANTY; without even the implied warranty of
15** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16** Mozilla Public Licence 2.0 for more details.
17**
18** You should have received a copy of the Mozilla Public Licence 2.0
19** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
20*/
21#pragma once
22
23extern "C"
24{
25#include "spx_definition_arguments.h"
26#include "spx_fonctions.h"
27#include "srs_api.h"
28}
29
30#include "antares/study/fwd.h"
31
32#include "named_problem.h"
33#include "ortools_utils.h"
34
35using namespace Antares;
36using namespace Antares::Data;
37using namespace Antares::Optimization;
38using namespace operations_research;
39
40// ======================
41// MPS files writing
42// ======================
43
45{
46public:
47 explicit I_MPS_writer(uint currentOptimNumber):
48 current_optim_number_(currentOptimNumber)
49 {
50 }
51
52 I_MPS_writer() = default;
53 virtual ~I_MPS_writer() = default;
54 virtual void runIfNeeded(Solver::IResultWriter& writer, const std::string& filename) = 0;
55
56protected:
57 uint current_optim_number_ = 0;
58};
59
60// Caution : this class should be removed if we want Sirius behind or-tools
61// But we want to keep the way we write MPS files for a named problem,
62// so we keep it for now.
63class fullMPSwriter final: public I_MPS_writer
64{
65public:
66 fullMPSwriter(PROBLEME_SIMPLEXE_NOMME* named_splx_problem, uint currentOptimNumber);
67 void runIfNeeded(Solver::IResultWriter& writer, const std::string& filename) override;
68
69private:
70 PROBLEME_SIMPLEXE_NOMME* named_splx_problem_ = nullptr;
71};
72
74{
75public:
76 virtual ~fullOrToolsMPSwriter() = default;
77 fullOrToolsMPSwriter(MPSolver* solver, uint currentOptimNumber);
78 void runIfNeeded(Solver::IResultWriter& writer, const std::string& filename) override;
79
80private:
81 MPSolver* solver_ = nullptr;
82};
83
85{
86public:
87 virtual ~nullMPSwriter() = default;
88 using I_MPS_writer::I_MPS_writer;
89
90 void runIfNeeded(Solver::IResultWriter& /*writer*/, const std::string& /*filename*/) override
91 {
92 // Does nothing
93 }
94};
95
97{
98public:
99 virtual ~mpsWriterFactory() = default;
100 mpsWriterFactory(Data::mpsExportStatus exportMPS,
101 bool exportMPSOnError,
102 const int current_optim_number,
103 PROBLEME_SIMPLEXE_NOMME* named_splx_problem,
104 MPSolver* solver);
105
106 std::unique_ptr<I_MPS_writer> create();
107 std::unique_ptr<I_MPS_writer> createOnOptimizationError();
108
109private:
110 // Member functions...
111 std::unique_ptr<I_MPS_writer> createFullmpsWriter();
112 bool doWeExportMPS();
113
114 // Member data...
115 Data::mpsExportStatus export_mps_;
116 bool export_mps_on_error_;
117 PROBLEME_SIMPLEXE_NOMME* named_splx_problem_ = nullptr;
118 MPSolver* solver_ = nullptr;
119 uint current_optim_number_;
120};
Definition i_writer.h:34
Definition mps_utils.h:45
Definition mps_utils.h:64
Definition mps_utils.h:74
Definition mps_utils.h:97
Definition mps_utils.h:85
Definition constraint-slack-analysis.cpp:45