/[ascend]/trunk/base/generic/solver/analyse_impl.h
ViewVC logotype

Contents of /trunk/base/generic/solver/analyse_impl.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1202 - (show annotations) (download) (as text)
Mon Jan 22 13:37:33 2007 UTC (16 years, 4 months ago) by johnpye
File MIME type: text/x-chdr
File size: 12507 byte(s)
Rearranged doxygen groups so that stuff that just deals with slv_system_t is in a module called 'system'.
1 /* ASCEND modelling environment
2 Copyright (C) 2007 Carnegie Mellon University
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA.
18 *//** @file
19 Data structures used by the 'analyze.c' implementation. DO NOT include
20 this file unless you are inside the implementation of problem analysis.
21 (so, only analyse.c and diffvars.c, at this stage).
22 */
23
24 #ifndef ASC_ANALYSE_IMPL_H
25 #define ASC_ANALYSE_IMPL_H
26
27 #include "slv_server.h"
28
29 /** @addtogroup system System
30 @{
31 */
32
33 /*-----------------------------------------------------------------------------
34 DATA STRUCTURES FOR USE DURING PROBLEM ANALYSIS
35 */
36
37 struct varip {
38 struct var_variable *data; /* ptr to destination of data */
39 int index; /* master gl index */
40 int incident; /* set 0 in classify_instance, 1 make_master_lists */
41 int in_block; /* set 0 in classify_instance */
42 int fixed; /* set in classify_instance */
43 int solvervar; /* set in classify_instance */
44 int active; /* is this var a part of my problem */
45 int basis; /* set in classify_instance */
46
47 int deriv; /* set in classify_instance */
48 int odeid; /* value loaded from the ode_id child integer atom */
49 int obsid; /* value of obs_id from child integer atom */
50 };
51
52
53 struct disvarip {
54 struct dis_discrete *data; /* ptr to destination of data */
55 int index; /* master gl index */
56 int fixed; /* set in classify_instance */
57 int isconst; /* is this dis var constant ? */
58 int distype; /* 0 boolean, 1 int, -1 symbol */
59 int value; /* integer value of the variable */
60 int incident; /* is it incident in a logrel */
61 int inwhen; /* is it in a when var list */
62 int booleanvar; /* Not sure if I need it */
63 int active; /* is this disvar a part of my problem */
64 };
65
66
67 struct relip {
68 struct rel_relation *data; /* ptr to destination of data */
69 long model; /* relation is in this model in model gllist */
70 /* set in CollectRelsAndWhens. = 1.. nmodels */
71 /* rel_relation models = u.r.model-1 */
72 int index; /* master gl list index */
73 int obj; /* is it an objective relation. set in classify_instance */
74 int ext; /* is it e_blackbox. set in classify_instance */
75 int included; /* set in classify_instance */
76 int cond; /* is it a conditional relation. set in classify_instance */
77 int inwhen; /* is it in a when */
78 int active; /* is this rel a part of my problem */
79 };
80
81 struct logrelip {
82 struct logrel_relation *data; /* ptr to destination of data */
83 long model; /* logrelation is in this model in model gllist */
84 int index; /* master gllist index */
85 int included; /* set in classify_instance */
86 int cond; /* is it a conditional logrelation. */
87 int inwhen; /* is it in a when */
88 int active; /* is this logrel a part of my problem */
89 };
90
91 struct whenip{
92 struct w_when *data; /* ptr to destination of data */
93 long model; /* when is in this model in model gllist */
94 int index; /* master gllist index */
95 int inwhen; /* is it in a when */
96 };
97
98 struct modip {
99 int index; /* set in make master lists. 1..nmodels */
100 int inwhen; /* is it in a when */
101 };
102
103 /* we will decorate the ascend instance tree with these in the interface
104 pointers, but ONLY for the system build process and not persistently.
105 DO NOT EVER UNDER ANY CIRCUMSTANCES EXPORT THIS DATA STRUCTURE.
106 */
107 struct solver_ipdata {
108 struct Instance *i; /* the kind of instance is the enum for union */
109 union {
110 struct modip m;
111 struct varip v;
112 struct disvarip dv;
113 struct relip r;
114 struct logrelip lr;
115 struct whenip w;
116 } u;
117 };
118
119 /* a handy cast for fetching things off gllists */
120 #define SIP(x) ((struct solver_ipdata *)(x))
121
122 /*
123 a bridge buffer used so much we aren't going to free it, just reuse it
124 */
125 static struct reuse_t {
126 size_t ipcap; /* number of ips allocated in ipbuf */
127 size_t ipused; /* number of ips in use */
128 struct solver_ipdata *ipbuf;
129 } g_reuse = {0,0,NULL};
130
131 /**
132 a data structure for bridge-building only. hell of a scaffolding.
133 all fields should be empty if construction is not in progress.
134 In particular, do no operations that can throw an exception
135 while manipulating a problem_t, as it is way too big to let leak.
136
137 We are making the ANSI assumption that this will be init to 0/NULL
138 (K&R 2nd Ed, p 219)
139
140 @TODO what about this one?:
141 container for globals during assembly.
142 At present, the mastervl and solvervl are of the same length. This
143 is purely coincidental and the long run intent is that there is one
144 master list and that a problem coordinator would set up the
145 solver var/rel lists blockwise as we go along. We may want to put
146 block information in the rel/var structures.
147 */
148 struct problem_t {
149
150 /* the following are established by CountStuffInTree */
151 /** @TODO rename these for consistency with eg pars --> npars, vars --> nvars */
152 long nv; /* number of solvervar/solveratom */
153 long np; /* number of real ATOM instance parameters */
154 long nu; /* number of real ATOM instance uninteresting */
155 long ndv; /* number of discrete variables */
156 long nud; /* number of uninteresting discretes */
157 long nc; /* number of conditional relations */
158 long ncl; /* number of conditional logrelations */
159 long nr; /* number of algebraic relations */
160 long no; /* number of objective rels */
161 long nl; /* number of logical rels */
162 long nw; /* number of whens */
163 long ne; /* number of external rels subset overestimate*/
164 long nm; /* number of models */
165 /*
166 The following gllists contain pointers to interface ptrs as
167 locally defined.
168 The lists will be in order found by a visit instance tree.
169 */
170 struct gl_list_t *vars; /* solvervar/solveratom. varips */
171 struct gl_list_t *pars; /* real ATOM instance parameters */
172 struct gl_list_t *unas; /* real ATOM instance of no 'apparent' use */
173 struct gl_list_t *models; /* models in tree. modips */
174
175 /*
176 The following gllists contain pointers to interface ptrs as
177 locally defined.
178 The lists will be in order found by running over the models list.
179 */
180 struct gl_list_t *dvars; /* discrete variables */
181 struct gl_list_t *dunas; /* discrete variables of no use */
182 struct gl_list_t *whens; /* whens */
183 struct gl_list_t *cnds; /* conditional relations */
184 struct gl_list_t *logcnds; /* conditional logrelations */
185 struct gl_list_t *rels; /* ascend relations. relips */
186 struct gl_list_t *objrels; /* objective rels. relips */
187 struct gl_list_t *logrels; /* logical rels */
188
189 struct gl_list_t *diffvars; /* subset of vars: all vars with ode_id set!=0 */
190 struct gl_list_t *algebvars; /* subset of vars: all vars with ode_id == 0 */
191 struct gl_list_t *indepvars; /* subset of vars: all vars with ode_type == -1 */
192 struct gl_list_t *obsvars; /* subset of vars: all vars with ode_type == -1 */
193
194 /* bridge ip data */
195 struct gl_list_t *oldips; /* buffer of oldip crap we're protecting */
196
197 /* misc stuff */
198 struct gl_list_t *tmplist; /* sort space */
199
200 /* stuff that will end up in the slv_system_t */
201 struct rel_relation *obj; /* DEFAULT objective relation, if any */
202 struct Instance *root; /* instance we construct system from */
203 struct gl_list_t *extrels; /* black box stub list */
204
205 /* stuff that should move elsewhere, but end up in slv_system_t */
206 mtx_region_t *blocks; /* array of partitions in reordered matrix */
207 int32 nblocks; /* size of array of partitions */
208 int nnz; /* free nonzeros in processed jacobian */
209 int nnztot; /* total nonzeros in processed relations */
210 int nnzobj; /* total nonzeros in objective gradients */
211 int nnzcond; /* total nonzeros in conditional relations */
212 int relincsize; /* total nonzeros in gradients */
213 int relincinuse; /* incidence given to relations so far */
214 int varincsize; /* total nonzeros in gradients (redundant) */
215 int varincinuse; /* incidence given to variables so far */
216 int ncol; /* free and incident vars */
217 int nrow; /* included relations */
218 /* conditional stuff */
219 int32 need_consistency; /* Conistency analysis is required ? */
220
221 /* logical relation stuff */
222 int lognnz; /* Summ of free boolean vars in inc logrels */
223 int lognrow; /* included logrelations */
224 int logncol; /* free and incident boolean vars */
225 int lrelinc; /* incident boolean vars */
226 int lrelincsize; /* Total summ of incidences (boolean vars)
227 in logrels*/
228 int lrelincinuse; /* incidence given to log relations so far */
229
230 /* data to go to slv_system_t */
231 /** @TODO rename these for consisttency, eg mastervl -> mastervars */
232 struct rel_relation *reldata; /* rel data space, mass allocated */
233 struct rel_relation *objdata; /* objrel data space, mass allocated */
234 struct rel_relation *condata; /* cond rel data space, mass allocated*/
235 struct logrel_relation *lrdata; /* logrel data space, mass allocated */
236 struct logrel_relation *logcondata; /* cond logrel data space, allocated */
237 struct var_variable *vardata; /* svar data space, mass allocated */
238 struct var_variable *pardata; /* par data space, mass allocated */
239 struct var_variable *undata; /* data space, mass allocated */
240 struct dis_discrete *disdata; /* dis var data space, mass allocated */
241 struct dis_discrete *undisdata; /* data space, mass allocated */
242 struct w_when *whendata; /* when data space, mass allocated */
243 struct bnd_boundary *bnddata; /* boundaries data space, allocated */
244 struct var_variable **mastervl; /* master null-terminated list */
245 struct var_variable **solvervl; /* solvers null-terminated list */
246 struct dis_discrete **masterdl; /* master null-terminated list */
247 struct dis_discrete **solverdl; /* solvers null-terminated list */
248 struct rel_relation **masterrl; /* master null-terminated list */
249 struct rel_relation **solverrl; /* solvers null-terminated list */
250 struct rel_relation **mastercl; /* master null-terminated list */
251 struct rel_relation **solvercl; /* solvers null-terminated list */
252 struct rel_relation **masterol; /* master null-terminated list */
253 struct rel_relation **solverol; /* solvers null-terminated list */
254 struct logrel_relation **masterll; /* master null-terminated list */
255 struct logrel_relation **solverll; /* solvers null-terminated list */
256 struct logrel_relation **mastercll; /* master null-terminated list */
257 struct logrel_relation **solvercll; /* solvers null-terminated list */
258 struct w_when **masterwl; /* master null-terminated list */
259 struct w_when **solverwl; /* solvers null-terminated list */
260 struct bnd_boundary **masterbl; /* master null-terminated list */
261 struct bnd_boundary **solverbl; /* solvers null-terminated list */
262 struct var_variable **masterpl; /* master null-terminated list */
263 struct var_variable **solverpl; /* solvers null-terminated list */
264 struct var_variable **masterul; /* master null-terminated list */
265 struct var_variable **solverul; /* solvers null-terminated list */
266 struct dis_discrete **masterdul; /* master null-terminated list */
267 struct dis_discrete **solverdul; /* solvers null-terminated list */
268 struct var_variable **relincidence; /* rel_relation incidence source */
269 struct rel_relation **varincidence; /* var_variable incidence source */
270 struct dis_discrete **logrelinciden; /* logrel_relation incidence source */
271 };
272
273 #endif

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