/[ascend]/trunk/ipslv-temp/rel.all_but_eachpair.h
ViewVC logotype

Contents of /trunk/ipslv-temp/rel.all_but_eachpair.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 916 - (show annotations) (download) (as text)
Tue Oct 31 02:39:16 2006 UTC (13 years, 8 months ago) by johnpye
File MIME type: text/x-chdr
File size: 25487 byte(s)
Adding Vicente's IPSlv code (needs revising and testing against the new code)\
1 /*
2 * SLV: Ascend Numeric Solver
3 * by Karl Michael Westerberg
4 * Created: 2/6/90
5 * Version: $Revision: 1.41 $
6 * Version control file: $RCSfile: rel.h,v $
7 * Date last modified: $Date: 1998/02/05 15:59:24 $
8 * Last modified by: $Author: ballan $
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
33 /*
34 * Contents: Relation module (ascend)
35 *
36 * Authors: Karl Westerberg
37 * Joseph Zaher
38 *
39 * Dates: 06/90 - original version
40 * 04/94 - added rel_apply_filter() which uses the new
41 * rel_filter_t data structure for perfoming all
42 * relation filtering needs (eliminating the
43 * filter module)
44 *
45 * Description: This is the ascend version of the rel module. This
46 * version should be used by any user who receives his/her
47 * equations directly from an instance tree created by the
48 * ASCEND compiler.
49 */
50
51 #ifndef rel__already_included
52 #define rel__already_included
53
54 /*
55 * requires #include "var.h"
56 */
57
58 /*
59 * rel_relation data type and basic type operators.
60 */
61
62 #define rel_TOK_less 0x1
63 #define rel_TOK_equal 0x2
64 #define rel_TOK_greater 0x4
65
66 struct rel_extnode {
67 int32 whichvar;
68 struct ExtRelCache *cache; /* pointer to private structure */
69 };
70
71 enum rel_enum {
72 e_rel_minimize,
73 e_rel_maximize,
74 e_rel_equal,
75 e_rel_not_equal,
76 e_rel_less,
77 e_rel_greater,
78 e_rel_lesseq,
79 e_rel_greatereq
80 };
81 /*
82 * enum rel_enum:
83 * The exact operator of a relation.
84 */
85 enum backend_enum {
86 e_rel_token,
87 e_rel_glassbox,
88 e_rel_blackbox
89 };
90
91 struct rel_relation {
92 SlvBackendToken instance;
93 struct rel_extnode *nodeinfo; /* Not NULL if blackbox relation */
94 struct var_variable **incidence;
95 /* array of atomic vars and nonvars in rel */
96 /*
97 * For future use:
98 *
99 * struct var_variable **incidentals; array of nonvars,
100 * once solveratoms arrive.
101 *
102 * int32 n_incidentals;
103 */
104 enum backend_enum type; /* tokens, glassbox or blackbox */
105 int32 n_incidences; /* length of incidence. */
106 int32 mindex; /* index in the slv_system_t master list */
107 int32 sindex; /* index in the slv_system_t solver list */
108 int32 model; /* index of a hypothetical MODEL rel is from */
109 uint32 flags; /* flags */
110 };
111 /*
112 * if you mess with the above struct, change the defaults for it in .c file
113 */
114
115
116 extern struct rel_relation *rel_create(SlvBackendToken ,struct rel_relation *);
117 /*
118 * rel_create(instance,rel)
119 * rel = rel_create(instance,NULL)
120 * struct rel_relation *rel;
121 * SlvBackendToken instance;
122 *
123 * Creates a relation given the relation instance.
124 * If the rel supplied is NULL, we allocate the memory for the
125 * rel we return, else we just init the memory you hand us and
126 * return it to you.
127 * We set the fields instance, nodeinfo, type following
128 * the instance. Setting the rest of the information is the job
129 * of the bridge building function between the ascend instance
130 * tree (or other relation back end) and the slv_system_t.
131 * In particular, the incidence list and indexing info is not
132 * handled here.
133 */
134
135 extern void rel_destroy(struct rel_relation *);
136 /*
137 * rel_destroy(rel)
138 * struct rel_relation *rel;
139 *
140 * Destroys a relation.
141 */
142
143 extern void rel_write_name(slv_system_t,struct rel_relation *,FILE *);
144 /*
145 * rel_write_name(sys,rel,file);
146 * Writes a name to the file given. Handles NULL inputs gracefully.
147 * Does not print any whitespace, including carriage returns.
148 * Is faster than slv_print_var_name.
149 * If sys is NULL, writes full ascend name. If file or rel is NULL
150 * does not write.
151 */
152
153 typedef struct rel_filter_structure {
154 uint32 matchbits;
155 uint32 matchvalue;
156 } rel_filter_t;
157
158 extern SlvBackendToken rel_instance(struct rel_relation *);
159 /*
160 * rel_instance(rel)
161 * struct rel_relation *rel;
162 *
163 * Returns the instance pointer from a rel.
164 */
165
166
167 extern struct rel_extnode *rel_extnodeinfo(struct rel_relation *);
168 extern void rel_set_extnodeinfo(struct rel_relation *,struct rel_extnode *);
169 /*
170 * struct rel_relation *rel;
171 * struct rel_extnode *nodeinfo;
172 *
173 * struct rel_extnode *nodeinfo = rel_extnodeinfo(rel);
174 * rel_set_extnodeinfo(rel,nodeinfo);
175 * Fetches the pointer to the external node information structure for
176 * a relation. If this is NULL, which will be the case for most
177 * relations, then there are no external call nodes present.
178 */
179
180 extern int32 rel_extwhichvar(struct rel_relation *);
181 extern void rel_set_extwhichvar(struct rel_relation *,int);
182 /*
183 * struct rel_relation *rel;
184 * int32 whichvar;
185 *
186 * This applies ONLY to rels that have external nodes !
187 * Relations that have external nodes have associated with them an
188 * index into the argument list from which the relation was constructed.
189 * rel_whichvar returns that index. e.g. if when this relation was
190 * constructed from an external procedure call, the number of output
191 * variables was 4, and the number of inputs was 6, valid results from
192 * this rel_whichvar would be 7, 8, 9, 10.
193 * A return value <= 0 is an error.
194 */
195
196 extern boolean rel_less(struct rel_relation *);
197 extern boolean rel_equal(struct rel_relation *);
198 extern boolean rel_greater(struct rel_relation *);
199 /*
200 * le = rel_less(rel)
201 * eq = rel_equal(rel)
202 * gr = rel_greater(rel)
203 * boolean le,eq,gr;
204 * struct rel_relation *rel;
205 *
206 * Returns true if the given relation is satisfied if the
207 * operator in question is among those that make up the
208 * comparator of the relation. (e.g. rel_less is satisfied
209 * by (<>,<.<=).
210 * le==TRUE implies rel would be satisfied if lhs < rhs
211 * gr==TRUE implies rel would be satisfied if lhs > rhs
212 * eq==TRUE implies rel would be satisfied if lhs ~ rhs
213 */
214
215 extern enum rel_enum rel_relop(struct rel_relation *);
216 /*
217 * relop = rel_relop(rel);
218 * rel_enum relop;
219 * struct rel_relation *rel;
220 * Returns the type of the relational operator of a given relation.
221 */
222
223 extern char *rel_make_name(slv_system_t,struct rel_relation *);
224 /*
225 * name = rel_make_name(sys,rel)
226 * slv_system_t sys;
227 * struct rel_relation *rel;
228 * char *name;
229 *
230 * Copies of the relation instance name can be made and returned.
231 * The string returned should be freed when no longer in use.
232 */
233
234 extern int32 rel_mindex(struct rel_relation *);
235 extern void rel_set_mindex(struct rel_relation *,int32);
236 /*
237 * index = rel_mindex(rel)
238 * rel_set_mindex(rel,index)
239 * int32 index;
240 * struct rel_relation *rel;
241 *
242 * Sets or retrieves the index number of the given relation as it
243 * appears in a slv_system_t master relation list.
244 */
245
246 extern int32 rel_sindex(const struct rel_relation *);
247 extern void rel_set_sindex(struct rel_relation *,int32);
248 /*
249 * index = rel_sindex(rel)
250 * rel_set_sindex(rel,index)
251 * int32 index;
252 * struct rel_relation *rel;
253 *
254 * Sets or retrieves the index number of the given relation as it
255 * appears in a solvers relation list. The index is most often used
256 * to assign the relation to a specific original row of a matrix.
257 */
258
259
260 extern int32 rel_model(const struct rel_relation *);
261 extern void rel_set_model(struct rel_relation *,int32);
262 /*
263 * index = rel_model(rel)
264 * rel_set_model(rel,index) //SERVER ONLY
265 * int32 index;
266 * struct rel_relation *rel;
267 *
268 * Sets or retrieves the model number of the given relation.
269 * In a hierarchy, relations come in groups associated with
270 * models. Models are numbered from 1 to some upper limit.
271 */
272
273 extern real64 rel_residual(struct rel_relation *);
274 extern void rel_set_residual(struct rel_relation *,real64);
275 /*
276 * residual = rel_residual(rel)
277 * rel_set_residual(rel,residual)
278 * real64 residual;
279 * struct rel_relation *rel;
280 *
281 * Sets or retrieves the residual field of the given relation.
282 * Note that the residual is not actually computed by rel_residual:
283 * there is no guarantee (from this function) that the residual is
284 * actually correct.
285 */
286
287 extern real64 rel_nominal(struct rel_relation *);
288 /*
289 * nominal = rel_nominal(rel)
290 * real64 nominal;
291 * struct rel_relation *rel;
292 *
293 * Retrieves the nominal field of the given relation.
294 * No slv client has any business being able to set the nominal,
295 * so no such operator is provided.
296 */
297
298 extern void rel_set_nominal(struct rel_relation *,real64);
299 /*
300 * Breaking above 'rule' for time being
301 */
302
303 #ifdef NDEBUG
304 #define rel_n_incidences(r) ((r)->n_incidences)
305 #define rel_set_incidences(r,n,ilist) \
306 (r)->n_incidences=(n); (r)->incidence = (ilist)
307 #else
308 #define rel_n_incidences(r) rel_n_incidencesF(r)
309 #define rel_set_incidences(r,n,ilist) rel_set_incidencesF((r),(n),(ilist))
310 #endif /* NDEBUG */
311
312 extern int32 rel_n_incidencesF(struct rel_relation *);
313 extern void rel_set_incidencesF(struct rel_relation *,
314 int32,struct var_variable **);
315 /*
316 * rel_n_incidences(rel)
317 * rel_set_incidences(rel,n,ilist) //SERVER ONLY
318 * struct rel_relation *rel;
319 * struct var_variable **ilist;
320 * int32 n;
321 *
322 * rel_n_incidences returns the length of the incidence_list.
323 * Not everything in the incidence list is necessarily a
324 * variable for your particular solver -- check the flags.
325 * Solver clients should not call rel_set_incidences,
326 * it is only for use by constructors of bridges to relation
327 * back ends.
328 */
329
330 extern const struct var_variable **rel_incidence_list(struct rel_relation *);
331 extern struct var_variable
332 **rel_incidence_list_to_modify(struct rel_relation *);
333 /*
334 * va = rel_incidence_list(rel)
335 * struct rel_relation *rel;
336 * struct var_variable **va;
337 *
338 * Returns a pointer to an array rel_n_incidences(rel) long of vars.
339 * Each element of the array is a struct var_variable *.
340 * Check the var sindex to see where each might go in a jacobian.
341 * If there is no incidence, NULL is returned.
342 * Pointers in this array will be unique.
343 * The list belongs to the relation. Do not destroy it. Do not change it.
344 *
345 * VA IS NOT a NULL-TERMINATED LIST.
346 */
347
348 /*
349 * relation filtration functions.
350 * We have a lot (32) of binary (one bit) flags a client may want to query
351 * in arbitrary combinations and paying attention to only certain of
352 * the bits. We will provide a set of macros and functions for each of
353 * these bits and for operations on the whole set.
354 */
355
356 extern int32 rel_apply_filter(const struct rel_relation *,rel_filter_t *);
357 /*
358 * value = rel_apply_filter(rel,filter)
359 * int32 value;
360 * struct rel_relation *rel;
361 * rel_filter_t *filter;
362 *
363 * Returns 1 only if all of the positions specified in
364 * filter->matchbits have the same values in
365 * filter->matchvalue and the relation's flags value.
366 * Bits set to 0 in filter->matchbits are ignored for the test.
367 *
368 * EXAMPLE:
369 * To find out if a relation is an unsatisfied equality:
370 * We don't care about anything except satisfaction and equality,
371 * so set filter->matchbits = (REL_SATISFIED | REL_EQUALITY);
372 * We want relation NOT satisfied, so leave REL_SATISFIED = 0
373 * in filter->matchvalue, i.e. filter->matchvalue = REL_EQUALITY;
374 * Usually it is most convenient to just declare a rel_filter_t filt;
375 * locally in a function and then take the address of it (&filt) after
376 * setting filt.matchbits = (| of all your interesting bits) and
377 * setting filt.matchvalue = (| of the bits you want to be TRUE).
378 */
379
380 extern uint32 rel_flags(struct rel_relation *);
381 extern void rel_set_flags(struct rel_relation *,uint32);
382 /*
383 * struct rel_relation *rel;
384 * uint32 flags;
385 *
386 * rel_flags(rel) returns the flags field of the relation.
387 * rel_set_flags(rel,flags) sets the entire flag field to the
388 * value of flags given.
389 */
390
391 extern uint32 rel_flagbit(struct rel_relation *,uint32);
392 /*
393 * rel_flagbit(rel,name);
394 * struct rel_relation *rel;
395 * uint32 name;
396 * name should be a REL_xx flag defined above)
397 * Returns the value of the bit specified from the relation flags.
398 */
399
400 extern void rel_set_flagbit(struct rel_relation *,uint32, uint32);
401 /*
402 * struct rel_relation *rel;
403 * uint32 NAME,oneorzero;
404 * rel_set_flagbit(rel,NAME,oneorzero)
405 *
406 * Sets the bit, which should be referred to by its macro name,
407 * on if oneorzero is >0 and off is oneorzero is 0.
408 * The macro names are the defined up at the top of this file.
409 *
410 * Example: rel_set_flags(rel,REL_PARTITION,1) turns on the
411 * REL_PARTITION bit.
412 * What it really does is:
413 * if (oneorzero) {
414 * rel->flags |= field;
415 * } else {
416 * rel->flags &= ~field;
417 * }
418 * In unix, see also man 3f bit or man not.
419 */
420
421 /*
422 * the bit flags. explained afterward. several are for use of
423 * transient clients and should be ignored by solver engines
424 */
425 #define REL_PARTITION 0x1
426 #define REL_TORN 0x2
427 #define REL_INTERFACE 0x4
428 #define REL_INCLUDED 0x8
429 /*
430 * INCLUDED is as yet a funny one. treat it as readonly because
431 * you can only change it using a real function and not the
432 * bit manipulation functions. It is here in the bits because
433 * it is useful in filters sometimes.
434 */
435 #define REL_OBJNEGATE 0x10
436 #define REL_BLACKBOX 0x20
437 #define REL_SATISFIED 0x40
438 #define REL_EQUALITY 0x80
439 #define REL_INBLOCK 0x100
440 /* Conditional Modeling */
441 #define REL_INWHEN 0x200
442 #define REL_ACTIVE 0x400
443 #define REL_INVARIANT 0x800
444 /* Conditional Relations (Boundaries) */
445 #define REL_CONDITIONAL 0x1000
446 #define REL_IN_CUR_SUBREGION 0x2000
447 /*
448 * temporary relation that doesn't exist independently in the backend,
449 * but is made by some process of the backend or the solver client.
450 */
451 #define REL_COMPLEMENTARY 0x4000
452 #define REL_GENERATED 0x10000
453
454 /*
455 * REL_PARTITION reordering clients. is it in the interesting region
456 * REL_TORN reordering clients output. is it a tear.
457 * REL_INTERFACE solvers, ui clients. user suggests it's a tear eqn.
458 * REL_INCLUDED solvers, ui clients. user wants eqn in problem.
459 * bit should be treated as readonly. use rel_set_*
460 * to change.
461 * REL_OBJNEGATE rel module. read_only for clients.
462 * REL_BLACKBOX rel module. read_only for clients.
463 * REL_SATISFIED has rel been pronounced satisfied by someone?
464 * bit should be treated as readonly. use rel_set_*
465 * to change.
466 * REL_EQUALITY is relation an equality? readonly for clients.
467 * REL_INBLOCK is the relation in the current block of registered
468 * client? for clients.
469 * REL_INWHEN is relation in a when? readonly for clients.
470 * REL_ACTIVE is this relation currently a part of my problem ?
471 * REL_INVARIANT is this relation an invariant in the conditional
472 * modeling analysis
473 * REL_CONDITIONAL is relation conditional? readonly for clients
474 * REL_IN_CUR_SUBREGION is the relation in the subregion currently
475 * analyzed ?
476 * REL_COMPLEMENTARY Does this relation contain solely complementarity
477 * pairs ?
478 * REL_GENERATED is rel fake and cooked up for this system only?
479 */
480
481 /*
482 * the bit flag lookups
483 */
484 #ifdef NDEBUG
485 #define rel_partition(r) ((r)->flags & REL_PARTITION)
486 #define rel_torn(r) ((r)->flags & REL_TORN)
487 #define rel_interface(r) ((r)->flags & REL_INTERFACE)
488 #define rel_obj_negate(r) ((r)->flags & REL_OBJNEGATE)
489 #define rel_blackbox(r) ((r)->flags & REL_BLACKBOX)
490 #define rel_satisfied(r) ((r)->flags & REL_SATISFIED)
491 #define rel_equality(r) ((r)->flags & REL_EQUALITY)
492 #define rel_in_block(r) ((r)->flags & REL_INBLOCK)
493 #define rel_in_when(r) ((r)->flags & REL_INWHEN)
494 #define rel_active(r) ((r)->flags & REL_ACTIVE)
495 #define rel_invariant(r) ((r)->flags & REL_INVARIANT)
496 #define rel_conditional(r) ((r)->flags & REL_CONDITIONAL)
497 #define rel_in_cur_subregion(r) ((r)->flags & REL_IN_CUR_SUBREGION)
498 #define rel_generated(r) ((r)->flags & REL_GENERATED)
499 #define rel_complementary(r) ((r)->flags & REL_COMPLEMENTARY)
500 #else
501 #define rel_partition(r) rel_flagbit((r),REL_PARTITION)
502 #define rel_torn(r) rel_flagbit((r),REL_TORN)
503 #define rel_interface(r) rel_flagbit((r),REL_INTERFACE)
504 #define rel_obj_negate(r) rel_flagbit((r),REL_OBJNEGATE)
505 #define rel_blackbox(r) rel_flagbit((r),REL_BLACKBOX)
506 #define rel_satisfied(r) rel_flagbit((r),REL_SATISFIED)
507 #define rel_equality(r) rel_flagbit((r),REL_EQUALITY)
508 #define rel_in_block(r) rel_flagbit((r),REL_INBLOCK)
509 #define rel_in_when(r) rel_flagbit((r),REL_INWHEN)
510 #define rel_active(r) rel_flagbit((r),REL_ACTIVE)
511 #define rel_invariant(r) rel_flagbit((r),REL_INVARIANT)
512 #define rel_conditional(r) rel_flagbit((r),REL_CONDITIONAL)
513 #define rel_in_cur_subregion(r) rel_flagbit((r),REL_IN_CUR_SUBREGION)
514 #define rel_generated(r) rel_flagbit((r),REL_GENERATED)
515 #define rel_complementary(r) rel_flagbit((r),REL_COMPLEMENTARY)
516 #endif /* NDEBUG */
517
518 /*
519 * bit flag assignments. any value other than 0 for bv turns the
520 * named flag to 1. 0 sets it to 0.
521 * Many of these bits have read-only semantics for clients.
522 * Take care when setting them.
523 */
524 #define rel_set_partition(r,bv) rel_set_flagbit((r),REL_PARTITION,(bv))
525 #define rel_set_torn(r,bv) rel_set_flagbit((r),REL_TORN,(bv))
526 #define rel_set_interface(r,bv) rel_set_flagbit((r),REL_INTERFACE,(bv))
527 #define rel_set_obj_negate(r,bv) rel_set_flagbit((r),REL_OBJNEGATE,(bv))
528 #define rel_set_blackbox(r,bv) rel_set_flagbit((r),REL_BLACKBOX,(bv))
529 #define rel_set_satisfied(r,bv) rel_set_flagbit((r),REL_SATISFIED,(bv))
530 #define rel_set_equality(r,bv) rel_set_flagbit((r),REL_EQUALITY,(bv))
531 #define rel_set_in_block(r,bv) rel_set_flagbit((r),REL_INBLOCK,(bv))
532 #define rel_set_in_when(r,bv) rel_set_flagbit((r),REL_INWHEN,(bv))
533 #define rel_set_active(r,bv) rel_set_flagbit((r),REL_ACTIVE,(bv))
534 #define rel_set_invariant(r,bv) rel_set_flagbit((r),REL_INVARIANT,(bv))
535 #define rel_set_conditional(r,bv) \
536 rel_set_flagbit((r),REL_CONDITIONAL,(bv))
537 #define rel_set_in_cur_subregion(r,bv) \
538 rel_set_flagbit((r),REL_IN_CUR_SUBREGION,(bv))
539 #define rel_set_generated(r,bv) rel_set_flagbit((r),REL_GENERATED,(bv))
540 #define rel_set_complementary(r,bv) rel_set_flagbit((r),REL_COMPLEMENTARY,(bv))
541
542 extern uint32 rel_included(struct rel_relation *);
543 extern void rel_set_included(struct rel_relation *,uint32);
544 /*
545 * included = rel_included(rel)
546 * rel_set_included(rel,included)
547 * uint32 included;
548 * struct rel_relation *rel;
549 *
550 * Sets or retrieves the included field of the given relation.
551 * This has side effect on the ascend instance, so it isn't
552 * implemented with the rest of the macros above. This needs to
553 * change.
554 */
555
556 /*
557 * in_block = rel_in_block(rel)
558 * rel_set_in_block(rel,in_block)
559 * uint32 in_block;
560 * struct rel_relation *rel;
561 *
562 * Sets or retrieves the INBLOCK member of the given relation flags
563 * which determines if the relation is within the current block.
564 */
565
566 /*
567 * rel_obj_negate(rel)
568 * struct rel_relation *rel;
569 *
570 * Returns TRUE if relation is of type e_maximize.
571 * Returns FALSE if relation is of type e_minimize.
572 * Note: should only be used on objectives. other relations
573 * will give a meaningless result (probably FALSE).
574 */
575
576 /*
577 * satisfied = rel_satisfied(rel)
578 * rel_set_satisfied(rel,satisfied)
579 * uint32 satisfied;
580 * struct rel_relation *rel;
581 *
582 * Sets or retrieves the satisfied field of the given relation (see
583 * rel_residual() for disclaimer).
584 */
585
586 /*
587 * equality = rel_equality(rel)
588 * rel_set_equality(rel,equality)
589 * uint32 equality;
590 * struct rel_relation *rel;
591 *
592 * TRUE if relation is of form lhs = rhs.
593 */
594
595 extern real64 rel_multiplier(struct rel_relation *);
596 extern void rel_set_multiplier(struct rel_relation *,real64);
597 /*
598 * (won a temporary reprieve. this should be a system property, not rel.)
599 * multiplier = rel_multiplier(rel)
600 * rel_set_multiplier(rel,multiplier)
601 * real64 multiplier;
602 * struct rel_relation *rel;
603 *
604 * Sets or retrieves the multiplier field of the given relation.
605 * This is expected to be computed as a lagrange multiplier which will
606 * relate the gradient of the relation rel with that of some objective
607 * function.
608 */
609
610 /*
611 * rel_relation utility functions.
612 *
613 * Things for the server side only. Not visible to clients.
614 *
615 * Ok, really nosy clients courting death can cheat. Don't cry when
616 * they break.
617 * We make absolutely no commitment to being compatible with this portion
618 * of the header at any time in the future.
619 */
620 #ifdef _SLV_SERVER_C_SEEN_
621 /*
622 *requires #include "expr.h"
623 * requires #include "types.h"
624 * requires #include "extfunc.h"
625 * requires #include "relation.h"
626 * requires #include "packages.h"
627 * requires #include "extcall.h"
628 * requires #include "mtx.h"
629 */
630
631 extern double g_external_tolerance; /* DEFAULT 1e-12 */
632
633 struct ExtRelCache {
634 int32 nodestamp;
635 struct ExternalFunc *efunc; /* pre_slv, eval and deriv funcs */
636 SlvBackendToken data; /* only passed on pre_slv */
637 struct gl_list_t *arglist; /* only passed on pre_slv */
638 struct gl_list_t *inputlist;
639 void *user_data; /* user data */
640 int32 ninputs, noutputs;
641 double *inputs;
642 double *outputs;
643 double *jacobian;
644 unsigned newcalc_done :1; /* bits needed to control */
645 unsigned first_func_eval :1; /* recalculation. until we can */
646 unsigned first_deriv_eval :1; /* do proper block coding */
647 };
648
649 extern struct ExtRelCache *rel_extcache(struct rel_relation *);
650 extern void rel_set_extcache(struct rel_relation *,struct ExtRelCache *);
651 /*
652 * cache = rel_extcache(rel);
653 * rel_set_extcache(rel,cache);
654 * struct rel_relation *rel;
655 * struct ExtRelCache *cache;
656 *
657 * This applies ONLY to rels that have external nodes !
658 * Ensure this by calling rel_extnodeinfo FIRST !
659 * This is the gateway to the external relation information
660 * stashed away to make processing of external relations efficient.
661 * See the file extrel.[ch] for functions to deal with the external
662 * relations cache, unless of course you are a client in which CASE
663 * don't.
664 */
665
666 /*
667 * The following aren't commented because Kirk Abbott didn't comment them.
668 * It's all server magic anyway?
669 */
670
671 extern struct ExtRelCache *CreateExtRelCache(struct ExtCallNode *);
672 struct ExtRelCache *CreateCacheFromInstance(SlvBackendToken);
673 extern void ExtRel_DestroyCache(struct ExtRelCache *);
674 extern int32 ExtRel_PreSolve(struct ExtRelCache *, int32 setup);
675 extern real64 ExtRel_Evaluate_RHS(struct rel_relation *);
676 extern real64 ExtRel_Evaluate_LHS(struct rel_relation *);
677 extern real64 ExtRel_Diffs_RHS(struct rel_relation *, var_filter_t *,
678 int32, mtx_matrix_t);
679 extern real64 ExtRel_Diffs_LHS(struct rel_relation *, var_filter_t *,
680 int32, mtx_matrix_t); /* not implemented */
681
682 #endif /* _SLV_SERVER_C_SEEN_ */
683
684 /*
685 * Things dead.
686 */
687 /* DEFUNCT
688 * extern struct rel_relation *rel_objcreate(SlvBackendToken, boolean);
689 * rel = rel_objcreate(instance,negate)
690 * struct rel_relation *rel;
691 * boolean negate;
692 * SlvBackendToken instance;
693 *
694 * Creates an objective relation given the relation instance.
695 * The other fields are given default values. The lhs will be NULL.
696 * objrels may not have extrel caches. Use a dummy relation if
697 * necessary. Negate must be TRUE for a maximize relation, FALSE for
698 * a minimize relation.
699 */
700
701 /* DEFUNCT
702 * If you're smart enough to understand the answer to this question,
703 * then you should be asking the instance directly, not asking us.
704 * extern enum rel_enum rel_type(struct rel_relation *);
705 * rtype = rel_type(rel);
706 * rel_enum rtype;
707 * struct rel_relation *rel;
708 * Returns the type of a given relation. This indicates whether the
709 * the relation is a token, opcode, glassbox, or blackbox relation.
710 */
711
712 /* DEFUNCT for now.
713 * extern boolean rel_in_subregion(struct rel_relation *);
714 * in_subregion = rel_in_subregion(rel)
715 * boolean in_subregion;
716 * struct rel_relation *rel;
717 *
718 * Computes if the conditions of the relation are all met by the
719 * current values of the subregion field of each relevant boundary.
720 * It will return TRUE even if there are no conditions.
721 */
722
723 /* DEFUNCT the solver has no business knowing about sides. this is the
724 * compilers job. temporarily still active.
725 * extern expr_t rel_lhs(struct rel_relation *);
726 * extern expr_t rel_rhs(struct rel_relation *);
727 * lhs = rel_lhs(rel)
728 * rhs = rel_rhs(rel)
729 * expr_t lhs,rhs;
730 * struct rel_relation *rel;
731 *
732 * Fetches the (internal copy of the) rhs and lhs of the relation.
733 * The user should not modify the expression, nor should the user
734 * use the expression after the relation is destroyed or the
735 * lhs/rhs has been re-set.
736 */
737
738
739 #endif /* rel__already_included */

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