Reaktoro
A unified framework for modeling chemically reactive systems
Regularizer.hpp
1 // Reaktoro is a unified framework for modeling chemically reactive systems.
2 //
3 // Copyright (C) 2014-2018 Allan Leal
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library. If not, see <http://www.gnu.org/licenses/>.
17 
18 #pragma once
19 
20 // C++ includes
21 #include <memory>
22 
23 // Reaktoro includes
24 #include <Reaktoro/Math/Matrix.hpp>
25 
26 namespace Reaktoro {
27 
29 struct OptimumOptions;
30 struct OptimumProblem;
31 struct OptimumState;
32 
35 {
39  bool echelonize = true;
40 
46  unsigned max_denominator = 0;
47 };
48 
51 {
52 public:
54  Regularizer();
55 
57  Regularizer(const Regularizer& other);
58 
60  virtual ~Regularizer();
61 
63  auto operator=(Regularizer other) -> Regularizer&;
64 
66  auto setOptions(const RegularizerOptions& options) -> void;
67 
72  auto regularize(OptimumProblem& problem, OptimumState& state, OptimumOptions& options) -> void;
73 
75  auto regularize(Vector& dgdp, Vector& dbdp) -> void;
76 
79  auto recover(OptimumState& state) -> void;
80 
82  auto recover(Vector& dxdp) -> void;
83 
84 private:
85  struct Impl;
86 
87  std::unique_ptr<Impl> pimpl;
88 };
89 
90 } // namespace Reaktoro
auto operator=(Regularizer other) -> Regularizer &
Assign an Regularizer instance to this instance.
Definition: Regularizer.cpp:575
bool echelonize
The boolean flag that indicates if echelonization should be performed.
Definition: Regularizer.hpp:39
A type that describes the non-linear constrained optimisation problem.
Definition: OptimumProblem.hpp:49
unsigned max_denominator
The maximum denominator that can exist in the coefficient matrix A.
Definition: Regularizer.hpp:46
virtual ~Regularizer()
Destroy this instance.
Definition: Regularizer.cpp:572
Regularizer()
Construct a default Regularizer instance.
Definition: Regularizer.cpp:564
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24
auto setOptions(const RegularizerOptions &options) -> void
Set the options for regularizing linear constraints.
Definition: Regularizer.cpp:581
auto recover(OptimumState &state) -> void
Recover an optimum state to an state that corresponds to the original optimum problem.
Definition: Regularizer.cpp:596
A type that describes the options of a optimisation calculation.
Definition: OptimumOptions.hpp:187
A type that describes the state of an optimum solution.
Definition: OptimumState.hpp:29
auto regularize(OptimumProblem &problem, OptimumState &state, OptimumOptions &options) -> void
Regularize the optimum problem, state, and options before they are used in an optimization calculatio...
Definition: Regularizer.cpp:586
A type that represents a regularized optimization problem.
Definition: Regularizer.hpp:51
A type that describes the options for regularizing linear constraints.
Definition: Regularizer.hpp:35