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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *

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