/[ascend]/trunk/tcltk98/generic/interface/CodeGen.h
ViewVC logotype

Contents of /trunk/tcltk98/generic/interface/CodeGen.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 67 - (show annotations) (download) (as text)
Wed Nov 30 16:31:29 2005 UTC (16 years, 5 months ago) by johnpye
File MIME type: text/x-chdr
File size: 7884 byte(s)
Standardised the "if seen" #defines to [ASC|ASCTK|ASCPY|ASCXX]_FILENAME_H
Fixed compile on FC3
1 /*
2 * CodeGen.h
3 * by Kirk Abbott and Ben Allan
4 * Created: 1/94
5 * Version: $Revision: 1.9 $
6 * Version control file: $RCSfile: CodeGen.h,v $
7 * Date last modified: $Date: 1997/07/18 12:22:30 $
8 * Last modified by: $Author: mthomas $
9 *
10 * This file is part of the ASCEND Tcl/Tk interface
11 *
12 * Copyright 1997, Carnegie Mellon University
13 *
14 * The ASCEND Tcl/Tk interface is free software; you can redistribute
15 * it and/or modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
18 *
19 * The ASCEND Tcl/Tk interface is distributed in hope that it will be
20 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with the program; if not, write to the Free Software Foundation,
26 * Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check the file named
27 * COPYING. COPYING is found in ../compiler.
28 */
29
30 /** @file
31 * Code Generation Routines
32 * <pre>
33 * Requires: #include "tcl.h"
34 * #include "utilities/ascConfig.h"
35 * #include "solver/slv_client.h"
36 * #include "solver/var.h"
37 * #include "compiler/exprs.h"
38 * #include "solver/rel.h"
39 * #include "compiler/interface.h"
40 * #include "compiler/instance_enum.h"
41 * </pre>
42 * @todo Complete documentaion of CodeGen.h.
43 */
44
45 #ifndef ASCTK_CODEGEN_H
46 #define ASCTK_CODEGEN_H
47
48 #define CG_INCLUDED 0x1
49 #define CG_LESS 0x2
50 #define CG_GREATER 0x4
51 #define CG_EQUAL CG_LESS | CG_GREATER
52
53 #define CG_FIXED 0x1
54 #define CG_INPUT 0x2
55 #define CG_OUTPUT 0x4
56 #define CG_SLV_CONST 0x8
57 #define CG_SLV_REAL 0x10
58
59 #define CG_SLV_OPEN 0x0
60
61 enum CodeGen_enum {
62 CG_ascend, CG_linear, CG_gams, CG_math, CG_c, /* main classes */
63 CG_minos, CG_blackbox, CG_glassbox, /* subclasses of CG_c */
64 CG_squarebracket, CG_curlybracket, CG_round, /* array subsrcripts*/
65 CG_hat_power, CG_dstar_power, CG_func_power, /* exponentiation */
66 CG_csr, CG_ll, CG_jds /* matrix formats */
67 };
68
69 struct CGFormat {
70 enum CodeGen_enum main_format;
71 enum CodeGen_enum parens;
72 enum CodeGen_enum power;
73 enum CodeGen_enum funcs;
74 enum CodeGen_enum names;
75 };
76
77 struct CGVar {
78 struct Instance *instance;
79 VOIDPTR prev_instanceinfo;
80 int index;
81 int cmplr_index;
82 unsigned int flags;
83 };
84
85 struct CGData {
86 struct gl_list_t *input_list;
87 struct gl_list_t *output_list;
88 enum CodeGen_enum matrix_type;
89 struct {
90 int num_vars;
91 struct CGVar *var_list; /* an array of structs */
92 } vars;
93 struct {
94 int num_pars;
95 struct var_variable **par_list; /* null terminated array of ptrs */
96 } pars;
97 struct {
98 int num_rels;
99 struct rel_relation **rel_list; /* null terminated array of ptrs */
100 } rels;
101 struct {
102 int num_objs;
103 struct rel_relation **obj_list; /* null terminated array of ptrs */
104 } objs;
105 struct {
106 int num_vars;
107 int num_pars;
108 int num_rels;
109 int num_objs;
110 int num_incidences;
111 } filtered;
112 };
113
114 extern struct CGData g_cgdata; /**< The main working data structure */
115
116 /*
117 * Some data access routines, which external clients should
118 * use.
119 */
120 extern struct Instance *Asc_CGVarInstance(struct CGVar *cgvar);
121 extern struct CGVar *Asc_CGInstanceVar(struct Instance *instance);
122 extern struct var_variable *Asc_CGInstancePar(struct Instance *instance);
123 extern int Asc_CGVarFixed(struct CGVar *);
124 extern int Asc_CGRelIncluded(struct rel_relation *);
125
126 extern struct CGVar *Asc_CodeGenSetUpVariables(struct var_variable **vp,
127 int num_vars);
128 extern struct CGVar *Asc_CodeGenSetUpVariables3(struct gl_list_t *list);
129
130 extern struct rel_relation **
131 Asc_CodeGenSetUpRelations(struct rel_relation **rp, int num_rels);
132
133 extern struct rel_relation **
134 Asc_CodeGenSetUpObjectives(struct rel_relation **op, int num_objs);
135
136 extern int Asc_CodeGenSetupCodeGen(slv_system_t sys,
137 struct CGVar *cgvarlist, int nvars,
138 struct rel_relation **rp, int nrels,
139 struct rel_relation **op, int nobjs,
140 struct var_variable **pp, int npars,
141 struct gl_list_t *inputs,
142 struct gl_list_t *outputs);
143 /**<
144 * This function sets up the main working data structure g_cgdata.
145 * It is being exported so as to make accessible across all the CodeGen
146 * files.
147 */
148
149 extern void Asc_CodeGenShutDown(void);
150 /**<
151 * This function shuts down the main working data structure g_cgdata.
152 * It is being exported so as to make accessible across all the CodeGen
153 * files.
154 */
155
156 extern int Asc_CodeGenParseDataCmd(ClientData cdata, Tcl_Interp *interp,
157 int argc, char *argv[]);
158 /**<
159 * This function simply attempts to find all the instance
160 * corresponding to the names in the list. This is mainly
161 * used for debugging. Where list is a proper tcl list. <br><br>
162 *
163 * registered as __codegen_parsedata list.
164 */
165
166 extern int Asc_CodeGenCCmd(ClientData cdata, Tcl_Interp *interp,
167 int argc, char *argv[]);
168 /**<
169 * Works on g_solvsys_cur, though this may change. The inputlist,
170 * outputlist and parameterlist may be *empty*, but *must* be provided.
171 * These lists are lists of variable that need to be marked specially
172 * for the codegeneration routines.
173 * grad?nograd tells whether gradients should be generated or not.
174 * filename is a prefix that will be used for all generated files, and
175 * exported functions so as to protect the namespace.
176 * Eg. __codegen_c flash grad {T,P,Feed} {Liq,Vap,phi} {tanksize}<br><br>
177 *
178 * registered as:
179 * __codegen_c filename ?grad?nograd? inputlist outputlist parameterlist
180 */
181
182 /*
183 * This functionality is implemented in file CodeGen2.c
184 */
185 extern int Asc_CodeGenWriteCmd(ClientData cdata, Tcl_Interp *interp,
186 int argc, char *argv[]);
187 /**<
188 * @todo ken needs to put some header here...
189 */
190
191 extern int Asc_CodeGenReadCmd(ClientData cdata, Tcl_Interp *interp,
192 int argc, char *argv[]);
193 /**<
194 * @todo ken needs to put some header here...
195 */
196
197 extern int Asc_CodeGenGamsCmd(ClientData cdata, Tcl_Interp *interp,
198 int argc, char *argv[]);
199 /**<
200 * @todo ken needs to put some header here...
201 */
202
203 extern int Asc_CodeGenGeneralCmd(ClientData cdata, Tcl_Interp *interp,
204 int argc, char *argv[]);
205 /**<
206 * Generates code in one of the major formats supported i.e.,
207 * ascend (linearized), gams, mathematica.
208 * Works on g_solvsys_cur.
209 * grad?nograd tells whether gradients should be generated or not.
210 * filename is a prefix that will be used for all generated files.<br><br>
211 *
212 * Registered as __codegen_general filename ?grad?nograd? format.
213 */
214
215 extern void Asc_CodeGenWriteAscendFile(slv_system_t sys,
216 FILE *fp,
217 char *file_prefix,
218 int gradients,
219 char *typelist);
220 /**<
221 * Start of some codegeneration routine to support the glass-box mode
222 * of pulling in external relations. typelist is a list of types that
223 * may be used to filter the amount of information that is written out.
224 */
225
226 /** some experimental stuff */
227 extern int Asc_CodeGenTypesCmd(ClientData cdata, Tcl_Interp *interp,
228 int argc, char *argv[]);
229
230 #endif /* ASCTK_CODEGEN_H */
231

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