1 |
#ifndef ASCXX_SIMULATION_H |
2 |
#define ASCXX_SIMULATION_H |
3 |
|
4 |
#include <string> |
5 |
#include <vector> |
6 |
#include <map> |
7 |
|
8 |
#include "symchar.h" |
9 |
#include "type.h" |
10 |
#include "instance.h" |
11 |
|
12 |
class Variable; |
13 |
|
14 |
extern "C"{ |
15 |
#include <compiler/createinst.h> |
16 |
#include <solver/slv_types.h> |
17 |
} |
18 |
|
19 |
class Solver; |
20 |
class SolverParameters; |
21 |
class SolverStatus; |
22 |
class IncidenceMatrix; |
23 |
class SolverReporter; |
24 |
|
25 |
/** |
26 |
@TODO This class is for *Simulation* instances. |
27 |
|
28 |
Handle instantiating, running initialisation functions, solving |
29 |
and outputing results of solutions. |
30 |
|
31 |
In ASCEND C-code, a simulation is a special type of Instance. It |
32 |
has a 'simulation root' instance which often needs to be used for |
33 |
solving, inspecting, etc, rather than the simulation instance itself. |
34 |
*/ |
35 |
class Simulation : public Instanc{ |
36 |
friend class IncidenceMatrix; |
37 |
friend class SolverStatus; |
38 |
|
39 |
private: |
40 |
Instanc simroot; |
41 |
slv_system_structure *sys; |
42 |
bool is_built; |
43 |
|
44 |
// options to pass to BinTokenSetOptions |
45 |
/// TODO these should probably be put somewhere else |
46 |
std::string *bin_srcname; |
47 |
std::string *bin_objname; |
48 |
std::string *bin_libname; |
49 |
std::string *bin_cmd; |
50 |
std::string *bin_rm; |
51 |
|
52 |
int activeblock; |
53 |
|
54 |
protected: |
55 |
slv_system_structure *getSystem(); |
56 |
|
57 |
public: |
58 |
explicit Simulation(Instance *i, const SymChar &name); |
59 |
Simulation(const Simulation &); |
60 |
~Simulation(); |
61 |
|
62 |
Instanc &getModel(); |
63 |
void run(const Method &method); |
64 |
void checkDoF() const; |
65 |
const bool check(); |
66 |
void build(); |
67 |
void solve(Solver s, SolverReporter &reporter); |
68 |
std::vector<Variable> getFixableVariables(); |
69 |
std::vector<Variable> getVariablesNearBounds(const double &epsilon=1e-4); |
70 |
|
71 |
void write(); |
72 |
|
73 |
void setSolver(Solver &s); |
74 |
const Solver getSolver() const; |
75 |
|
76 |
SolverParameters getSolverParameters() const; |
77 |
void setSolverParameters(SolverParameters &); |
78 |
|
79 |
IncidenceMatrix getIncidenceMatrix(); |
80 |
|
81 |
const std::string getInstanceName(const Instanc &) const; |
82 |
|
83 |
void processVarStatus(); |
84 |
const int getNumVars(); |
85 |
|
86 |
const int getActiveBlock() const; |
87 |
|
88 |
void checkConsistency() const; |
89 |
void checkStructuralSingularity() const; |
90 |
}; |
91 |
|
92 |
|
93 |
#endif |