/[ascend]/trunk/ascend/compiler/mathinst.h
ViewVC logotype

Contents of /trunk/ascend/compiler/mathinst.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2688 - (show annotations) (download) (as text)
Mon Mar 4 08:11:49 2013 UTC (7 years, 2 months ago) by jpye
File MIME type: text/x-chdr
File size: 8189 byte(s)
Various debug output to try to resolve bug 567.
1 /* ASCEND modelling environment
2 Copyright (C) 2006 Carnegie Mellon University
3 Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly
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, see <http://www.gnu.org/licenses/>.
17 *//**
18 @file
19 Ascend Instance Math Object Functions.
20
21 Relation, logical relation, and When querying and assignment routines
22
23 Requires:
24 #include "utilities/ascConfig.h"
25 #include "fractions.h"
26 #include "instance_enum.h"
27 #include "compiler.h"
28 #include "dimen.h"
29 #include "expr_types.h"
30 *//*
31 by Tom Epperly
32 8/16/89
33 Last in CVS: $Revision: 1.8 $ $Date: 1998/05/06 17:33:37 $ $Author: ballan $
34 */
35
36 #ifndef ASC_MATHINST_H
37 #define ASC_MATHINST_H
38
39 #include "expr_types.h"
40 #include "instance_enum.h"
41
42 /** @addtogroup compiler_inst Compiler Instance Hierarchy
43 @{
44 */
45
46 ASC_DLLSPEC enum Expr_enum GetInstanceRelationType(CONST struct Instance *i);
47 /**<
48 This returns the type of the relation associated with this relations
49 instance (REL_INST).
50 This should be one of e_token, e_opcode, e_glassbox or e_blackbox.
51 */
52
53 ASC_DLLSPEC CONST struct relation *GetInstanceRelationOnly(CONST struct Instance *i);
54 /**<
55 This returns the guts of a relation instance (REL_INST).
56 These should be treated as read only usually because you don't
57 know who is sharing those guts.
58 */
59
60 ASC_DLLSPEC CONST struct relation *GetInstanceRelation(CONST struct Instance *i,
61 enum Expr_enum *type);
62 /**<
63 This returns the value of a relation inst(REL_INST). It will fill in
64 the type of the relation associated with this relation instance.
65 This will be one of e_token, e_opcode, e_glassbox or e_blackbox,
66 or possibly e_undefined.
67
68 @TODO Important! This appears not to be to inverse of the rel_instance
69 function in the solver! Why is that? -- JP
70 */
71
72 extern struct relation *GetInstanceRelToModify(struct Instance *i,
73 enum Expr_enum *type);
74 /**<
75 This returns the value of a relation inst(REL_INST). In this function
76 we do not get a CONST structure and therefore we can modify it. This
77 is useful while marking conditional relations.
78 */
79
80 extern void SetInstanceRelation(struct Instance *i,
81 struct relation *rel,
82 enum Expr_enum type);
83 /**<
84 Set the relation to rel. rel will be incorporated into the instance,
85 so rel should not be modified or destroyed. The type of the relation
86 *has* to be provided.
87
88 rel and type may be the NULL/e_undefined combination.
89 */
90
91 ASC_DLLSPEC CONST struct logrelation *GetInstanceLogRelOnly(CONST struct Instance*i);
92 /**<
93 This returns the guts of a logical relation instance (LREL_INST).
94 These should be treated as read only usually because you don't
95 know who is sharing those guts.
96 */
97
98 ASC_DLLSPEC CONST struct logrelation *GetInstanceLogRel(CONST struct Instance *i);
99 /**<
100 This returns the value of a logrelation inst(LREL_INST).
101 */
102
103 extern struct logrelation *GetInstanceLogRelToModify(struct Instance *i);
104 /**<
105 This returns the value of a logrelation inst(LREL_INST). In this function
106 we do not get a CONST structure and therefore we can modify it. This
107 is useful while marking conditional logrelations.
108 */
109
110 extern void SetInstanceLogRel(struct Instance *i, struct logrelation *lrel);
111 /**<
112 Set the logical relation to lrel. rel will be incorporated into the
113 instance, so rel should not be modified or destroyed.
114 */
115
116 ASC_DLLSPEC struct gl_list_t *GetInstanceOperands(CONST struct Instance *i);
117 /**<
118 Returns list of vars/models/equations in a mathematical relationship.
119 Accepts all instance kinds. returns list only if the query makes
120 sense, but list may be empty. List is yours to destroy, but its
121 contents are not.
122 */
123
124 extern struct gl_list_t *GetInstanceWhenVars(CONST struct Instance *i);
125 /**<
126 This returns the list of variables associated with this when
127 instance (WHEN_INST)
128 */
129
130 extern struct gl_list_t *GetInstanceWhenCases(CONST struct Instance *i);
131 /**<
132 This returns the list of cases associated with this when
133 instance (WHEN_INST)
134 */
135
136 extern struct gl_list_t *GetInstanceWhens(CONST struct Instance *i);
137 /**<
138 This returns the list of whens associated with this instance.
139 Instance can be a model, relation,when,boolean, integer or symbol.
140 */
141
142 extern void SetWhenVarList(struct Instance *i, struct gl_list_t *whenvars);
143 /**<
144 Set the list of variables of a when instance to whenvars
145 */
146
147 extern void SetWhenCases(struct Instance *i, struct gl_list_t *whencases);
148 /**<
149 Set the list of cases of a when instance to whencases
150 */
151
152 /*------------------------------------------------------------------------------
153 SPECIAL REAL ATOM FUNCTIONS
154
155 Each real instance knows what mathematical relations that it appears in.
156 That information can be acessed by the following routines.
157 Same for discrete variables.
158 */
159
160 ASC_DLLSPEC unsigned long RelationsCount(CONST struct Instance *i);
161 /**<
162 This will return the number of relations that instance "i" appears in.
163 "i" must be a REAL_ATOM_INST. Otherwise, this routine will
164 bomb.
165 */
166
167 ASC_DLLSPEC struct Instance *RelationsForAtom(CONST struct Instance *i,
168 unsigned long c);
169 /**<
170 This routine will return the c'th relation in instance i's relation list.
171 "i" must be a REAL_ATOM_INST and 0 < c <= RelationsCount(i).
172 */
173
174 extern void AddRelation(struct Instance *i, struct Instance *reln);
175 /**<
176 Add the relation instance reln to instance i's relation list. "i" must
177 be of type REAL_ATOM_INST and reln must be of type REL_INST.
178 */
179
180 extern void RemoveRelation(struct Instance *i, struct Instance *reln);
181 /**<
182 Remove reln from the relation list of variable instance 'i'. If reln isn't
183 found in i's relation list, execution continues with a warning message.
184 */
185
186 ASC_DLLSPEC unsigned long LogRelationsCount(CONST struct Instance *i);
187 /**<
188 This will return the number of logical relations that instance "i"
189 appears in. "i" must be a BOOLEAN_ATOM_INST, REL_INST or LREL_INST
190 */
191
192 ASC_DLLSPEC struct Instance *LogRelationsForInstance(CONST struct Instance *i,
193 unsigned long c);
194 /**<
195 This routine will return the c'th logical relation in instance i's
196 logical relation list. "i" must be BOOLEAN_ATOM_INST, REL_INST or
197 LREL_INST and 0 < c <= LogRelationsCount(i).
198 */
199
200 extern void AddLogRel(struct Instance *i, struct Instance *reln);
201 /**<
202 Add the logical relation instance lreln to instance i's logical relation
203 list. "i" must be of type BOOLEAN_ATOM_INST, REL_INST or LREL_INST
204 and lreln must be of type LREL_INST. REL_INST and LREL_INST are
205 allowed because of the SATISFIED logical term.
206 */
207
208 extern void RemoveLogRel(struct Instance *i, struct Instance *lreln);
209 /**<
210 Remove lreln from i's logical relation list. If 'lreln' isn't found in
211 i's logical relation list, execution continues with a warning message.
212 */
213
214 ASC_DLLSPEC unsigned long WhensCount(struct Instance *i);
215 /**<
216 This will return the number of whens that instance "i" is referenced in.
217 */
218
219 ASC_DLLSPEC struct Instance *WhensForInstance(struct Instance *i,
220 unsigned long c);
221 /**<
222 This routine will return the c'th when in instance i's when list.
223 0 < c <= WhensCount(i).
224 */
225
226 extern void AddWhen(struct Instance *i, struct Instance *when);
227 /**<
228 Add the when instance when to instance i's when list. when must be of
229 type WHEN_INST.
230 */
231
232 extern void RemoveWhen(struct Instance *i, struct Instance *when);
233 /**<
234 Remove when from i's when list. If 'when' isn't found in i's when
235 list, execution continues with a warning message.
236 */
237
238 /* @} */
239
240 #endif /* ASC_MATHINST_H */
241

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