1 |
/* |
2 |
* SLV: Ascend Nonlinear Solver |
3 |
* by Karl Michael Westerberg |
4 |
* Created: 2/6/90 |
5 |
* Version: $Revision: 1.22 $ |
6 |
* Version control file: $RCSfile: slv_server.h,v $ |
7 |
* Date last modified: $Date: 1998/03/30 22:07:09 $ |
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 |
* Copyright (C) 1996 Benjamin Andrew Allan |
16 |
* |
17 |
* The SLV solver is free software; you can redistribute |
18 |
* it and/or modify it under the terms of the GNU General Public License as |
19 |
* published by the Free Software Foundation; either version 2 of the |
20 |
* License, or (at your option) any later version. |
21 |
* |
22 |
* The SLV solver is distributed in hope that it will be |
23 |
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
25 |
* General Public License for more details. |
26 |
* |
27 |
* You should have received a copy of the GNU General Public License along with |
28 |
* the program; if not, write to the Free Software Foundation, Inc., 675 |
29 |
* Mass Ave, Cambridge, MA 02139 USA. Check the file named COPYING. |
30 |
* COPYING is found in ../compiler. |
31 |
*/ |
32 |
#ifndef slv_server_h__already_included |
33 |
#define slv_server_h__already_included |
34 |
|
35 |
/* requires #include "base.h" */ |
36 |
/* requires #include "var.h" */ |
37 |
/* requires #include "rel.h" */ |
38 |
/* requires #include "discrete.h" */ |
39 |
/* requires #include "conditional.h" */ |
40 |
/* requires #include "logrel.h" */ |
41 |
/* requires #include "bnd.h" */ |
42 |
/* requires #include "linsol.h" */ |
43 |
/* requires #include "linsolqr.h" */ |
44 |
/* requires #include "slv_common.h" */ |
45 |
/* requires #include "slv_types.h" */ |
46 |
/* requires #include "slv_client.h" */ |
47 |
|
48 |
/*** ! ! We are going through a solver API definition restructuring. |
49 |
! ! The appearance of ! ! in the header means the code in question |
50 |
! ! has, or is about to have, a change in its meaning or is code that |
51 |
! ! is new and replaces some or all the functionality of an old |
52 |
! ! function definition. Basically, expect to have to read ! ! sections |
53 |
! ! carefully and maybne patch calls dependent on them. |
54 |
**/ |
55 |
|
56 |
extern slv_system_t slv_create(void); |
57 |
/** |
58 |
*** sys = slv_create(); |
59 |
*** slv_system_t sys; |
60 |
*** |
61 |
*** Creates a system of the currently selected type in sys. |
62 |
**/ |
63 |
|
64 |
extern int slv_destroy(slv_system_t); |
65 |
/** |
66 |
*** slv_destroy(sys) |
67 |
*** slv_system_t sys; |
68 |
*** |
69 |
*** Destroys all currently created systems in sys. |
70 |
*** returns n if something untoward happens in destroy process. |
71 |
*** returns 0 normally. |
72 |
*** n is the total number of solvers with trouble destroying. |
73 |
**/ |
74 |
|
75 |
extern SlvBackendToken slv_instance(slv_system_t); |
76 |
extern void slv_set_instance(slv_system_t, SlvBackendToken); |
77 |
/** |
78 |
*** returns or sets the root instance of the slv system. |
79 |
*** All naming within the context of the slv_system_t is |
80 |
*** done relative to this instance pointer. |
81 |
*** |
82 |
*** NOTE: THESE TWO FUNCTIONS SHOULD TAKE A VOID * AND |
83 |
*** THEN THE USER SHOULD CAST IT BACK TO WHATEVER IS |
84 |
*** NEEDED GIVEN THE KNOWLEDGE OF THE BACK END IN QUESTION. |
85 |
**/ |
86 |
|
87 |
extern void slv_set_num_models(slv_system_t,int32); |
88 |
/** |
89 |
*** slv_set_num_models(sys,nmod); |
90 |
*** Sets the number of models associated with the system to nmod. |
91 |
**/ |
92 |
|
93 |
extern void slv_set_need_consistency(slv_system_t, int32); |
94 |
/* |
95 |
* slv_set_need_consistency(sys,need_consistency); |
96 |
* slv_need_consistency(sys); |
97 |
* Sets the int need_consitency associated with the system. |
98 |
*/ |
99 |
|
100 |
extern void slv_set_master_var_list(slv_system_t, struct var_variable **,int); |
101 |
extern void slv_set_master_par_list(slv_system_t, struct var_variable **,int); |
102 |
extern void slv_set_master_unattached_list(slv_system_t, |
103 |
struct var_variable **,int); |
104 |
extern void slv_set_master_dvar_list(slv_system_t, |
105 |
struct dis_discrete **,int); |
106 |
extern void slv_set_master_disunatt_list(slv_system_t, |
107 |
struct dis_discrete **,int); |
108 |
extern void slv_set_master_rel_list(slv_system_t, struct rel_relation **,int); |
109 |
extern void slv_set_master_condrel_list(slv_system_t, |
110 |
struct rel_relation **,int); |
111 |
extern void slv_set_master_obj_list(slv_system_t, struct rel_relation **,int); |
112 |
extern void slv_set_master_logrel_list(slv_system_t, |
113 |
struct logrel_relation **, |
114 |
int); |
115 |
extern void slv_set_master_condlogrel_list(slv_system_t, |
116 |
struct logrel_relation **, |
117 |
int); |
118 |
extern void slv_set_master_when_list(slv_system_t, struct w_when **,int); |
119 |
extern void slv_set_master_bnd_list(slv_system_t, struct bnd_boundary **,int); |
120 |
/** |
121 |
! ! slv_set_master_*_list(sys,list,size) |
122 |
*** slv_system_t sys; |
123 |
*** struct var_variable **vlist; |
124 |
*** struct rel_relation **rlist; |
125 |
*** struct dis_discrete **dvlist; |
126 |
*** struct logrel_relation **lrlist; |
127 |
*** struct w_when **wlist; |
128 |
*** struct bnd_boundary **wlist; |
129 |
*** int size; |
130 |
*** |
131 |
*** Set the master list of the given type. |
132 |
*** |
133 |
! ! |
134 |
! ! There are now 2 lists: the master list pulled of the instance |
135 |
! ! tree, and the solvers list is to be handed to the solvers. |
136 |
! ! Eventually the solvers_list will only include those elements the specific |
137 |
! ! solver needs to know about. |
138 |
! ! For the moment,the content of the two lists is the same, but the ordering |
139 |
! ! is not. The master list is in the order collected. The solvers list |
140 |
! ! is reordered in some useful fashion defined elsewhere. |
141 |
**/ |
142 |
|
143 |
extern void slv_set_symbol_list(slv_system_t, struct gl_list_t *); |
144 |
/* |
145 |
* set gllist of SymbolValues struct to sys. they are used to assign an |
146 |
* integer value to a symbol value |
147 |
*/ |
148 |
|
149 |
extern void slv_set_var_buf(slv_system_t, struct var_variable *); |
150 |
extern void slv_set_par_buf(slv_system_t, struct var_variable *); |
151 |
extern void slv_set_unattached_buf(slv_system_t, struct var_variable *); |
152 |
extern void slv_set_dvar_buf(slv_system_t, struct dis_discrete *,int); |
153 |
extern void slv_set_disunatt_buf(slv_system_t, struct dis_discrete *); |
154 |
extern void slv_set_rel_buf(slv_system_t, struct rel_relation *); |
155 |
extern void slv_set_condrel_buf(slv_system_t, struct rel_relation *); |
156 |
extern void slv_set_obj_buf(slv_system_t, struct rel_relation *); |
157 |
extern void slv_set_logrel_buf(slv_system_t, struct logrel_relation *); |
158 |
extern void slv_set_condlogrel_buf(slv_system_t, struct logrel_relation *); |
159 |
extern void slv_set_when_buf(slv_system_t, struct w_when *,int); |
160 |
extern void slv_set_bnd_buf(slv_system_t, struct bnd_boundary *,int); |
161 |
/** |
162 |
*** slv_set_*_buf(sys,array); |
163 |
*** You should give these functions a pointer to an array of |
164 |
*** the var or rel structure. These arrays should contain the |
165 |
*** memory pointed to by any and all pointers in the var/rel/when/bdn |
166 |
*** lists associated with the slv_system_t. If you have none |
167 |
*** of a particular type, its buf may be NULL. |
168 |
*** There is no way to RETRIEVE these -- they are destroyed with |
169 |
*** the slv_system_t. You should have no individually allocated |
170 |
*** vars/rels in the system: these are the only ones we will free. |
171 |
*** |
172 |
*** Calling any of these twice on the system is an extreme error. |
173 |
**/ |
174 |
|
175 |
extern void slv_set_incidence(slv_system_t, struct var_variable **,long); |
176 |
extern void slv_set_var_incidence(slv_system_t, struct rel_relation **,long); |
177 |
extern void slv_set_logincidence(slv_system_t, struct dis_discrete **,long); |
178 |
/** |
179 |
*** slv_set_incidence(sys,array,size); |
180 |
*** slv_set_var_incidence(sys,array,size); |
181 |
*** slv_set_logincidence(sys,array,size); |
182 |
*** |
183 |
*** slv_set_incidence: |
184 |
*** You should give this function a pointer to an array of |
185 |
*** struct var_variable *. This array should contain the |
186 |
*** memory pointed to by any and all pointers in rel incidence |
187 |
*** lists associated with the slv_system_t. |
188 |
*** There is no way to RETRIEVE these -- they are destroyed with |
189 |
*** the slv_system_t. You should have no individually allocated |
190 |
*** rel incidence in the system: this is the only one we will free. |
191 |
*** Size is the length of the array, which we want for accounting. |
192 |
*** slv_set_logincidence: |
193 |
*** slv_set_logincidence is the equivalent of slv_set_incidence but |
194 |
*** using logrels instead of rels and discrete vars instead of real |
195 |
*** vars. |
196 |
*** slv_set_var_incidence: |
197 |
*** corresponds to the list of relations in which a variable is incident |
198 |
*** as opposed to slv_set_incidence which is the list of variables incident |
199 |
*** in a relation. |
200 |
*** |
201 |
*** Calling any of this twice on the system is an extreme error. |
202 |
**/ |
203 |
|
204 |
extern void slv_set_extrel_list(slv_system_t,struct ExtRelCache **,int); |
205 |
extern struct ExtRelCache **slv_get_extrel_list(slv_system_t); |
206 |
extern int slv_get_num_extrels(slv_system_t); |
207 |
/** |
208 |
*** slv_set_extrel_list(sys,rlist,size) |
209 |
*** erlist = slv_get_extrel_list(sys) |
210 |
*** |
211 |
*** slv_system_t sys; |
212 |
*** struct ExtRelCache **erlist; |
213 |
*** int size; |
214 |
*** |
215 |
*** slv_set_extrel_list sets the external rellsit of the solver to the given |
216 |
*** one. The solver will merely reference the list, it will not |
217 |
*** make its own private copy of the list, nor will it destroy the |
218 |
*** list when the system is destroyed. This is a list of pointers to |
219 |
*** struct ExtRelCache's. These external rel caches provide convenient |
220 |
*** and quick access to information needed by external relations. All |
221 |
*** external relations with the same node stamp will point to the same |
222 |
*** ExtRelCache. The extrel list contains only unique ExtRelCaches though |
223 |
*** the list is not sorted. Size is the number of such ExtRelCaches. |
224 |
*** Calling slv_set_extrel_list twice on the same system is fatal. |
225 |
*** |
226 |
*** slv_get_extrel_list will return the most recently set extrel list (or |
227 |
*** NULL if it is empty) for the convenience of those who were not around |
228 |
*** when it was initially set. |
229 |
**/ |
230 |
|
231 |
extern int32 slv_obj_select_list(slv_system_t, int32 **); |
232 |
/** |
233 |
*** count = slv_obj_select_list(sys, rip) |
234 |
*** int32 count; |
235 |
*** slv_system_t sys; |
236 |
*** int32 **rip; |
237 |
*** |
238 |
*** slv_obj_select_list allocates rip and fills it with solver |
239 |
*** objective list positions of included objectives. |
240 |
*** The rip list is terminated with a -1. |
241 |
*** Returns number of objectives found. |
242 |
*** The calling function must free rip. |
243 |
**/ |
244 |
|
245 |
extern int32 slv_get_obj_num(slv_system_t); |
246 |
/** |
247 |
*** num = slv_get_obj_num(sys) |
248 |
*** int32 num; |
249 |
*** slv_system_t sys; |
250 |
*** |
251 |
*** slv_get_obj_num returns the solver list index |
252 |
*** of the current objective. If the objective is |
253 |
*** NULL then -1 is returned. |
254 |
**/ |
255 |
|
256 |
extern int32 slv_near_bounds(slv_system_t, real64, int32 **); |
257 |
/** |
258 |
*** count = slv_near_bounds(sys, epsilon, rip) |
259 |
*** int32 count; |
260 |
*** real64 epsilon; |
261 |
*** slv_system_t sys; |
262 |
*** int32 **rip; |
263 |
*** |
264 |
*** slv_check bounds allocates rip and fills it with |
265 |
*** 1) the number of vars close to lower bounds |
266 |
*** 2) the number of vars close to upper bounds |
267 |
*** 3) solver variable list positions of close to UB. |
268 |
*** 4) solver variable list positions of close to LB. |
269 |
*** 5) Returns number of variables close to bounds. |
270 |
*** |
271 |
*** A variable is close to its bound if |
272 |
*** abs(value - bound)/nominal < epsilon |
273 |
*** |
274 |
*** The calling function must free rip. |
275 |
**/ |
276 |
|
277 |
extern int32 slv_far_from_nominals(slv_system_t, real64, int32 **); |
278 |
/** |
279 |
*** count = slv_far_from_nominals(sys, bignum, rip) |
280 |
*** int32 count; |
281 |
*** real64 bignum; |
282 |
*** slv_system_t sys; |
283 |
*** int32 **rip; |
284 |
*** |
285 |
*** slv_check bounds allocates rip and fills it with |
286 |
*** solver variable list positions of variables far |
287 |
*** from nominal values. |
288 |
*** |
289 |
*** Test used: abs(value - nominal)/nominal > bignum |
290 |
*** |
291 |
*** The calling function must free rip. |
292 |
|
293 |
|
294 |
**/ |
295 |
|
296 |
|
297 |
#endif |