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

Contents of /trunk/base/generic/compiler/mathinst.h

Parent Directory Parent Directory | Revision Log Revision Log


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

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