1 |
#ifndef ASCXX_INCIDENCEMATRIX_H |
2 |
#define ASCXX_INCIDENCEMATRIX_H |
3 |
|
4 |
#include <vector> |
5 |
|
6 |
#include "variable.h" |
7 |
#include "relation.h" |
8 |
#include "simulation.h" |
9 |
|
10 |
#include "config.h" |
11 |
extern "C"{ |
12 |
#include <solver/incidence.h> |
13 |
} |
14 |
|
15 |
typedef enum{ |
16 |
IM_NULL=0, IM_ACTIVE_FIXED, IM_ACTIVE_FREE, IM_DORMANT_FIXED, IM_DORMANT_FREE |
17 |
} IncidencePointType; |
18 |
|
19 |
class IncidencePoint{ |
20 |
public: |
21 |
IncidencePoint(const int&row, const int&col, const IncidencePointType &type); |
22 |
IncidencePoint(const IncidencePoint &); |
23 |
IncidencePoint(); |
24 |
|
25 |
int row; |
26 |
int col; |
27 |
IncidencePointType type; |
28 |
}; |
29 |
|
30 |
/** |
31 |
Special class for plotting incidence matrices using matplotlib |
32 |
|
33 |
GOAL: facilitate use of pylab 'spy2' function, but hopefully add extra |
34 |
stuff for viewing blocks and fixed/free incidences, solved/active/unsolved |
35 |
variables, etc. |
36 |
|
37 |
This is going to be like a C++ified copy of MtxProc.c |
38 |
*/ |
39 |
class IncidenceMatrix{ |
40 |
|
41 |
private: |
42 |
Simulation ∼ |
43 |
slv_system_structure *sys; |
44 |
|
45 |
std::vector<IncidencePoint> data; |
46 |
incidence_vars_t i; |
47 |
bool is_built; |
48 |
|
49 |
void buildPlotData(); |
50 |
public: |
51 |
explicit IncidenceMatrix(Simulation &sim); |
52 |
~IncidenceMatrix(); |
53 |
|
54 |
const std::vector<IncidencePoint> &getIncidenceData(); |
55 |
const int &getNumRows() const; |
56 |
const int &getNumCols() const; |
57 |
const Variable getVariable(const int &row) const; |
58 |
const Relation getRelation(const int &col) const; |
59 |
const int getBlockRow(const int & row) const; |
60 |
const std::vector<Variable> getBlockVars(const int &block); |
61 |
const std::vector<Relation> getBlockRels(const int &block); |
62 |
const std::vector<int> getBlockLocation(const int &block) const; |
63 |
const int getNumBlocks(); |
64 |
#ifdef ASC_WITH_MFGRAPH |
65 |
void writeGraph(std::ostream &,const int &block) const; |
66 |
#endif; |
67 |
}; |
68 |
|
69 |
#endif // ASCXX_INCIDENCEMATRIX_H |