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

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