/[ascend]/trunk/pygtk/interface/solver.i
ViewVC logotype

Contents of /trunk/pygtk/interface/solver.i

Parent Directory Parent Directory | Revision Log Revision Log


Revision 290 - (show annotations) (download)
Fri Feb 10 03:30:05 2006 UTC (18 years, 4 months ago) by johnpye
File size: 4114 byte(s)
Fixable vars added to interface (outputs to console)
Added 'next big' and 'prev big' to move between 'big blocks' in the diagnose window.
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 void processVarStatus();
33 const int getActiveBlock() const;
34 };
35
36 // SOLVE PARAMETERS
37
38 %pythoncode{
39 class SolverParameterIter:
40 def __init__(self, params):
41 self.params = params;
42 self.index = 0;
43
44 def next(self):
45 self.index = self.index + 1
46 if self.index >= self.params.getLength():
47 raise StopIteration
48 return self.params.getParameter(self.index)
49 }
50
51 class SolverParameters{
52 public:
53 const std::string toString();
54 SolverParameters(const SolverParameters &);
55 const int getLength() const;
56 SolverParameter getParameter(const int &) const;
57 };
58
59 %extend SolverParameters{
60 %pythoncode{
61 def __iter__(self):
62 return SolverParameterIter(self)
63 def getitem(self,index):
64 return
65 }
66 }
67
68 class SolverParameter{
69 public:
70 explicit SolverParameter(slv_parameter *);
71
72 const std::string getName() const;
73 const std::string getDescription() const;
74 const std::string getLabel() const;
75 const int &getNumber() const;
76 const int &getPage() const;
77
78 const bool isInt() const;
79 const bool isBool() const;
80 const bool isStr() const;
81 const bool isReal() const;
82
83 // The following throw execeptions unless the parameter type is correct
84 const int &getIntValue() const;
85 const int &getIntLowerBound() const;
86 const int &getIntUpperBound() const;
87 void setIntValue(const int&);
88
89 const bool getBoolValue() const;
90 void setBoolValue(const bool&);
91
92 const std::string getStrValue() const;
93 const std::vector<std::string> getStrOptions() const;
94 void setStrValue(const std::string &);
95 void setStrOption(const int &opt);
96
97 const double &getRealValue() const;
98 const double &getRealLowerBound() const;
99 const double &getRealUpperBound() const;
100 void setRealValue(const double&);
101
102 const bool isBounded() const;
103
104 const std::string toString() const;
105 };
106
107 /* Incidence matrix stuff */
108 typedef enum{
109 IM_NULL=0, IM_ACTIVE_FIXED, IM_ACTIVE_FREE, IM_DORMANT_FIXED, IM_DORMANT_FREE
110 } IncidencePointType;
111
112 class IncidencePoint{
113 public:
114 IncidencePoint(const IncidencePoint &);
115
116 int row;
117 int col;
118 IncidencePointType type;
119 };
120
121 %extend IncidencePoint{
122 %pythoncode{
123 def __repr__(self):
124 return str([ self.row, self.col, int(self.type) ]);
125 }
126 }
127
128 %template(IncidencePointVector) std::vector<IncidencePoint>;
129
130 class IncidenceMatrix{
131 public:
132 explicit IncidenceMatrix(Simulation &);
133 const std::vector<IncidencePoint> &getIncidenceData();
134 const int &getNumRows() const;
135 const int &getNumCols() const;
136 const Variable getVariable(const int &col);
137 const Relation getRelation(const int &col);
138 const int getBlockRow(const int &row) const;
139 const std::vector<Variable> getBlockVars(const int block);
140 const std::vector<Relation> getBlockRels(const int block);
141 const std::vector<int> getBlockLocation(const int &block) const;
142 const int getNumBlocks();
143 };
144
145
146 /* Variables and relations belong to solvers, so they're here: */
147
148 class Variable{
149 public:
150 explicit Variable(const Variable &old);
151 const std::string &getName() const;
152 const double getValue() const;
153 const double getNominal() const;
154 const double getLowerBound() const;
155 const double getUpperBound() const;
156 };
157
158 %extend Variable {
159 %pythoncode{
160 def __repr__(self):
161 return self.getName()
162 }
163 }
164
165 class Relation{
166 public:
167 explicit Relation(const Relation &old);
168 const std::string &getName();
169 const double &getResidual();
170 };
171
172 %extend Relation {
173 %pythoncode{
174 def __repr__(self):
175 return self.getName()
176 }
177 }

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22