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 |
const std::string getInstanceName(const Instanc &) const; |
31 |
}; |
32 |
|
33 |
// SOLVE PARAMETERS |
34 |
|
35 |
%pythoncode{ |
36 |
class SolverParameterIter: |
37 |
def __init__(self, params): |
38 |
self.params = params; |
39 |
self.index = 0; |
40 |
|
41 |
def next(self): |
42 |
self.index = self.index + 1 |
43 |
if self.index >= self.params.getLength(): |
44 |
raise StopIteration |
45 |
return self.params.getParameter(self.index) |
46 |
} |
47 |
|
48 |
class SolverParameters{ |
49 |
public: |
50 |
const std::string toString(); |
51 |
SolverParameters(const SolverParameters &); |
52 |
const int getLength() const; |
53 |
SolverParameter getParameter(const int &) const; |
54 |
}; |
55 |
|
56 |
%extend SolverParameters{ |
57 |
%pythoncode{ |
58 |
def __iter__(self): |
59 |
return SolverParameterIter(self) |
60 |
def getitem(self,index): |
61 |
return |
62 |
} |
63 |
} |
64 |
|
65 |
class SolverParameter{ |
66 |
public: |
67 |
explicit SolverParameter(slv_parameter *); |
68 |
|
69 |
const std::string getName() const; |
70 |
const std::string getDescription() const; |
71 |
const std::string getLabel() const; |
72 |
const int &getNumber() const; |
73 |
const int &getPage() const; |
74 |
|
75 |
const bool isInt() const; |
76 |
const bool isBool() const; |
77 |
const bool isStr() const; |
78 |
const bool isReal() const; |
79 |
|
80 |
// The following throw execeptions unless the parameter type is correct |
81 |
const int &getIntValue() const; |
82 |
const int &getIntLowerBound() const; |
83 |
const int &getIntUpperBound() const; |
84 |
void setIntValue(const int&); |
85 |
|
86 |
const bool getBoolValue() const; |
87 |
void setBoolValue(const bool&); |
88 |
|
89 |
const std::string getStrValue() const; |
90 |
const std::vector<std::string> getStrOptions() const; |
91 |
void setStrValue(const std::string &); |
92 |
void setStrOption(const int &opt); |
93 |
|
94 |
const double &getRealValue() const; |
95 |
const double &getRealLowerBound() const; |
96 |
const double &getRealUpperBound() const; |
97 |
void setRealValue(const double&); |
98 |
|
99 |
const bool isBounded() const; |
100 |
|
101 |
const std::string toString() const; |
102 |
}; |
103 |
|
104 |
/* Incidence matrix stuff */ |
105 |
typedef enum{ |
106 |
IM_NULL=0, IM_ACTIVE_FIXED, IM_ACTIVE_FREE, IM_DORMANT_FIXED, IM_DORMANT_FREE |
107 |
} IncidencePointType; |
108 |
|
109 |
|
110 |
class IncidencePoint{ |
111 |
public: |
112 |
IncidencePoint(const IncidencePoint &); |
113 |
|
114 |
int row; |
115 |
int col; |
116 |
IncidencePointType type; |
117 |
}; |
118 |
|
119 |
%extend IncidencePoint{ |
120 |
%pythoncode{ |
121 |
def __repr__(self): |
122 |
return str([ self.row, self.col, int(self.type) ]); |
123 |
} |
124 |
} |
125 |
|
126 |
%template(IncidencePointVector) std::vector<IncidencePoint>; |
127 |
|
128 |
class IncidenceMatrix{ |
129 |
public: |
130 |
explicit IncidenceMatrix(Simulation &); |
131 |
const std::vector<IncidencePoint> &getIncidenceData(); |
132 |
const int &getNumRows() const; |
133 |
const int &getNumCols() const; |
134 |
const Variable getVariable(const int &col); |
135 |
const Relation getRelation(const int &col); |
136 |
const int getBlockRow(const int &row) const; |
137 |
}; |