1 |
/* |
2 |
SWIG interface for accessing Solver and choosing solver parameters |
3 |
*/ |
4 |
|
5 |
class Solver{ |
6 |
public: |
7 |
Solver(const std::string &name); |
8 |
Solver(const Solver &); |
9 |
|
10 |
const int &getIndex() const; |
11 |
const std::string getName() const; |
12 |
}; |
13 |
|
14 |
class Simulation : public Instanc{ |
15 |
public: |
16 |
Simulation(Instance *&, const SymChar &name); |
17 |
Instanc &getModel(); |
18 |
std::vector<Variable> getFixableVariables(); |
19 |
void build(); |
20 |
const bool check(); |
21 |
void checkDoF() const; |
22 |
void run(const Method &); |
23 |
void setSolver(Solver&); |
24 |
const Solver getSolver() const; |
25 |
void solve(Solver s); |
26 |
SolverParameters getSolverParameters() const; |
27 |
void setSolverParameters(SolverParameters&); |
28 |
|
29 |
IncidenceMatrix getIncidenceMatrix(); |
30 |
}; |
31 |
|
32 |
// SOLVE PARAMETERS |
33 |
|
34 |
%pythoncode{ |
35 |
class SolverParameterIter: |
36 |
def __init__(self, params): |
37 |
self.params = params; |
38 |
self.index = 0; |
39 |
|
40 |
def next(self): |
41 |
self.index = self.index + 1 |
42 |
if self.index >= self.params.getLength(): |
43 |
raise StopIteration |
44 |
return self.params.getParameter(self.index) |
45 |
} |
46 |
|
47 |
class SolverParameters{ |
48 |
public: |
49 |
const std::string toString(); |
50 |
SolverParameters(const SolverParameters &); |
51 |
const int getLength() const; |
52 |
SolverParameter getParameter(const int &) const; |
53 |
}; |
54 |
|
55 |
%extend SolverParameters{ |
56 |
%pythoncode{ |
57 |
def __iter__(self): |
58 |
return SolverParameterIter(self) |
59 |
def getitem(self,index): |
60 |
return |
61 |
} |
62 |
} |
63 |
|
64 |
class SolverParameter{ |
65 |
public: |
66 |
explicit SolverParameter(slv_parameter *); |
67 |
|
68 |
const std::string getName() const; |
69 |
const std::string getDescription() const; |
70 |
const std::string getLabel() const; |
71 |
const int &getNumber() const; |
72 |
const int &getPage() const; |
73 |
|
74 |
const bool isInt() const; |
75 |
const bool isBool() const; |
76 |
const bool isStr() const; |
77 |
const bool isReal() const; |
78 |
|
79 |
// The following throw execeptions unless the parameter type is correct |
80 |
const int &getIntValue() const; |
81 |
const int &getIntLowerBound() const; |
82 |
const int &getIntUpperBound() const; |
83 |
void setIntValue(const int&); |
84 |
|
85 |
const bool getBoolValue() const; |
86 |
void setBoolValue(const bool&); |
87 |
|
88 |
const std::string getStrValue() const; |
89 |
const std::vector<std::string> getStrOptions() const; |
90 |
void setStrValue(const std::string &); |
91 |
void setStrOption(const int &opt); |
92 |
|
93 |
const double &getRealValue() const; |
94 |
const double &getRealLowerBound() const; |
95 |
const double &getRealUpperBound() const; |
96 |
void setRealValue(const double&); |
97 |
|
98 |
const bool isBounded() const; |
99 |
|
100 |
const std::string toString() const; |
101 |
}; |
102 |
|
103 |
/* Incidence matrix stuff */ |
104 |
typedef enum{ |
105 |
IM_NULL=0, IM_ACTIVE_FIXED, IM_ACTIVE_FREE, IM_DORMANT_FIXED, IM_DORMANT_FREE |
106 |
} IncidencePointType; |
107 |
|
108 |
|
109 |
class IncidencePoint{ |
110 |
public: |
111 |
IncidencePoint(const IncidencePoint &); |
112 |
|
113 |
int row; |
114 |
int col; |
115 |
IncidencePointType type; |
116 |
}; |
117 |
|
118 |
%extend IncidencePoint{ |
119 |
%pythoncode{ |
120 |
def __repr__(self): |
121 |
return str([ self.row, self.col, int(self.type) ]); |
122 |
} |
123 |
} |
124 |
|
125 |
%template(IncidencePointVector) std::vector<IncidencePoint>; |
126 |
|
127 |
class IncidenceMatrix{ |
128 |
public: |
129 |
explicit IncidenceMatrix(Simulation &); |
130 |
const std::vector<IncidencePoint> &getIncidenceData(); |
131 |
}; |