1 |
/* ASCEND modelling environment |
2 |
Copyright (C) 2006 Carnegie Mellon University |
3 |
Copyright (C) 1996 Benjamin Andrew Allan |
4 |
|
5 |
This program is free software; you can redistribute it and/or modify |
6 |
it under the terms of the GNU General Public License as published by |
7 |
the Free Software Foundation; either version 2, or (at your option) |
8 |
any later version. |
9 |
|
10 |
This program is distributed in the hope that it will be useful, |
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
GNU General Public License for more details. |
14 |
|
15 |
You should have received a copy of the GNU General Public License |
16 |
along with this program; if not, write to the Free Software |
17 |
Foundation, Inc., 59 Temple Place - Suite 330, |
18 |
Boston, MA 02111-1307, USA. |
19 |
*//** @file |
20 |
Problem Analysis Routines. |
21 |
|
22 |
These functions are the start of a new design for feeding |
23 |
solvers from the ASCEND compiler or any arbitrary backend. |
24 |
|
25 |
The intention is that eventually the other code in the solver |
26 |
directory will really be for *solution algorithms* and the |
27 |
definition of a *problem* will come from here. In essence, most |
28 |
of what was solver/system.c will be here. Negotiating directly |
29 |
with the ASCEND instance hierarchy should not be a solver's |
30 |
job. |
31 |
The goal of this module is to CREATE a slv_system_t data structure |
32 |
capable of supporting code generation, an interactive interface, and |
33 |
in-core solvers, while being expandable in the future to out of core |
34 |
solvers/external-process solvers. |
35 |
|
36 |
A secondary goal is to have nonlinear solver files be independent of |
37 |
all the compiler directory files except ascmalloc.h. |
38 |
The present fly in the ointment is expr.h because of the objective fcns. |
39 |
The relman and exprman modules go away because they are indicative of |
40 |
functionality that belongs either in the compiler or rel.c. |
41 |
If we meet this goal, then it is a simple matter to connect any |
42 |
arbitrary compiler backend to the solver API by replacing the rel |
43 |
and var and analyze modules. |
44 |
*//* |
45 |
by Benjamin Andrew Allan 5/19/96 |
46 |
Version: $Revision: 1.10 $ |
47 |
Date last modified: $Date: 1997/07/18 12:13:50 $ |
48 |
Last modified by: $Author: mthomas $ |
49 |
*/ |
50 |
|
51 |
#ifndef ASC_ANALYZE_H |
52 |
#define ASC_ANALYZE_H |
53 |
|
54 |
#include <utilities/config.h> |
55 |
#include <utilities/ascConfig.h> |
56 |
|
57 |
#include <compiler/instance_enum.h> |
58 |
#include "slv_types.h" |
59 |
#include "conditional.h" |
60 |
|
61 |
/** @addtogroup analyse Analyse |
62 |
@{ |
63 |
*/ |
64 |
|
65 |
/** Used to give an integer value to each symbol used in a when */ |
66 |
struct SymbolValues { |
67 |
char *name; |
68 |
int value; |
69 |
}; |
70 |
|
71 |
extern int analyze_make_problem(slv_system_t sys, struct Instance *inst); |
72 |
/**< |
73 |
Takes a system and populates the guts of it from the instance. |
74 |
|
75 |
@NOTE |
76 |
This implementation of analyze is specific to the ASCEND Compiler |
77 |
back end. |
78 |
*/ |
79 |
|
80 |
extern void analyze_free_reused_mem(void); |
81 |
/**< |
82 |
Resets all internal memory recycles. |
83 |
*/ |
84 |
|
85 |
/*------------------------------------------------------------------------------ |
86 |
Stuff for retrieving differential and derivative variables from the system |
87 |
*/ |
88 |
|
89 |
/** |
90 |
Structure that holds a differential variable and the sequence of |
91 |
its derivatives as found explicity in the model. |
92 |
|
93 |
For example, |
94 |
- x, dx/dt |
95 |
*/ |
96 |
typedef struct SolverDiffVarSequenceStruct{ |
97 |
long ode_id; |
98 |
short n; |
99 |
struct var_variable **vars; /* will be in order of ascending ode_type, starting from 1 */ |
100 |
} SolverDiffVarSequence; |
101 |
|
102 |
/** |
103 |
Array of diff var sequences. Once generated, this will hold all of the |
104 |
This would hold all of the differential and derivative variables found |
105 |
in the system. For example, with each row being a SolverDiffVarSequence: |
106 |
- y, dy/dt, d2y/dt2 |
107 |
- x, dx/dt |
108 |
- z, dz/dt |
109 |
*/ |
110 |
typedef struct SolverDiffVarCollectionStruct{ |
111 |
SolverDiffVarSequence *seqs; |
112 |
long n; |
113 |
long maxorder; |
114 |
} SolverDiffVarCollection; |
115 |
|
116 |
#ifdef ASC_IDA_NEW_ANALYSE |
117 |
/** |
118 |
Return the SolverDiffVarCollection for the system. You *don't* own the |
119 |
returned list -- it belongs to the slv_system_t. |
120 |
*/ |
121 |
extern const SolverDiffVarCollection *analyse_get_diffvars(slv_system_t sys); |
122 |
#endif |
123 |
|
124 |
/*------------------------------------------------------------------------------ |
125 |
These routines are in use elsewhere in the solver directory, but we want |
126 |
to get rid of them, as they contain dependencies on the compiler's data |
127 |
structures. |
128 |
*/ |
129 |
|
130 |
extern int varinst_found_in_whenlist(slv_system_t sys, struct Instance *inst); |
131 |
/**< |
132 |
Determine if the conditional variable inst is part of the |
133 |
variable list of some when in the when list of slv_system_t |
134 |
|
135 |
@DEPRECATED we want to get rid of this in order to clean up the |
136 |
solver interface (divorce it from dependencies on compiler) |
137 |
*/ |
138 |
|
139 |
extern int dis_var_in_a_when(struct Instance *var, struct w_when *when); |
140 |
/**< |
141 |
Return 1 if the discrete var is a member of the when var list, else |
142 |
return 0 |
143 |
|
144 |
@DEPRECATED we want to get rid of this in order to clean up the |
145 |
solver interface (divorce it from dependencies on compiler)*/ |
146 |
|
147 |
extern int GetIntFromSymbol(CONST char *symval, struct gl_list_t *symbol_list); |
148 |
/**< |
149 |
Creates the gl_list of SymboValues struct to asign an integer |
150 |
value to a symbol value |
151 |
|
152 |
@DEPRECATED we want to get rid of this in order to clean up the |
153 |
solver interface (divorce it from dependencies on compiler)*/ |
154 |
|
155 |
extern void DestroySymbolValuesList(struct gl_list_t *symbol_list); |
156 |
/**< |
157 |
Destroy the gl_list of SymbolValues struct created to asign an integer |
158 |
value to symbol value |
159 |
|
160 |
@DEPRECATED we want to get rid of this in order to clean up the |
161 |
solver interface (divorce it from dependencies on compiler) |
162 |
*/ |
163 |
|
164 |
/* @} */ |
165 |
|
166 |
#endif /* ASC_ANALYZE_H */ |