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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 669 - (show annotations) (download) (as text)
Wed Jun 21 07:00:45 2006 UTC (13 years, 2 months ago) by johnpye
File MIME type: text/x-chdr
File size: 7011 byte(s)
Merged changes from DAE branch (revisions 702 to 819) back into trunk.
This adds the Integration API to the ASCEND solver (in base/generic).
Also provides pre-alpha support for 'IDA' from the SUNDIALS suite, a DAE solver.
Many other minor code clean-ups, including adoption of new 'ASC_NEW' and friends (to replace 'ascmalloc')
Added some very sketchy stuff providing 'DIFF(...)' syntax, although it is anticipated that this will be removed.
1 /* ASCEND modelling environment
2 Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly
3 Copyright (C) 2006 Carnegie Mellon University
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 Relation Output Routines.
21
22 Requires:
23 #include <stdio.h>
24 #include "utilities/ascConfig.h"
25 #include "instance_enum.h"
26 #include "fractions.h"
27 #include "compiler.h"
28 #include "dimen.h"
29 #include "expr_types.h"
30 #include "relation_type.h"
31 #include "exprs.h"
32 #include "relation.h"
33 *//*
34 by Tom Epperly
35 Created: 2/8/90
36 Version: $Revision: 1.9 $
37 Date last modified: $Date: 1998/01/27 11:00:18 $
38 Last modified by: $Author: ballan $
39 */
40
41 #ifndef ASC_RELATION_IO_H
42 #define ASC_RELATION_IO_H
43
44 #include <utilities/ascConfig.h>
45
46 /**<
47 * This enum controls the format of function names and other
48 * minor operator variations in the supported languages.
49 *
50 * Add others here as desired and then update RelationWriteString.
51 */
52 enum rel_lang_format {
53 relio_ascend,
54 relio_C
55 };
56
57 typedef char * (*WRSNameFunc)(CONST struct relation *,unsigned long,void *);
58 /**<
59 * For use with WriteRelationString() and token relations.
60 * Func should return a name for varnum in tokenrel.
61 * Userdata will be that which the caller of WriteRelationString provides.
62 * We do not keep the name returned or free it -- it is the func's
63 * responsibility to track this memory.
64 */
65
66 struct RXNameData{
67 char *prefix;
68 int *indices;
69 char *suffix;
70 };
71
72 extern char *RelationVarXName(CONST struct relation *r,
73 unsigned long varnum,
74 struct RXNameData *rxndata);
75 /**<
76 * Returns names like x23.
77 * Returns a character string (which we own, not the caller, but it won't
78 * change until we're called again) with the name of the
79 * the variable in "Prefix%luSuffix" format. prefix and suffix are limited
80 * to 110 characters and are taken from rxndata.
81 * If indices is not NULL, then the number printed will be
82 * (unsigned long)indices[varnum] (remember: varnums go from 1 and
83 * C arrays from 0!) else number printed will be varnum.
84 * If prefix is NULL, "x" will be assumed and suffix will be assumed "".
85 * If prefix is not NULL, suffix must not be NULL.
86 * r is ignored entirely.<br><br>
87 *
88 * This function is compatible with WriteRelationString().
89 */
90
91 extern int NeedParen(enum Expr_enum parent, enum Expr_enum child, int rhs);
92 /**<
93 * Given a unary or binary expression, will determine whether, the
94 * child expression needs parentheses. "rhs" tells if we are looking
95 * at the left or right side of a binary token.
96 * E.g x ^ (2/y), would need parens exactly as shown to give the
97 * correct precedence.
98 * This would be called as : NeedParen(e_power,e_divide,right);
99 * and would return nonzero.
100 */
101
102 extern void WriteRelation(FILE *f,
103 CONST struct Instance *relinst,
104 CONST struct Instance *ref);
105 /**<
106 * Write the relation in infix to the file indicated.
107 * This function comfortably handles all the relation types.
108 * Variables are written with names relative to ref.
109 */
110
111 ASC_DLLSPEC(char*) WriteRelationString(
112 CONST struct Instance *relinst,
113 CONST struct Instance *ref,
114 WRSNameFunc func,
115 void *userdata,
116 enum rel_lang_format lang,
117 int *lenptr
118 );
119 /**<
120 * Write the token relation in infix to a char using the
121 * variable names as generated by func.
122 * If func is NULL, name will be written in ascend form
123 * from ref to the variable.
124 * This function comfortably handles all the relation types,
125 * but glassbox and blackbox do not use func or userdata.
126 * lenptr contains the length of the string returned, or -1
127 * if string is NULL. If lenptr is NULL, it is ignored.
128 */
129
130 extern void WriteRelationPostfix(FILE *f,
131 CONST struct Instance *relinst,
132 CONST struct Instance *ref);
133 /**<
134 * Write the relation in postfix to the file indicated.
135 * This function at the moment is only applicable to token relations.
136 */
137
138 ASC_DLLSPEC(char *) WriteRelationPostfixString(CONST struct Instance *relinst,
139 CONST struct Instance *ref);
140 /**<
141 * Write the relation in postfix to the file indicated.
142 * This function at the moment is only applicable to token relations.
143 */
144
145 extern void Infix_WriteRelation(FILE *f,
146 CONST struct Instance *r,
147 CONST struct Instance *ref);
148 /**<
149 * Write the relation in infixe to the file indicated.
150 * This function uses the "new" infix representation of relations.
151 * This function at the moment is only applicable to token relations.
152 */
153
154 extern void WriteRelationsInTree(FILE *f, struct Instance *relinst);
155 /**<
156 * Search for relations in an instance and write them to the
157 * file given in various formats.
158 */
159
160 extern void WriteRelationsInList(FILE *f, struct gl_list_t *l);
161 /**<
162 * Search for relations in an instance list and write them to the
163 * file given in various formats.
164 */
165
166 extern void SaveRelationVariables(FILE *fp, CONST struct relation *r);
167 /**<
168 * Given a relation will save its variable list in the ASCEND condensed
169 * format.
170 */
171
172 extern void SaveGlassBoxRelation(FILE *fp, CONST struct Instance *relinst);
173 /**<
174 * Given a glassbox relation will save it in the ASCEND condensed
175 * format.
176 */
177
178 extern void SaveTokenRelation(FILE *fp, CONST struct Instance *relinst);
179 /**<
180 * Given a token relation will save it in the ASCEND condensed
181 * format.
182 */
183
184 extern void SaveReln2GlassBox(FILE *fp,
185 CONST struct Instance *relinst,
186 char *prefix,
187 unsigned long index_);
188 /**<
189 * Given a relation will save it and perform conversion to the glassbox
190 * format.
191 */
192
193 extern int ConversionIsValid(enum Expr_enum old, enum Expr_enum new_enum);
194 /**<
195 * Given a relation format will return TRUE if conversion to another
196 * format is valid. It assumes that new is a valid relation type.
197 */
198
199 extern void RelationIO_init_pool(void);
200 /**<
201 * starts memory recycle. Do not call twice before stopping recycle.
202 */
203
204 extern void RelationIO_destroy_pool(void);
205 /**<
206 * Stops memory recycle. Do not call while ANY Expr are outstanding.
207 */
208
209 extern void RelationIO_report_pool(void);
210 /**<
211 * Write the pool report to ASCERR for the ppe pool.
212 */
213
214 #endif /* ASC_RELATION_IO_H */
215

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