/[ascend]/trunk/pygtk/solverstatus.cpp
ViewVC logotype

Contents of /trunk/pygtk/solverstatus.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1549 - (show annotations) (download) (as text)
Mon Jul 23 14:30:35 2007 UTC (12 years, 11 months ago) by jpye
File MIME type: text/x-c++src
File size: 2142 byte(s)
More work on IPOPT optimizer.
Prevented repeated slv_get_status errors; added exception in getSimulationStatus in C++.
1 #include "solverstatus.h"
2 #include "simulation.h"
3
4 #include <stdexcept>
5
6 extern "C"{
7 #include <solver/solver.h>
8 }
9
10 SolverStatus::SolverStatus(){
11 // do nothing else
12 }
13
14 SolverStatus::SolverStatus(const SolverStatus &old) : s(old.s){
15 // just that
16 }
17
18 void
19 SolverStatus::getSimulationStatus(Simulation &sim){
20 int res = slv_get_status(sim.getSystem(), &s);
21 if(res)throw std::runtime_error("Error requesting solver status");
22 }
23
24 const bool
25 SolverStatus::isOK() const{
26 return s.ok;
27 }
28
29 const bool
30 SolverStatus::isOverDefined() const{
31 return s.over_defined!=0;
32 }
33
34 const bool
35 SolverStatus::isUnderDefined() const{
36 return s.under_defined!=0;
37 }
38
39 const bool
40 SolverStatus::isStructurallySingular() const{
41 return s.struct_singular!=0;
42 }
43
44 const bool
45 SolverStatus::isReadyToSolve() const{
46 return s.ready_to_solve!=0;
47 }
48
49 const bool
50 SolverStatus::isConverged() const{
51 return s.converged!=0;
52 }
53 const bool
54 SolverStatus::isDiverged() const{
55 return s.diverged!=0;
56 }
57
58 const bool
59 SolverStatus::isInconsistent() const{
60 return s.inconsistent!=0;
61 }
62
63 const bool
64 SolverStatus::hasResidualCalculationErrors() const{
65 return s.calc_ok!=0;
66 }
67
68 const bool
69 SolverStatus::hasExceededIterationLimit() const{
70 return s.iteration_limit_exceeded!=0;
71 }
72 const bool
73 SolverStatus::hasExceededTimeLimit() const{
74 return s.time_limit_exceeded!=0;
75 }
76
77 const bool
78 SolverStatus::isInterrupted() const{
79 return s.panic!=0;
80 }
81
82 const int
83 SolverStatus::getIterationNum() const{
84 return s.iteration;
85 }
86
87 // block stuff....
88
89 const int
90 SolverStatus::getNumBlocks() const{
91 return s.block.number_of;
92 }
93
94 const int
95 SolverStatus::getCurrentBlockNum() const{
96 return s.block.current_block;
97 }
98 const int
99 SolverStatus::getCurrentBlockSize() const{
100 return s.block.current_size;
101 }
102 const int
103 SolverStatus::getCurrentBlockIteration() const{
104 return s.block.iteration;
105 }
106
107 const int
108 SolverStatus::getNumConverged() const{
109 return s.block.previous_total_size;
110 }
111 const int
112 SolverStatus::getNumJacobianEvals() const{
113 return s.block.jacs;
114 }
115 const int
116 SolverStatus::getNumResidualEvals() const{
117 return s.block.funcs;
118 }
119
120 const double
121 SolverStatus::getBlockResidualRMS() const{
122 return s.block.residual;
123 }
124
125

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