/[ascend]/trunk/ascend/system/block.h
ViewVC logotype

Contents of /trunk/ascend/system/block.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2385 - (show annotations) (download) (as text)
Wed Feb 9 03:44:19 2011 UTC (13 years, 4 months ago) by jpye
File MIME type: text/x-chdr
File size: 7111 byte(s)
woops
1 /* ASCEND modelling environment
2 Copyright (C) 1998, 2006 Carnegie Mellon University
3 Copyright (C) 1996 Benjamin Andrew Allan
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19 *//** @defgroup system_block System Block Partitioning
20 Block partitioning gets done by a selected solver engine, at its
21 discretion. See functions 'structural_analysis' in slv3 and others.
22
23 @NOTE 'BLT' = block lower triangular, 'BUT' = block upper triangular.
24 *//*
25 by Benjamin Andrew Allan
26 5/19/96
27 Last in CVS: $Revision: 1.8 $ $Date: 1998/06/16 16:53:07 $ $Author: mthomas $
28 */
29
30 #ifndef ASC_SLV_BLOCK_H
31 #define ASC_SLV_BLOCK_H
32
33 #include <ascend/system/slv_types.h>
34 #include <stdio.h>
35 #include <ascend/linear/mtx_reorder.h>
36
37 #include <ascend/system/var.h>
38 #include <ascend/system/rel.h>
39
40 /** @addtogroup system_block
41 @{
42 */
43
44 /*------------------------------------------------------------------------------
45 BLOCK PARTITIONING
46 */
47
48 #define slv_block_partition(s) slv_block_partition_real((s),0)
49 /**< do block lower triangular permutation to system solver's lists */
50
51 #define slv_block_partition_upper(s) slv_block_partition_real((s),1)
52 /**< do block upper triangular permutation to system solver's lists */
53
54 ASC_DLLSPEC int slv_block_partition_real(slv_system_t sys, int uppertriangular);
55 /**<
56 Takes a system and reorders its solvers_vars and solvers_rels
57 list so that they fall into a BUT/BLT (block upper/lower triangular) form
58 and the system's block list is set to match.
59 Only included equality relations and free, incident solver_var
60 are so ordered.
61
62 The blocks derived are put in the slv_system_t block list.
63
64 Produces whine about DOF analysis on file stderr.
65
66 @NOTE doesn't grok inequalities
67
68 ASSUMPTION: We assume that the variable and relation bit flags
69 are in sync with the flags on the atoms. The need for this
70 assumption and the associated bookkeeping should go away when
71 we move to using only the bit flags. Currently var_fixed and
72 rel_included are in charge of the syncronization.
73
74 @param upppertriangular if 1, partition into BUT form. If 0, partitition into BLT for.
75 @return 0 on success, 2 on out-of-memory, 1 on any other failure
76 */
77
78
79 ASC_DLLSPEC int slv_block_unify(slv_system_t sys);
80 /**<
81 * Takes a system that has been through slv_block_partition and combines
82 * the blocks that comprise rows 0 -> (structural_rank -1) and
83 * columns 0 to ncols-1 in the system's dof_t into one block.
84 * This may be useful for optimizers which want a whole rectangular
85 * block, and is used by our CONOPT wrapper.
86 */
87
88 ASC_DLLSPEC int slv_set_up_block(slv_system_t sys, int32 block);
89 /**<
90 This function should be called on blocks which have previously
91 been reordered. Variable and relation maintanence is performed
92 so that the block will be ready for an interation.
93
94 The further comments under slv_spk1_reorder_block also apply.
95 */
96
97 ASC_DLLSPEC int slv_spk1_reorder_block(slv_system_t sys,
98 int32 block, int32 transpose);
99 /**<
100 * System should have first been processed by slv_block_partition,
101 * so that all the current rows and columns within the block
102 * correspond to org rows and columns within the block.
103 * Within the diagonal block given (which must be square), an SPK1
104 * reordering is done. solvers_vars and solvers_rels lists are
105 * reordered and reindexed within that region to match.
106 * The block should contain only included equality relations and
107 * free, incident solver_vars.
108 * transpose determines if SPK1 is transposed.
109 * If we made a matrix out of the block, it should have a full
110 * diagonal.
111 *
112 @return 0 on success, 2 on out-of-memory, 1 on any other failure.
113 *
114 * Preconditions of use:
115 * No vars outside the block in the solvers_var list should have
116 * VAR_INBLOCK set to TRUE.
117 *
118 * Sideeffects:
119 * We will diddle with all the vars in the solvers_vars and solver_rels
120 * list so that all rel/vars inside the block respond TRUE to in_block.
121 * We will do this even if we decide to block is too small to be worth
122 * reordering or is the wrong shape.
123 *
124 * @bug This should optionally take a user supplied matrix so it doesn't
125 * allocate a big matrix header+perms every time. This needs some
126 * thought.
127 *
128 * @todo Revisit design of slv_set_up_block() - take user matrix?
129 */
130
131 ASC_DLLSPEC int slv_tear_drop_reorder_block(slv_system_t sys,
132 int32 blockindex,
133 int32 cutoff,
134 int two,
135 enum mtx_reorder_method blockmethod);
136 /**<
137 * System should have first been processed by slv_block_partition,
138 * so that all the current rows and columns within the block
139 * correspond to org rows and columns within the block.
140 * If you made a matrix out of the block, it should have a full
141 * diagonal.<br><br>
142 *
143 * Given a system and the index of a block in that system,
144 * applies a variant of the reordering hinted at in [Abbott,1996].
145 * The implementation here is by Ben Allan, so any discrepancies
146 * (positive) in performance with respect to the Abbott
147 * thesis data are Ben's fault.<br><br>
148 *
149 * If two != 0, applies an algorithm slightly more similar to that
150 * of Abbott, getting borders roughly twice as large.
151 * Preconditions of use: same as spk1_reorder_block.
152 * Sideeffects and bugs: same as spk1_reorder_block.
153 * Additional bugs: none known, but they're there.
154
155 @return ???
156 */
157
158 ASC_DLLSPEC int system_block_debug(slv_system_t sys, FILE *fp);
159 /**<
160 Create debug output detailing the current block structure of the system.
161 */
162
163 /*------------------------------------------------------------------------------
164 PARTITIONING FOR DAE SYSTEMS
165 */
166
167 ASC_DLLSPEC void system_var_list_debug(slv_system_t sys);
168 ASC_DLLSPEC void system_rel_list_debug(slv_system_t sys);
169
170
171 ASC_DLLSPEC int system_cut_vars(slv_system_t sys, const int start, const var_filter_t *vfilt, int *nvars);
172 /**
173 We start at position 'start' in the solver's var list. Any variable
174 that does not meet the filter 'vfilt' is moved to the back, and any
175 var that does stays. The number nvars of vars meeting the filter is returned.
176
177 Afterwards, we have 'start' vars left as-is, followed by the 'nvars' vars that
178 meet 'vfilt', followed by all remaining vars in the solvers var list.
179
180 @return 0 on success
181 */
182
183
184 ASC_DLLSPEC int system_cut_rels(slv_system_t sys, const int start, const rel_filter_t *rfilt, int *nrels);
185 /**
186 @see system_cut_vars. Same, but for rels.
187 */
188 #endif

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