/[ascend]/trunk/base/generic/solver/var.h
ViewVC logotype

Annotation of /trunk/base/generic/solver/var.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 944 - (hide annotations) (download) (as text)
Sat Nov 25 10:46:13 2006 UTC (14 years, 3 months ago) by johnpye
File MIME type: text/x-chdr
File size: 24598 byte(s)
Implemented ATOLVECT, ATOL, RTOL parameters for the IDA integrator.
1 johnpye 485 /* ASCEND modelling environment
2 johnpye 239 Copyright (C) 1990 Karl Michael Westerberg
3     Copyright (C) 1993 Joseph Zaher
4     Copyright (C) 1994 Joseph Zaher, Benjamin Andrew Allan
5 johnpye 480 Copyright (C) 2006 Carnegie Mellon University
6 johnpye 239
7 johnpye 485 This program is free software; you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by
9     the Free Software Foundation; either version 2, or (at your option)
10     any later version.
11 johnpye 239
12 johnpye 485 This program is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     GNU General Public License for more details.
16 johnpye 239
17     You should have received a copy of the GNU General Public License
18 johnpye 485 along with this program; if not, write to the Free Software
19     Foundation, Inc., 59 Temple Place - Suite 330,
20     Boston, MA 02111-1307, USA.
21     *//**
22     @file
23 johnpye 231 Variable module of the SLV solver.
24 aw0a 1
25 johnpye 669 This module provides a SLV solver (the "client") with access to
26     variables present in the ASCEND compiler (the "server").
27 johnpye 231
28 johnpye 669 Access to ASCEND variables is abstracted so that SLV solvers
29     can theoretically be used to solve other kinds of systems as
30     well. @see analyze.h
31    
32 johnpye 485 The idea of a var makes no sense outside the context of
33     a slv_system_t, so some of the functions here may require
34     the passing of a slv_system_t with the var.
35 johnpye 231
36 johnpye 485 06/90 - original version
37     01/94 - added var_make_name() to create a copy of the
38     instance name
39     04/94 - added var_apply_filter() which uses the new
40     var_filter_t data structure for perfoming all
41     variable filtering needs (eliminating the
42     filter module)
43     08/94 - added var_BackendTokens_to_vars. BAA.
44 johnpye 231
45 johnpye 480 Requires:
46 johnpye 231 #include <stdio.h>
47     #include "utilities/ascConfig.h"
48     #include "solver/slv_types.h"
49    
50 johnpye 485 @TODO
51     At present there is some insanity about asking the instance tree
52     vs asking our data structure about the flag values - This needs to
53 johnpye 669 be fixed (see longer BAA comment in var.h).
54 johnpye 485 *//*
55     Authors: Karl Westerberg and Joseph Zaher
56     Version: $Revision: 1.26 $
57     Date last modified: $Date: 1998/03/30 22:07:10 $
58     Last modified by: $Author: rv2a $
59 johnpye 231 */
60    
61 johnpye 67 #ifndef ASC_VAR_H
62     #define ASC_VAR_H
63 aw0a 1
64 johnpye 485 #include <utilities/ascConfig.h>
65    
66 aw0a 1 /*
67 johnpye 239 The first section of flagbit definitions are those flags to be
68     set by the server. Clients should not mess with them unless
69     they are very, very smart.
70 aw0a 1 */
71 jds 54 #define VAR_REAL 0x1
72 ben.allan 33 /**< don't know what this is good for. */
73 jds 54 #define VAR_INCIDENT 0x2
74 ben.allan 33 /**< is this variable incident on some equation in the slv_system? */
75 jds 54 #define VAR_PVAR 0x4
76 ben.allan 33 /**< do we think this var a 'solver_par'? */
77 jds 54 #define VAR_SVAR 0x8
78 ben.allan 33 /**< do we think this var a 'solver_var'? */
79 jds 54 #define VAR_INTEGER 0x10
80 ben.allan 33 /**< do we think this var a solver_integer? */
81 jds 54 #define VAR_BINARY 0x20
82 ben.allan 33 /**< do we think this var a solver_binary? */
83 jds 54 #define VAR_SEMICONT 0x40
84 ben.allan 33 /**< do we think this var a solver_semi(continuous) ? */
85 aw0a 1
86     /*
87 johnpye 239 The remaining flagbit definitions are those flags to be
88     manipulated by registered clients. Unregistered clients
89     should not change these bits unless the manner in which
90     they affect the bits is explained in the header for the
91     unregistered client.
92 aw0a 1 */
93    
94 jds 54 #define VAR_PARAM 0x1000
95     /**< is this variable considered parametric currently? */
96     #define VAR_FIXED 0x2000
97     /**< is this variable considered fixed currently? */
98     #define VAR_INBLOCK 0x4000
99     /**< is this var in the columns of the block we are currently solving? */
100     #define VAR_INTERFACE 0x8000
101     /**< is this var an interface var currently? */
102     #define VAR_RELAXED 0x10000
103     /**< is this var currently a relaxed int or binary or semi var? */
104     #define VAR_ACTIVE 0x20000
105     /**< is this var currently a part of my problem? */
106     #define VAR_NONBASIC 0x40000
107     /**< is this var currently an independent variable (optimization)? */
108     #define VAR_ACTIVE_AT_BND 0x80000
109     /**< is this var active in some of the subregions neighboring the
110 johnpye 239 boundary on which the problem currently lies ? */
111 jds 54 #define VAR_ELIGIBLE 0x100000
112     /**< is this variable eligible to be fixed (globally)? */
113 aw0a 1 #define VAR_ELIGIBLE_IN_SUBREGION 0x200000
114 jds 54 /**< is this variable eligible to be fixed (in current subregion) ? */
115 aw0a 1 #define VAR_POTENTIALLY_FIXED 0x400000
116 jds 54 /**< this bit is auxiliar while iteratively and recurively we are
117 johnpye 239 performing a combinatorial search, looking for a consitent
118     partition for all the alternatives in an conditional model */
119 ben.allan 33 #define VAR_INCIDENT_IN_CASE 0x800000
120 jds 54 /**< is this variable incident in some relation of a CASE in a
121 johnpye 239 WHEN statement ?. This is for purposes of simplfying the
122     analysis of conditional models */
123 aw0a 1
124 jds 54 /**
125 johnpye 239 Variable structure.
126     Finally, we have a real structure so that we aren't hanging stuff
127     of the global instance tree. Do not dereference this structure except
128     via macros/functions, because we make no commitments about being
129     backward compatible with such code.
130    
131     struct Instance * and struct var_variable * are no longer synonymous!
132 aw0a 1 */
133 jds 54 struct var_variable {
134     SlvBackendToken ratom; /**< the associated ascend ATOM */
135     struct rel_relation **incidence; /**< array rels which contain var */
136     int32 n_incidences; /**< length of incidence. */
137     int32 sindex; /**< index in the solver clients list (often column index) */
138     int32 mindex; /**< index in the slv_system_t master list */
139     uint32 flags; /**< batch of binary flags. The bit positions are as above */
140     };
141 aw0a 1
142 jds 54 /** Variable filter structure */
143 aw0a 1 typedef struct var_filter_structure {
144 jds 54 uint32 matchbits; /**< Bits to match. */
145     uint32 matchvalue; /**< Value to match. */
146 aw0a 1 } var_filter_t;
147 jds 54 /**< Variable filter type */
148 aw0a 1
149     #define var_NO_UPPER_BOUND MAXDOUBLE
150     #define var_NO_LOWER_BOUND (-MAXDOUBLE/2)
151    
152     #ifdef NDEBUG
153 johnpye 239 # define var_instance(var) ((var)->ratom)
154 jds 54 #else
155 johnpye 239 # define var_instance(var) var_instanceF(var)
156 johnpye 480 #endif
157 jds 54 /**<
158 johnpye 239 Returns the ATOM instance associated with the variable.
159     @param var const struct var_variable *, the variable to query.
160     @return Returns the instance as a SlvBackendToken.
161     @see var_instanceF()
162     */
163 aw0a 1
164 jds 54 #ifdef NDEBUG
165 johnpye 239 # define var_set_instance(var,inst) ((var)->ratom = (inst))
166 jds 54 #else
167 johnpye 239 # define var_set_instance(var,inst) var_set_instanceF((var),(inst))
168 johnpye 480 #endif
169 ben.allan 33 /**<
170 johnpye 239 Sets the ATOM instance associated with the variable.
171     @param var struct var_variable *, the variable to modify.
172     @param inst SlvBackendToken, the new instance value.
173     @return No return value.
174     @see var_instanceF()
175     */
176 aw0a 1
177 johnpye 490 ASC_DLLSPEC(SlvBackendToken) var_instanceF(const struct var_variable *var);
178 ben.allan 33 /**<
179 johnpye 239 Implementation function for var_instance(). Do not call this
180     function directly - use var_instance() instead.
181     */
182 jds 54 extern void var_set_instanceF(struct var_variable *var, SlvBackendToken i);
183     /**<
184 johnpye 239 Implementation function for var_set_instance(). Do not call this
185     function directly - use var_set_instance() instead.
186     */
187 jds 54
188     extern char *var_make_xname(const struct var_variable *var);
189     /**<
190 johnpye 239 Returns the index name, eg x23 rather than full name.
191     See var_make_name() for more information.
192     */
193 johnpye 490 ASC_DLLSPEC(char*) var_make_name(
194 johnpye 480 const slv_system_t sys,
195     const struct var_variable *var
196     );
197 jds 54 /**<
198 johnpye 239 Creates and returns a sufficiently large string storing the
199     qualified name of var as known by the solver instance tree.
200     If the instance is not found, "?" is returned. The string
201     should be destroyed when no longer in use.<br><br>
202 aw0a 1
203 johnpye 239 The name of a var is context dependent, so you have to provide the
204     slv_system_t from which you got the var.
205     */
206    
207 johnpye 521 ASC_DLLSPEC(void) var_write_name(const slv_system_t sys,
208 jds 54 const struct var_variable *var,
209     FILE *file);
210 ben.allan 33 /**<
211 johnpye 239 Writes a name to the file given. Handles NULL inputs gracefully.
212     Does not print any whitespace, including carriage returns.
213     Is faster than slv_print_var_name().
214     If sys is NULL, writes full ascend name. If file or var is NULL
215     does not write.
216     */
217 aw0a 1
218 jds 54 void var_destroy(struct var_variable *var);
219 ben.allan 33 /**<
220 johnpye 239 Since someone else allocates vars en masse, this just sets
221     our integrity check to ERROR.
222     */
223 aw0a 1
224     #ifdef NDEBUG
225 johnpye 239 # define var_mindex(var) (var)->mindex
226 jds 54 #else
227 johnpye 239 # define var_mindex(var) var_mindexF(var)
228 johnpye 480 #endif
229 jds 54 /**<
230 johnpye 239 Returns the index of the variable as it appears in a variable list.
231     The index is also used to assign the variable to a specific
232     original column of a matrix.
233     @param var const struct var_variable *, the variable to query.
234     @return Returns the index as an int32.
235     @see var_mindexF().
236     */
237 aw0a 1
238 jds 54 #ifdef NDEBUG
239 johnpye 239 # define var_set_mindex(var,index) (var)->mindex = (index)
240 jds 54 #else
241 johnpye 239 # define var_set_mindex(var,index) var_set_mindexF((var),(index))
242 johnpye 480 #endif
243 ben.allan 33 /**<
244 johnpye 239 Sets the index of the variable as it appears in a variable list.
245     @param var struct var_variable *, the variable to modify.
246     @param index int32, the new value for the index.
247     @return No return value.
248     @see var_set_mindexF().
249     */
250 jds 54
251     extern int32 var_mindexF(const struct var_variable *var);
252     /**<
253 johnpye 239 Implementation function for var_mindex(). Do not call this
254     function directly - use var_mindex() instead.
255     */
256 johnpye 908 extern void var_set_mindexF(struct var_variable *var, int32 mindex);
257 jds 54 /**<
258 johnpye 239 Implementation function for var_set_mindex(). Do not call this
259     function directly - use var_set_mindex() instead.
260     */
261 aw0a 1
262     #ifdef NDEBUG
263 johnpye 239 # define var_sindex(var) (var)->sindex
264 jds 54 #else
265 johnpye 239 # define var_sindex(var) var_sindexF(var)
266 johnpye 480 #endif
267 jds 54 /**<
268 johnpye 239 Returns the index of the variable as it appears in a solvers
269     variable list. The index is also used to assign the variable
270     to a specific original column of a matrix.
271     @param var const struct var_variable *, the variable to query.
272     @return Returns the index as an int32.
273     @see var_sindexF().
274     */
275 aw0a 1
276 jds 54 #ifdef NDEBUG
277 johnpye 239 # define var_set_sindex(var,index) (var)->sindex = (index)
278 jds 54 #else
279 johnpye 239 # define var_set_sindex(var,index) var_set_sindexF((var),(index))
280 johnpye 480 #endif
281 ben.allan 33 /**<
282 johnpye 239 Sets the index of the variable as it appears in a solver's
283     variable list.
284     @param var struct var_variable *, the variable to modify.
285     @param index int32, the new value for the index.
286     @return No return value.
287     @see var_set_sindexF().
288     */
289 jds 54
290 johnpye 490 ASC_DLLSPEC(int32) var_sindexF(const struct var_variable *var);
291 jds 54 /**<
292 johnpye 239 Implementation function for var_sindex(). Do not call this
293     function directly - use var_sindex() instead.
294     */
295 johnpye 908 extern void var_set_sindexF(struct var_variable *var, int32 sindex);
296 jds 54 /**<
297 johnpye 239 Implementation function for var_set_sindex(). Do not call this
298     function directly - use var_set_sindex() instead.
299     */
300 aw0a 1
301 johnpye 490 ASC_DLLSPEC(real64) var_value(const struct var_variable *var);
302 jds 54 /**< Returns the value of the variable. */
303 johnpye 522 ASC_DLLSPEC(void ) var_set_value(struct var_variable *var, real64 value);
304 ben.allan 33 /**<
305 johnpye 239 Sets the value of the variable.
306     */
307 aw0a 1
308 johnpye 490 ASC_DLLSPEC(real64) var_nominal(struct var_variable *var);
309 jds 54 /**< Returns the nominal value of the variable, or 1.0 if it has none. */
310 johnpye 522 ASC_DLLSPEC(void ) var_set_nominal(struct var_variable *var, real64 nominal);
311 ben.allan 33 /**<
312 johnpye 239 Sets the nominal value of the variable.
313 johnpye 480 If no nominal field in var, returns 1.0.
314 johnpye 239 */
315 aw0a 1
316 johnpye 490 ASC_DLLSPEC(real64) var_lower_bound(struct var_variable *var);
317 jds 54 /**< Returns the lower bound value of the variable. */
318     extern void var_set_lower_bound(struct var_variable *var, real64 lower_bound);
319 ben.allan 33 /**<
320 johnpye 239 Sets the lower bound value of the variable.
321     */
322 aw0a 1
323 johnpye 490 ASC_DLLSPEC(real64) var_upper_bound(struct var_variable *var);
324 jds 54 /**< Returns the upper bound value of the variable. */
325     extern void var_set_upper_bound(struct var_variable *var, real64 upper_bound);
326 ben.allan 33 /**<
327 johnpye 239 Gets/sets the upper bound value of the variable.
328     */
329 aw0a 1
330 johnpye 944 double var_odeatol(struct var_variable *var);
331     /**< Returns the ODE absolute error tolerance for the variable, or -1 if not available */
332    
333 aw0a 1 #ifdef NDEBUG
334 johnpye 239 # define var_n_incidences(var) ((var)->n_incidences)
335 aw0a 1 #else
336 johnpye 732 ASC_DLLSPEC(int32) var_n_incidencesF(struct var_variable *var);
337 johnpye 239 # define var_n_incidences(var) var_n_incidencesF(var)
338 jds 54 #endif
339     /**<
340 johnpye 239 Returns the length of the incidence list.
341     Not everything in the incidence list is necessarily a
342     variable for your particular solver -- check the flags.
343     @param var const struct var_variable *, the variable to query.
344     @return Returns the index as an int32.
345     @see var_n_incidencesF().
346     */
347 aw0a 1
348 jds 54 #ifdef NDEBUG
349 johnpye 239 # define var_set_incidences(var,n,ilist) \
350 jds 54 (var)->n_incidences=(n); (var)->incidence = (ilist)
351     #else
352 johnpye 239 # define var_set_incidences(var,n,ilist) var_set_incidencesF((var),(n),(ilist))
353 johnpye 480 #endif
354 ben.allan 33 /**<
355 johnpye 239 Sets the incidence list for a variable.
356     Solver clients should not call var_set_incidences(). It is
357     only for use by constructors of bridges to varation back ends.
358     @param var struct var_variable *, the variable to query.
359     @param n int32, length of the new incidence list.
360     @param ilist struct rel_relation **, the new incidence list.
361     @return No return value.
362     @see var_set_incidencesF().
363     */
364 jds 54
365     extern void var_set_incidencesF(struct var_variable *var,
366     int32 n,
367     struct rel_relation **ilist);
368     /**<
369 johnpye 239 Implementation function for var_set_incidences(). Do not call this
370     function directly - use var_set_incidences() instead.
371     */
372 aw0a 1
373 johnpye 732 ASC_DLLSPEC(struct rel_relation **) var_incidence_list_to_modify(
374     struct var_variable *var);
375 jds 54 /**< Same as var_incidence_list(), except the returned list is modifiable. */
376 johnpye 732
377 jds 54 extern const struct rel_relation **var_incidence_list(struct var_variable *var);
378 ben.allan 33 /**<
379 johnpye 239 Returns a pointer to an array var_n_incidences(var) long of vars.
380     Each element of the array is a struct rel_relation *.
381     Check the var sindex to see where each might go in a jacobian.
382     If there is no incidence, NULL is returned.
383     Pointers in this array will be unique.
384 aw0a 1
385 johnpye 732 The list belongs to the varation. Do not destroy it. Do not change it.
386    
387 johnpye 239 RA IS NOT a NULL-TERMINATED LIST.
388     */
389    
390 jds 54 #ifdef NDEBUG
391 johnpye 239 # define var_flags(var) ((var)->flags)
392 jds 54 #else
393 johnpye 239 # define var_flags(var) var_flagsF(var)
394 johnpye 480 #endif
395 jds 54 /**<
396 johnpye 239 Returns the flags field of the var. This flags value should
397     be composed of the var_xxx values defined above.
398     @param var const struct var_variable *, the variable to query.
399     @return Returns the index as an int32.
400     @see var_flagsF().
401     */
402 aw0a 1
403     #ifdef NDEBUG
404 johnpye 239 # define var_set_flags(var,flags) ((var)->flags = (flags))
405 aw0a 1 #else
406 johnpye 239 # define var_set_flags(var,flags) var_set_flagsF((var),(flags))
407 johnpye 480 #endif
408 jds 54 /**<
409 johnpye 480 Sets the entire flag field to the value of flags given.
410     This flags value should be composed of the var_xxx values
411 johnpye 239 defined above.
412     @param var struct var_variable *, the variable to query.
413     @param flags uint32, the new flags value.
414     @return No return value.
415     @see var_set_flagsF().
416     */
417 aw0a 1
418 johnpye 490 ASC_DLLSPEC(uint32) var_flagsF(const struct var_variable *var);
419 ben.allan 33 /**<
420 johnpye 239 Implementation function for var_flags(). Do not call this
421     function directly - use var_flags() instead.
422 jds 54 */
423     extern void var_set_flagsF(struct var_variable *var, uint32 flags);
424     /**<
425 johnpye 239 Implementation function for var_set_flags(). Do not call this
426     function directly - use var_set_flags() instead.
427     */
428 aw0a 1
429 johnpye 490 ASC_DLLSPEC(uint32) var_flagbit(const struct var_variable *rel, const uint32 name);
430 ben.allan 33 /**<
431 johnpye 239 Returns the value of the bit specified from the variable flags.
432     name should be a VAR_xx flag defined above.
433     */
434 aw0a 1
435 johnpye 522 ASC_DLLSPEC(void ) var_set_flagbit(struct var_variable *var,
436 jds 54 uint32 NAME,
437     uint32 oneorzero);
438 ben.allan 33 /**<
439 johnpye 239 Sets the bit, which should be referred to by its macro name,
440     on if oneorzero is >0 and off is oneorzero is 0.
441     The macro names are the defined up at the top of this file.<br><br>
442 aw0a 1
443 johnpye 239 Example: var_set_flags(var,VAR_PARTITION,1) turns on the
444     VAR_PARTITION bit.
445     <pre>
446     What it really does is:
447     if (oneorzero) {
448     var->flags |= field;
449     } else {
450     var->flags &= ~field;
451     }
452     </pre>
453     */
454    
455 jds 54 /*
456 aw0a 1 * At present there is some insanity about asking the instance tree
457     * vs asking our data structure about the flag values. This needs to
458 johnpye 480 * be fixed. In the process of that fix, we should establish a
459     * protocol that means vars/rels never need to look back at ATOM
460 aw0a 1 * instances to be queried during the solution process. Rather, we
461     * need to establish a process in which the var list tells all its
462     * atoms about the solver derived values or the var list updates
463     * its values and flags from the instance tree.
464     * There is a counterpart exercise that needs to go on in the
465     * rel module so that (for remote processing) it is possible to
466     * do everything without looking back at the instance tree.
467     * At present, we will always keep VAR_FIXED in sync with the
468     * instance tree, but the instance tree is the leader.
469     * 6/96. baa
470     */
471    
472 johnpye 522 ASC_DLLSPEC(int32 ) var_apply_filter(const struct var_variable *var,
473 jds 54 const var_filter_t *filter);
474 ben.allan 33 /**<
475 johnpye 239 Returns 1 if filter and var flags are compatible, 0 elsewise.
476     See the filter description in rel.h. This is exactly the same.
477     */
478 aw0a 1
479 johnpye 522 ASC_DLLSPEC(uint32 ) var_fixed(struct var_variable *var);
480 jds 54 /**< Returns the fixed flag of var. Has side effects in the ascend instance. */
481     extern void var_set_fixed(struct var_variable *var, uint32 fixed);
482     /**< Sets the fixed flag of var. Has side effects in the ascend instance. */
483     extern uint32 var_relaxed(struct var_variable *var);
484     /**< Returns the relaxed flag of var. Has side effects in the ascend instance. */
485     extern void var_set_relaxed(struct var_variable *var, uint32 fixed);
486     /**< Sets the relaxed flag of var. Has side effects in the ascend instance. */
487     extern uint32 var_interface(struct var_variable *var);
488     /**< Returns the interface flag of var. Has side effects in the ascend instance. */
489     extern void var_set_interface(struct var_variable *var, uint32 fixed);
490 jds 56 /**< Sets the interface flag of var. Has side effects in the ascend instance.
491 johnpye 239 @todo solver/var.h: var_set_interface() not implemented. Implement or remove.
492 jds 54 */
493     /*
494 johnpye 239 The above... Gets/sets the fixed/relaxed/interface flag of the variable. This
495     has side effects in the ascend instance, with which
496     we are keeping the bits in sync.
497     */
498 aw0a 1
499     #ifdef NDEBUG
500 johnpye 239 # define var_in_block(var) ((var)->flags & VAR_INBLOCK)
501     /**< Returns the in_block flag of var as a uint32. */
502     # define var_incident(var) ((var)->flags & VAR_INCIDENT)
503     /**< Returns the incident flag of var as a uint32. */
504    
505     # define var_active(var) ((var)->flags & VAR_ACTIVE)
506     /**< Returns the active flag of var as a uint32. */
507     # define var_nonbasic(var) ((var)->flags & VAR_NONBASIC)
508     /**< Returns the nonbasic flag of var as a uint32. */
509     # define var_active_at_bnd(var) ((var)->flags & VAR_ACTIVE_AT_BND)
510     /**< Returns the active_at_bnd flag of var as a uint32. */
511     # define var_eligible(var) ((var)->flags & VAR_ELIGIBLE)
512     /**< Returns the eligible flag of var as a uint32. */
513     # define var_eligible_in_subregion(var) ((var)->flags & VAR_ELIGIBLE_IN_SUBREGION)
514     /**< Returns the eligible_in_subregion flag of var as a uint32. */
515     # define var_incident_in_case(var) ((var)->flags & VAR_INCIDENT_IN_CASE)
516     /**< Returns the incident_in_case flag of var as a uint32. */
517     # define var_potentially_fixed(var) ((var)->flags & VAR_POTENTIALLY_FIXED)
518     /**< Returns the potentially_fixed flag of var as a uint32. */
519 jds 54 #else
520 johnpye 239 # define var_in_block(var) var_flagbit((var),VAR_INBLOCK)
521     /**< Returns the in_block flag of var as a uint32. */
522    
523     # define var_incident(var) var_flagbit((var),VAR_INCIDENT)
524     /**< Returns the incident flag of var as a uint32. */
525     # define var_active(var) var_flagbit((var),VAR_ACTIVE)
526     /**< Returns the active flag of var as a uint32. */
527     # define var_nonbasic(var) var_flagbit((var),VAR_NONBASIC)
528     /**< Returns the nonbasic flag of var as a uint32. */
529     # define var_active_at_bnd(var) var_flagbit((var),VAR_ACTIVE_AT_BND)
530     /**< Returns the active_at_bnd flag of var as a uint32. */
531     # define var_eligible(var) var_flagbit((var),VAR_ELIGIBLE)
532     /**< Returns the eligible flag of var as a uint32. */
533     # define var_eligible_in_subregion(var) var_flagbit((var),VAR_ELIGIBLE_IN_SUBREGION)
534     /**< Returns the eligible_in_subregion flag of var as a uint32. */
535     # define var_incident_in_case(var) var_flagbit((var),VAR_INCIDENT_IN_CASE)
536     /**< Returns the incident_in_case flag of var as a uint32. */
537     # define var_potentially_fixed(var) var_flagbit((var),VAR_POTENTIALLY_FIXED)
538     /**< Returns the potentially_fixed flag of var as a uint32. */
539 jds 54 #endif /* NDEBUG */
540 aw0a 1
541 jds 54 #define var_set_in_block(var,oneorzero) \
542     var_set_flagbit((var),VAR_INBLOCK,(oneorzero))
543     /**< Sets the in_block flag of var on (1) or off (0). */
544     #define var_set_incident(var,oneorzero) \
545     var_set_flagbit((var),VAR_INCIDENT,(oneorzero))
546     /**< Sets the incident flag of var on (1) or off (0). */
547     #define var_set_interface(var,oneorzero) \
548     var_set_flagbit((var),VAR_INTERFACE,(oneorzero))
549     /**< Sets the interface flag of var on (1) or off (0). */
550     #define var_set_active(var,oneorzero) \
551     var_set_flagbit((var),VAR_ACTIVE,(oneorzero))
552     /**< Sets the active flag of var on (1) or off (0). */
553     #define var_set_nonbasic(var,oneorzero) \
554     var_set_flagbit((var),VAR_NONBASIC,(oneorzero))
555     /**< Sets the nonbasic flag of var on (1) or off (0). */
556     #define var_set_active_at_bnd(var,oneorzero) \
557     var_set_flagbit((var),VAR_ACTIVE_AT_BND,(oneorzero))
558     /**< Sets the active_at_bnd flag of var on (1) or off (0). */
559     #define var_set_eligible(var,oneorzero) \
560     var_set_flagbit((var),VAR_ELIGIBLE,(oneorzero))
561     /**< Sets the eligible flag of var on (1) or off (0). */
562     #define var_set_eligible_in_subregion(var,oneorzero) \
563     var_set_flagbit((var),VAR_ELIGIBLE_IN_SUBREGION,(oneorzero))
564     /**< Sets the eligible_in_subregion flag of var on (1) or off (0). */
565     #define var_set_incident_in_case(var,oneorzero) \
566     var_set_flagbit((var),VAR_INCIDENT_IN_CASE,(oneorzero))
567     /**< Sets the incident_in_case flag of var on (1) or off (0). */
568     #define var_set_potentially_fixed(var,oneorzero) \
569     var_set_flagbit((var),VAR_POTENTIALLY_FIXED,(oneorzero))
570     /**< Sets the potentially_fixed flag of var on (1) or off (0). */
571    
572 johnpye 239 extern struct var_variable **
573     var_BackendTokens_to_vars(slv_system_t sys, SlvBackendToken *tokenlist, int32 len);
574 ben.allan 33 /**<
575 johnpye 239 varp is NULL iff something is amiss, OTHERWISE it
576     contains len struct var_variable * s.
577     The user should free the array varp when done with it.
578     Some entries in the array varp may be NULL if the tokenlist
579     contains a token which is not from the sys given.
580     tokenlist[i] <--> varp[i];<br><br>
581 aw0a 1
582 johnpye 239 The whole point of a slv_system_t is to isolate the client from
583     the compiler backend. Clients who find themselves in need of
584     this function are very much in need of rethinking as well.
585     For that reason, among others, this function is not heavily
586     optimized, it is however reasonable for 1-off jobs.<br><br>
587    
588     CPU Cost = k1*complexity of the instance under sys +
589     k2*number of vars in sys + k3*len.
590    
591     @todo Hasn't been through verification and testing - SQA asleep.
592     */
593    
594 aw0a 1 /*
595     * What constitutes a solver_var (and some other interesting types)
596     * is controlled by the ascend server via the following functions.
597     * Clients shouldn't use these.
598     */
599    
600     #define SOLVER_VAR_STR "solver_var"
601     #define SOLVER_INT_STR "solver_int"
602     #define SOLVER_BINARY_STR "solver_binary"
603     #define SOLVER_SEMI_STR "solver_semi"
604    
605     #define solver_par(i) (0)
606    
607 jds 54 extern boolean solver_var(SlvBackendToken inst);
608 ben.allan 33 /**<
609 johnpye 239 Returns true if the instance in question matches the currently
610     known definition of solver_var. Since these definitions
611     involve refinement, solver_var() will report TRUE on variables
612     matching any of these types:
613     - solver_var
614     - solver_int
615     - solver_binary
616     - solver_semi
617    
618     SERVER ONLY. clients should just look at the flagbits.
619     */
620 jds 54 extern boolean solver_int(SlvBackendToken inst);
621     /**<
622 johnpye 239 Returns true if the instance in question matches the currently
623     known definition of solver_int.
624     SERVER ONLY. clients should just look at the flagbits.
625     */
626 jds 54 extern boolean solver_binary(SlvBackendToken inst);
627     /**<
628 johnpye 239 Returns true if the instance in question matches the currently
629     known definition of solver_binary.
630     SERVER ONLY. clients should just look at the flagbits.
631     */
632 jds 54 extern boolean solver_semi(SlvBackendToken inst);
633     /**<
634 johnpye 239 Returns true if the instance in question matches the currently
635     known definition of solver_semi.
636     SERVER ONLY. clients should just look at the flagbits.
637     */
638     /* For the above...
639     Note that these definitions involve refinement, so
640     solver_var will report TRUE on variables matching any of
641     these types, while solver_binary will only be TRUE on binaries.
642    
643     hierarchy is solvervar-\----solver_int-----solver_binary
644     \-solver_semi
645    
646 jds 54 */
647 aw0a 1
648     extern boolean set_solver_types(void);
649 ben.allan 33 /**<
650 johnpye 239 Sets (changes) the current definition of solver_var to match
651     the current library. Returns 1 if unsuccessful, 0 if ok.
652     If 1, it is useless to invoke the solvers.
653     Also sets all the related types listed above.
654     */
655 jds 54
656 johnpye 67 #endif /* ASC_VAR_H */
657 jds 54

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