A template for a class that implements Lemke's algorithm.
More...
#include <jade.lemke.hpp>
|
static bool | solve (matrix_type &out, const matrix_type &tableau) |
| Attempts to solve the linear complementarity problem using Lemke's Algorithm. If successful, this method stores the z vector into the output parameter. More...
|
|
static bool | solve (matrix_type &out, const matrix_type &m, const matrix_type &q) |
| Attempts to solve the linear complementarity problem using Lemke's Algorithm. If successful, this method stores the z vector into the output parameter. More...
|
|
static bool | solve (matrix_type &out, const matrix_type &q, const matrix_type &a, const matrix_type &c, const matrix_type &b) |
| Attempts to solve the linear complementarity problem using Lemke's Algorithm. If successful, this method stores the z vector into the output parameter. More...
|
|
|
static constexpr auto | invalid_index |
| The value associated with an invalid or unassigned index. More...
|
|
template<typename TValue>
class jade::basic_lemke< TValue >
A template for a class that implements Lemke's algorithm.
Definition at line 18 of file jade.lemke.hpp.
◆ labels_type
template<typename TValue >
◆ matrix_type
template<typename TValue >
◆ state_type
template<typename TValue >
◆ value_type
template<typename TValue >
◆ basic_lemke() [1/3]
template<typename TValue >
Initializes a new instance of the class based on the specified tableau.
- Parameters
-
Definition at line 81 of file jade.lemke.hpp.
89 assert(tableau.get_height() > 0);
90 assert(tableau.get_width() == tableau.get_height() * 2 + 2);
92 const auto & t = _tableau;
94 const auto z0 = n + n;
100 for (
size_t i = 0; i < n; i++)
101 _labels.push_back(i);
108 if (!_find_initial_pivot_row())
◆ basic_lemke() [2/3]
template<typename TValue >
Initializes a new instance of the class based on the specified M and Q matrices.
- Parameters
-
m | The M matrix. |
q | The Q matrix. |
Definition at line 116 of file jade.lemke.hpp.
◆ basic_lemke() [3/3]
template<typename TValue >
Initializes a new instance of the class based on the specified Q and A matrices and c and b vectors.
- Parameters
-
q | The Q matrix. |
a | The A matrix. |
c | The c vector. |
b | The b vector. |
Definition at line 127 of file jade.lemke.hpp.
◆ format_label()
template<typename TValue >
- Returns
- The specified label index as a string; labels are formatted as w_1, w_2, ..., w_n; z_0, z_1, ..., z_n; or q.
- Parameters
-
label | The label to format. |
Definition at line 140 of file jade.lemke.hpp.
144 const auto & t = _tableau;
147 const auto z0 = n + n;
148 const auto q = n + n + 1;
150 std::ostringstream out;
151 if (label < z1) out <<
"w_" << label + 1;
152 else if (label < z0) out <<
"z_" << label + 1 - n;
153 else if (label == z0) out <<
"z_0";
154 else if (label == q) out <<
"q";
◆ get_labels()
template<typename TValue >
◆ get_output()
template<typename TValue >
- Returns
- The output.
Definition at line 170 of file jade.lemke.hpp.
172 const auto & t = _tableau;
175 const auto q = n + n + 1;
179 for (
size_t i = 0; i < n; i++)
181 const auto label = _labels[i];
183 out[label - z1] = t(i, q);
◆ get_pivot_col()
template<typename TValue >
- Returns
- The pivot column, or invalid_index if the algorithm has terminated.
Definition at line 193 of file jade.lemke.hpp.
◆ get_pivot_row()
template<typename TValue >
- Returns
- The pivot row, or invalid_index if the algorithm has terminated.
Definition at line 202 of file jade.lemke.hpp.
◆ get_state()
template<typename TValue >
◆ get_tableau()
template<typename TValue >
◆ is_executing()
template<typename TValue >
- Returns
- True if the algorithm is still executing; otherwise, false.
Definition at line 226 of file jade.lemke.hpp.
◆ iterate()
template<typename TValue >
Performs one step of the algorithm.
- Returns
- True if the still executing; otherwise, false.
Definition at line 235 of file jade.lemke.hpp.
246 if (!_find_pivot_row())
◆ solve() [1/4]
template<typename TValue >
Executes the algorithm until it has completed or has aborted.
- Returns
- True if completed; otherwise, false.
Definition at line 256 of file jade.lemke.hpp.
◆ solve() [2/4]
template<typename TValue >
Attempts to solve the linear complementarity problem using Lemke's Algorithm. If successful, this method stores the z vector into the output parameter.
- Returns
- True if successful; otherwise, false.
- Parameters
-
out | The output vector. |
m | The M matrix. |
q | The q vector. |
Definition at line 290 of file jade.lemke.hpp.
295 return solve(out, _create_tableau(m, q));
◆ solve() [3/4]
template<typename TValue >
Attempts to solve the linear complementarity problem using Lemke's Algorithm. If successful, this method stores the z vector into the output parameter.
- Returns
- True if successful; otherwise, false.
- Parameters
-
out | The output vector. |
q | The Q matrix. |
a | The A matrix. |
c | The c vector. |
b | The b vector. |
Definition at line 305 of file jade.lemke.hpp.
312 return solve(out, _create_tableau(q, a, c, b));
◆ solve() [4/4]
template<typename TValue >
Attempts to solve the linear complementarity problem using Lemke's Algorithm. If successful, this method stores the z vector into the output parameter.
- Returns
- True if successful; otherwise, false.
- Parameters
-
out | The output vector. |
tableau | The tableau. |
Definition at line 271 of file jade.lemke.hpp.
279 out = lemke.get_output();
◆ str()
template<typename TValue >
- Returns
- A string representation of the class.
Definition at line 318 of file jade.lemke.hpp.
320 const auto & t = _tableau;
322 const auto q = n + n + 1;
324 static const size_t cx = 8;
325 std::ostringstream out;
326 out << std::setprecision(3)
327 << std::setw(cx) <<
"BV";
329 for (
size_t j = 0; j <= q; j++)
333 for (
size_t i = 0; i < n; i++)
336 for (
size_t j = 0; j <= q; j++)
337 out << std::setw(cx) << t(i, j);
342 <<
"state: " <<
state::str(_state) << std::endl
351 out << std::endl << std::endl;
◆ invalid_index
template<typename TValue >
Initial value:=
std::numeric_limits<size_t>::max()
The value associated with an invalid or unassigned index.
Definition at line 24 of file jade.lemke.hpp.
The documentation for this class was generated from the following file: