PolyDiM
C++ library for POLYtopal DIscretization Methods
Loading...
Searching...
No Matches
LPUtilities.hpp
Go to the documentation of this file.
1// _LICENSE_HEADER_
2//
3// Copyright (C) 2019 - 2025.
4// Terms register on the GPL-3.0 license.
5//
6// This file can be redistributed and/or modified under the license terms.
7//
8// See top level LICENSE file for more details.
9//
10// This file can be used citing references in CITATION.cff file.
11
12#ifndef __LPUtilties_HPP
13#define __LPUtilties_HPP
14
15#include "Eigen/Eigen"
16#include <stdlib.h>
17
18namespace Gedim
19{
20namespace LPUtilties
21{
22
27struct Simplex
28{
30 {
31 enum struct ExitValue
32 {
33 SUCCESS = 1, // success
34 UNBOUNDED = 2, // primal is unbounded
35 NOSLACK = 3, // no starting basis
36 MAXIT = 4
37 };
38
39 Eigen::VectorXd solution;
40 double cost_value;
41
42 Eigen::VectorXd solution_final;
43
45 };
46
47 enum struct ConstraintType
48 {
49 GE = 1, // greater or equal
50 EQ = 2, // equality
51 LE = 3, // lower or equal
52 };
53
54 unsigned int m; // num constraints
55 unsigned int n; // num variables
56
57 Eigen::VectorXd cost_vector; // cost functional
58 Eigen::MatrixXd A; // matrix constraints
59 Eigen::VectorXd b; // rhs constraints
60 std::vector<ConstraintType> constraint_types;
61 Eigen::VectorXd LB; // lower bound, std::nan("") means free
62 Eigen::VectorXd UB; // upper bound, std::nan("") means free
63
64 double trasl_cost;
65 Eigen::VectorXd trasl_sol;
66 Eigen::VectorXd sign_sol;
67 Eigen::MatrixXd map_sol;
68
69 unsigned int m_final; // num final equality constraint after preprocessing
70 unsigned int n_final; // num final variables after preprocessing
71 Eigen::MatrixXd A_final; // matrix constraints after preprocessing
72 Eigen::VectorXd b_final; // rhs constraints after preprocessing
73 Eigen::VectorXd cost_vector_final; // cost functional after preprocessing
74
75 std::vector<unsigned int> slack_indices;
76 std::vector<unsigned int> no_slack_indices;
77
79
80 Simplex(const unsigned int n_data,
81 const Eigen::VectorXd &cost_vector_data,
82 const Eigen::MatrixXd &A_data,
83 const Eigen::VectorXd &b_data,
84 const std::vector<ConstraintType> &constraint_types_data,
85 const Eigen::VectorXd &LB_data,
86 const Eigen::VectorXd &UB_data);
87
88 void solve_primal_simplex(std::vector<unsigned int> &basis,
89 std::vector<unsigned int> &no_basis,
90 const unsigned int max_iteration = 1000,
91 const double &tolerance = 1.0e-12);
92};
93
94} // namespace LPUtilties
95} // namespace Gedim
96
97#endif
Eigen column vector.
Definition Eigen_Array.hpp:23
Definition Eigen_Array.cpp:22
Definition LPUtilities.hpp:30
Eigen::VectorXd solution_final
Definition LPUtilities.hpp:42
ExitValue exit_value
Definition LPUtilities.hpp:44
ExitValue
Definition LPUtilities.hpp:32
double cost_value
Definition LPUtilities.hpp:40
Eigen::VectorXd solution
Definition LPUtilities.hpp:39
Definition LPUtilities.hpp:28
Eigen::MatrixXd map_sol
Definition LPUtilities.hpp:67
Eigen::VectorXd cost_vector_final
Definition LPUtilities.hpp:73
unsigned int n
Definition LPUtilities.hpp:55
std::vector< unsigned int > slack_indices
Definition LPUtilities.hpp:75
Eigen::VectorXd b
Definition LPUtilities.hpp:59
Eigen::MatrixXd A_final
Definition LPUtilities.hpp:71
Eigen::MatrixXd A
Definition LPUtilities.hpp:58
Eigen::VectorXd b_final
Definition LPUtilities.hpp:72
Eigen::VectorXd LB
Definition LPUtilities.hpp:61
Eigen::VectorXd sign_sol
Definition LPUtilities.hpp:66
Eigen::VectorXd cost_vector
Definition LPUtilities.hpp:57
std::vector< ConstraintType > constraint_types
Definition LPUtilities.hpp:60
void solve_primal_simplex(std::vector< unsigned int > &basis, std::vector< unsigned int > &no_basis, const unsigned int max_iteration=1000, const double &tolerance=1.0e-12)
Definition LPUtilities.cpp:145
double trasl_cost
Definition LPUtilities.hpp:64
PrimalResult result
Definition LPUtilities.hpp:78
unsigned int m
Definition LPUtilities.hpp:54
std::vector< unsigned int > no_slack_indices
Definition LPUtilities.hpp:76
Eigen::VectorXd UB
Definition LPUtilities.hpp:62
Eigen::VectorXd trasl_sol
Definition LPUtilities.hpp:65
unsigned int n_final
Definition LPUtilities.hpp:70
ConstraintType
Definition LPUtilities.hpp:48
unsigned int m_final
Definition LPUtilities.hpp:69