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

Contents of /trunk/ipslv-temp/rel.allterms.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: 25809 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_COMP_TERM 0x8000
453 #define REL_GENERATED 0x10000
454
455 /*
456 * REL_PARTITION reordering clients. is it in the interesting region
457 * REL_TORN reordering clients output. is it a tear.
458 * REL_INTERFACE solvers, ui clients. user suggests it's a tear eqn.
459 * REL_INCLUDED solvers, ui clients. user wants eqn in problem.
460 * bit should be treated as readonly. use rel_set_*
461 * to change.
462 * REL_OBJNEGATE rel module. read_only for clients.
463 * REL_BLACKBOX rel module. read_only for clients.
464 * REL_SATISFIED has rel been pronounced satisfied by someone?
465 * bit should be treated as readonly. use rel_set_*
466 * to change.
467 * REL_EQUALITY is relation an equality? readonly for clients.
468 * REL_INBLOCK is the relation in the current block of registered
469 * client? for clients.
470 * REL_INWHEN is relation in a when? readonly for clients.
471 * REL_ACTIVE is this relation currently a part of my problem ?
472 * REL_INVARIANT is this relation an invariant in the conditional
473 * modeling analysis
474 * REL_CONDITIONAL is relation conditional? readonly for clients
475 * REL_IN_CUR_SUBREGION is the relation in the subregion currently
476 * analyzed ?
477 * REL_COMPLEMENTARY Does this relation contain solely complementarity
478 * pairs ?
479 * REL_COMP_TERM Does this relation contain only one complementarity
480 * pair ?
481 * REL_GENERATED is rel fake and cooked up for this system only?
482 */
483
484 /*
485 * the bit flag lookups
486 */
487 #ifdef NDEBUG
488 #define rel_partition(r) ((r)->flags & REL_PARTITION)
489 #define rel_torn(r) ((r)->flags & REL_TORN)
490 #define rel_interface(r) ((r)->flags & REL_INTERFACE)
491 #define rel_obj_negate(r) ((r)->flags & REL_OBJNEGATE)
492 #define rel_blackbox(r) ((r)->flags & REL_BLACKBOX)
493 #define rel_satisfied(r) ((r)->flags & REL_SATISFIED)
494 #define rel_equality(r) ((r)->flags & REL_EQUALITY)
495 #define rel_in_block(r) ((r)->flags & REL_INBLOCK)
496 #define rel_in_when(r) ((r)->flags & REL_INWHEN)
497 #define rel_active(r) ((r)->flags & REL_ACTIVE)
498 #define rel_invariant(r) ((r)->flags & REL_INVARIANT)
499 #define rel_conditional(r) ((r)->flags & REL_CONDITIONAL)
500 #define rel_in_cur_subregion(r) ((r)->flags & REL_IN_CUR_SUBREGION)
501 #define rel_generated(r) ((r)->flags & REL_GENERATED)
502 #define rel_complementary(r) ((r)->flags & REL_COMPLEMENTARY)
503 #define rel_comp_term(r) ((r)->flags & REL_COMP_TERM)
504 #else
505 #define rel_partition(r) rel_flagbit((r),REL_PARTITION)
506 #define rel_torn(r) rel_flagbit((r),REL_TORN)
507 #define rel_interface(r) rel_flagbit((r),REL_INTERFACE)
508 #define rel_obj_negate(r) rel_flagbit((r),REL_OBJNEGATE)
509 #define rel_blackbox(r) rel_flagbit((r),REL_BLACKBOX)
510 #define rel_satisfied(r) rel_flagbit((r),REL_SATISFIED)
511 #define rel_equality(r) rel_flagbit((r),REL_EQUALITY)
512 #define rel_in_block(r) rel_flagbit((r),REL_INBLOCK)
513 #define rel_in_when(r) rel_flagbit((r),REL_INWHEN)
514 #define rel_active(r) rel_flagbit((r),REL_ACTIVE)
515 #define rel_invariant(r) rel_flagbit((r),REL_INVARIANT)
516 #define rel_conditional(r) rel_flagbit((r),REL_CONDITIONAL)
517 #define rel_in_cur_subregion(r) rel_flagbit((r),REL_IN_CUR_SUBREGION)
518 #define rel_generated(r) rel_flagbit((r),REL_GENERATED)
519 #define rel_complementary(r) rel_flagbit((r),REL_COMPLEMENTARY)
520 #define rel_comp_term(r) rel_flagbit((r),REL_COMP_TERM)
521 #endif /* NDEBUG */
522
523 /*
524 * bit flag assignments. any value other than 0 for bv turns the
525 * named flag to 1. 0 sets it to 0.
526 * Many of these bits have read-only semantics for clients.
527 * Take care when setting them.
528 */
529 #define rel_set_partition(r,bv) rel_set_flagbit((r),REL_PARTITION,(bv))
530 #define rel_set_torn(r,bv) rel_set_flagbit((r),REL_TORN,(bv))
531 #define rel_set_interface(r,bv) rel_set_flagbit((r),REL_INTERFACE,(bv))
532 #define rel_set_obj_negate(r,bv) rel_set_flagbit((r),REL_OBJNEGATE,(bv))
533 #define rel_set_blackbox(r,bv) rel_set_flagbit((r),REL_BLACKBOX,(bv))
534 #define rel_set_satisfied(r,bv) rel_set_flagbit((r),REL_SATISFIED,(bv))
535 #define rel_set_equality(r,bv) rel_set_flagbit((r),REL_EQUALITY,(bv))
536 #define rel_set_in_block(r,bv) rel_set_flagbit((r),REL_INBLOCK,(bv))
537 #define rel_set_in_when(r,bv) rel_set_flagbit((r),REL_INWHEN,(bv))
538 #define rel_set_active(r,bv) rel_set_flagbit((r),REL_ACTIVE,(bv))
539 #define rel_set_invariant(r,bv) rel_set_flagbit((r),REL_INVARIANT,(bv))
540 #define rel_set_conditional(r,bv) \
541 rel_set_flagbit((r),REL_CONDITIONAL,(bv))
542 #define rel_set_in_cur_subregion(r,bv) \
543 rel_set_flagbit((r),REL_IN_CUR_SUBREGION,(bv))
544 #define rel_set_generated(r,bv) rel_set_flagbit((r),REL_GENERATED,(bv))
545 #define rel_set_complementary(r,bv) rel_set_flagbit((r),REL_COMPLEMENTARY,(bv))
546 #define rel_set_comp_term(r,bv) rel_set_flagbit((r),REL_COMP_TERM,(bv))
547
548 extern uint32 rel_included(struct rel_relation *);
549 extern void rel_set_included(struct rel_relation *,uint32);
550 /*
551 * included = rel_included(rel)
552 * rel_set_included(rel,included)
553 * uint32 included;
554 * struct rel_relation *rel;
555 *
556 * Sets or retrieves the included field of the given relation.
557 * This has side effect on the ascend instance, so it isn't
558 * implemented with the rest of the macros above. This needs to
559 * change.
560 */
561
562 /*
563 * in_block = rel_in_block(rel)
564 * rel_set_in_block(rel,in_block)
565 * uint32 in_block;
566 * struct rel_relation *rel;
567 *
568 * Sets or retrieves the INBLOCK member of the given relation flags
569 * which determines if the relation is within the current block.
570 */
571
572 /*
573 * rel_obj_negate(rel)
574 * struct rel_relation *rel;
575 *
576 * Returns TRUE if relation is of type e_maximize.
577 * Returns FALSE if relation is of type e_minimize.
578 * Note: should only be used on objectives. other relations
579 * will give a meaningless result (probably FALSE).
580 */
581
582 /*
583 * satisfied = rel_satisfied(rel)
584 * rel_set_satisfied(rel,satisfied)
585 * uint32 satisfied;
586 * struct rel_relation *rel;
587 *
588 * Sets or retrieves the satisfied field of the given relation (see
589 * rel_residual() for disclaimer).
590 */
591
592 /*
593 * equality = rel_equality(rel)
594 * rel_set_equality(rel,equality)
595 * uint32 equality;
596 * struct rel_relation *rel;
597 *
598 * TRUE if relation is of form lhs = rhs.
599 */
600
601 extern real64 rel_multiplier(struct rel_relation *);
602 extern void rel_set_multiplier(struct rel_relation *,real64);
603 /*
604 * (won a temporary reprieve. this should be a system property, not rel.)
605 * multiplier = rel_multiplier(rel)
606 * rel_set_multiplier(rel,multiplier)
607 * real64 multiplier;
608 * struct rel_relation *rel;
609 *
610 * Sets or retrieves the multiplier field of the given relation.
611 * This is expected to be computed as a lagrange multiplier which will
612 * relate the gradient of the relation rel with that of some objective
613 * function.
614 */
615
616 /*
617 * rel_relation utility functions.
618 *
619 * Things for the server side only. Not visible to clients.
620 *
621 * Ok, really nosy clients courting death can cheat. Don't cry when
622 * they break.
623 * We make absolutely no commitment to being compatible with this portion
624 * of the header at any time in the future.
625 */
626 #ifdef _SLV_SERVER_C_SEEN_
627 /*
628 *requires #include "expr.h"
629 * requires #include "types.h"
630 * requires #include "extfunc.h"
631 * requires #include "relation.h"
632 * requires #include "packages.h"
633 * requires #include "extcall.h"
634 * requires #include "mtx.h"
635 */
636
637 extern double g_external_tolerance; /* DEFAULT 1e-12 */
638
639 struct ExtRelCache {
640 int32 nodestamp;
641 struct ExternalFunc *efunc; /* pre_slv, eval and deriv funcs */
642 SlvBackendToken data; /* only passed on pre_slv */
643 struct gl_list_t *arglist; /* only passed on pre_slv */
644 struct gl_list_t *inputlist;
645 void *user_data; /* user data */
646 int32 ninputs, noutputs;
647 double *inputs;
648 double *outputs;
649 double *jacobian;
650 unsigned newcalc_done :1; /* bits needed to control */
651 unsigned first_func_eval :1; /* recalculation. until we can */
652 unsigned first_deriv_eval :1; /* do proper block coding */
653 };
654
655 extern struct ExtRelCache *rel_extcache(struct rel_relation *);
656 extern void rel_set_extcache(struct rel_relation *,struct ExtRelCache *);
657 /*
658 * cache = rel_extcache(rel);
659 * rel_set_extcache(rel,cache);
660 * struct rel_relation *rel;
661 * struct ExtRelCache *cache;
662 *
663 * This applies ONLY to rels that have external nodes !
664 * Ensure this by calling rel_extnodeinfo FIRST !
665 * This is the gateway to the external relation information
666 * stashed away to make processing of external relations efficient.
667 * See the file extrel.[ch] for functions to deal with the external
668 * relations cache, unless of course you are a client in which CASE
669 * don't.
670 */
671
672 /*
673 * The following aren't commented because Kirk Abbott didn't comment them.
674 * It's all server magic anyway?
675 */
676
677 extern struct ExtRelCache *CreateExtRelCache(struct ExtCallNode *);
678 struct ExtRelCache *CreateCacheFromInstance(SlvBackendToken);
679 extern void ExtRel_DestroyCache(struct ExtRelCache *);
680 extern int32 ExtRel_PreSolve(struct ExtRelCache *, int32 setup);
681 extern real64 ExtRel_Evaluate_RHS(struct rel_relation *);
682 extern real64 ExtRel_Evaluate_LHS(struct rel_relation *);
683 extern real64 ExtRel_Diffs_RHS(struct rel_relation *, var_filter_t *,
684 int32, mtx_matrix_t);
685 extern real64 ExtRel_Diffs_LHS(struct rel_relation *, var_filter_t *,
686 int32, mtx_matrix_t); /* not implemented */
687
688 #endif /* _SLV_SERVER_C_SEEN_ */
689
690 /*
691 * Things dead.
692 */
693 /* DEFUNCT
694 * extern struct rel_relation *rel_objcreate(SlvBackendToken, boolean);
695 * rel = rel_objcreate(instance,negate)
696 * struct rel_relation *rel;
697 * boolean negate;
698 * SlvBackendToken instance;
699 *
700 * Creates an objective relation given the relation instance.
701 * The other fields are given default values. The lhs will be NULL.
702 * objrels may not have extrel caches. Use a dummy relation if
703 * necessary. Negate must be TRUE for a maximize relation, FALSE for
704 * a minimize relation.
705 */
706
707 /* DEFUNCT
708 * If you're smart enough to understand the answer to this question,
709 * then you should be asking the instance directly, not asking us.
710 * extern enum rel_enum rel_type(struct rel_relation *);
711 * rtype = rel_type(rel);
712 * rel_enum rtype;
713 * struct rel_relation *rel;
714 * Returns the type of a given relation. This indicates whether the
715 * the relation is a token, opcode, glassbox, or blackbox relation.
716 */
717
718 /* DEFUNCT for now.
719 * extern boolean rel_in_subregion(struct rel_relation *);
720 * in_subregion = rel_in_subregion(rel)
721 * boolean in_subregion;
722 * struct rel_relation *rel;
723 *
724 * Computes if the conditions of the relation are all met by the
725 * current values of the subregion field of each relevant boundary.
726 * It will return TRUE even if there are no conditions.
727 */
728
729 /* DEFUNCT the solver has no business knowing about sides. this is the
730 * compilers job. temporarily still active.
731 * extern expr_t rel_lhs(struct rel_relation *);
732 * extern expr_t rel_rhs(struct rel_relation *);
733 * lhs = rel_lhs(rel)
734 * rhs = rel_rhs(rel)
735 * expr_t lhs,rhs;
736 * struct rel_relation *rel;
737 *
738 * Fetches the (internal copy of the) rhs and lhs of the relation.
739 * The user should not modify the expression, nor should the user
740 * use the expression after the relation is destroyed or the
741 * lhs/rhs has been re-set.
742 */
743
744
745 #endif /* rel__already_included */

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