ExactConstraintSatisfaction.hh 2.65 KB
Newer Older
1
2
3
4
#ifndef EXACTCONSTRAINTSATISFACTION_HH
#define EXACTCONSTRAINTSATISFACTION_HH

#include <CoMISo/Config/config.hh>
Robin Brost's avatar
Robin Brost committed
5
#include <CoMISo/Config/CoMISoDefines.hh>
6
7
8

#include <CoMISo/NSolver/NProblemInterface.hh>
#include <vector>
9
#include <list>
10
#include <time.h>
11

Robin Brost's avatar
Robin Brost committed
12
class COMISODLLEXPORT ExactConstraintSatisfaction
13
14
15
16
{
public:
    ExactConstraintSatisfaction();

17
    typedef Eigen::SparseVector<int>::InnerIterator iteratorV;
18
19
20
    typedef Eigen::SparseVector<int> sparseVec;
    typedef Eigen::SparseMatrix<int, Eigen::ColMajor> SP_Matrix_C;
    typedef Eigen::SparseMatrix<int, Eigen::RowMajor> SP_Matrix_R;
21
22

    //-----------------------helpfull methods---------------------------------
23
24
    void   print_matrix(const Eigen::SparseMatrix<int, Eigen::RowMajor> A);
    void   print_vector(Eigen::VectorXi b);
25
26


Robin Brost's avatar
Robin Brost committed
27
    int    gcd(const int a, const int b);
28
29
    int    gcd_row(const Eigen::SparseVector<int> row, const int b);

Robin Brost's avatar
Robin Brost committed
30
    int    lcm(const int a, const int b);
31
    int    lcm(const std::vector<int>& D);
32

33
34
    void   swap_rows(SP_Matrix_R& mat,  int row1, int row2);
    void   eliminate_row(SP_Matrix_R& mat, int row1, int row2, int pivot_column);
35
    int    largest_exponent(const Eigen::VectorXd& x);
36
    int    index_pivot(const sparseVec& row);
Robin Brost's avatar
Robin Brost committed
37
    double F_delta(double x);
38
    double get_delta();
Robin Brost's avatar
Robin Brost committed
39

40
41
    //--------------------matrix transformation-------------------------------

42
43
    void   IREF_Gaussian(SP_Matrix_R& A, Eigen::VectorXi& b, const Eigen::VectorXd x);
    void   IRREF_Jordan(SP_Matrix_R& A, Eigen::VectorXi& b);
44
45
46

    //-------------------Evaluation--------------------------------------------

47
    void   evaluation(SP_Matrix_R& _A, Eigen::VectorXi& b, Eigen::VectorXd& x, const Eigen::VectorXd values);
48
    double makeDiv(const std::vector<int>& D, double x);
49
    double safeDot(const std::vector<std::pair<int, double> >& S);
50
51
52

private:

53
54
    // for evaluation

55
56
57
    int get_pivot_row_student(const SP_Matrix_C& A, int col);
    int get_pivot_row_new(const SP_Matrix_C& A, const SP_Matrix_R& _A, int col);

58
59
60
    std::vector<int> get_divisors_student(const SP_Matrix_C& A, int col);
    std::vector<int> get_divisors_new(const SP_Matrix_C& A, const SP_Matrix_R& _A, int col);

61
62
63
    std::vector<std::pair<int, double>> get_dot_product_elements_student(const SP_Matrix_C& A, const Eigen::VectorXd& x, int k, int pivot_row);
    std::vector<std::pair<int, double>> get_dot_product_elements_new(const SP_Matrix_R& A, const Eigen::VectorXd& x, int pivot_row);

64
65
    //-----------------------helpfull variables-------------------------------

Robin Brost's avatar
Robin Brost committed
66
67
68
    int    number_pivots_ = 0; //number of rows with a pivot;
    int    largest_exponent_ = 0;
    double delta_ = 0;
69
70
71
};

#endif // EXACTCONSTRAINTSATISFACTION_HH