/[ascend]/trunk/ascend4/solver/conopt.h
ViewVC logotype

Annotation of /trunk/ascend4/solver/conopt.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (hide annotations) (download) (as text)
Fri Oct 29 20:54:12 2004 UTC (17 years, 8 months ago) by aw0a
File MIME type: text/x-chdr
File size: 14505 byte(s)
Setting up web subdirectory in repository
1 aw0a 1 /*
2     * External Definitions of CONOPT Subroutines
3     * by Vicente Rico Ramirez
4     * Created: 05/97
5     * Version: $Revision: 1.9 $
6     * Version control file: $RCSfile: conopt.h,v $
7     * Date last modified: $Date: 1998/02/26 15:57:56 $
8     * Last modified by: $Author: mthomas $
9     *
10     * This file is part of the SLV solver.
11     *
12     * The SLV solver is free software; you can redistribute
13     * it and/or modify it under the terms of the GNU General Public License as
14     * published by the Free Software Foundation; either version 2 of the
15     * License, or (at your option) any later version.
16     *
17     * The SLV solver is distributed in hope that it will be
18     * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
19     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20     * General Public License for more details.
21     *
22     * You should have received a copy of the GNU General Public License
23     * along with the program; if not, write to the Free Software Foundation,
24     * Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check the file named
25     * COPYING. COPYING is found in ../compiler.
26     *
27     */
28    
29     #ifndef conopt__already_included
30     #define conopt__already_included
31    
32     /*
33     * Macros defined because of the different convention of Fortran from C about
34     * the use of an index in arrays (starting from zero or from one).
35     */
36     #define F2C(x) x - 1
37     #define C2F(x) x + 1
38    
39     /*
40     * Parameter required for CONOPT subroutines
41     */
42     #define NINTGR 3
43     #define MAX_INT 20000
44     #define MAX_REAL 10e300
45    
46     /*
47     * CONOPT data structure.
48     */
49     struct conopt_data {
50     int32 n; /* number of columns */
51     int32 m; /* number of rows */
52     int32 nz; /* number of nonzeros */
53     int32 maxrow; /* number of elements in densest row */
54     int32 modsta; /* model status */
55     int32 solsta; /* solver status */
56     int32 iter; /* # of conopt iterations */
57     real64 obj; /* objective value */
58    
59     real64 *work; /* work space */
60     int32 minmem; /* minimum memory suggested by conopt */
61     int32 estmem; /* estimated memory suggested by conopt */
62     int32 lwork; /* size of allocated workspace */
63     int32 nintgr; /* size of problem size vector */
64     int32 ipsz[NINTGR]; /* problem size vector */
65    
66     int32 kept; /* if 1 can call warm conopt restart */
67    
68     int32 optimized; /* has conopt been called? */
69     int32 maxusd; /* maximum work space used */
70     int32 curusd; /* current work space used */
71     int32 opt_count; /* count of calls to coiopt */
72     int32 progress_count; /* count of calls to coiprg */
73     };
74    
75     /*
76     * Structure of function pointers, so that a particular solver can define
77     * its user-defined CONOPT subroutines independently
78     */
79     struct conopt_function_pointers {
80     void (*coirms_ptr)();
81     void (*coifbl_ptr)();
82     void (*coifde_ptr)();
83     void (*coista_ptr)();
84     void (*coirs_ptr)();
85     void (*coiusz_ptr)();
86     void (*coiopt_ptr)();
87     void (*coipsz_ptr)();
88     void (*coimsg_ptr)();
89     void (*coiscr_ptr)();
90     void (*coiec_ptr)();
91     void (*coier_ptr)();
92     void (*coienz_ptr)();
93     void (*coiprg_ptr)();
94     void (*coiorc_ptr)();
95     };
96    
97     /*
98     * Pointer to the previous structure
99     */
100     typedef struct conopt_function_pointers *conopt_pointers;
101    
102    
103     /*
104     * is CONOPT available ?
105     */
106     #if (defined(STATIC_CONOPT) || defined(DYNAMIC_CONOPT))
107     #define CONOPT_ACTIVE TRUE
108     #else /* defined(STATIC_CONOPT) */
109     #define CONOPT_ACTIVE FALSE
110     #endif /* defined(STATIC_CONOPT) */
111    
112    
113     #if CONOPT_ACTIVE /* code used if CONOPT is available */
114     /*
115     * Take care of fortran underbar madness
116     */
117     #ifdef sun
118     #define FORTRAN_UNDERBARS
119     #endif /* sun */
120    
121     #ifdef __alpha
122     #define FORTRAN_UNDERBARS
123     #endif /* __alpha */
124    
125     #ifdef __sgi
126     #define FORTRAN_UNDERBARS
127     #endif /* __sgi */
128    
129     #ifdef __WIN32__
130     /* dec visual fortran */
131     #define COICSM COICSM
132     #define COIMEM COIMEM
133     #define COIRMS COIRMS
134     #define COIFBL COIFBL
135     #define COIFDE COIFDE
136     #define COISTA COISTA
137     #define COIRS COIRS
138     #define COIUSZ COIUSZ
139     #define COIOPT COIOPT
140     #define COIPSZ COIPSZ
141     #define COIMSG COIMSG
142     #define COISCR COISCR
143     #define COIEC COIEC
144     #define COIER COIER
145     #define COIENZ COIENZ
146     #define COIPRG COIPRG
147     #define COIORC COIORC
148     #else
149     /* unixisms */
150     #ifdef FORTRAN_UNDERBARS
151     #define COICSM coicsm_
152     #define COICRM coicrm_
153     #define COIMEM coimem_
154     #define COIRMS coirms_
155     #define COIFBL coifbl_
156     #define COIFDE coifde_
157     #define COISTA coista_
158     #define COIRS coirs_
159     #define COIUSZ coiusz_
160     #define COIOPT coiopt_
161     #define COIPSZ coipsz_
162     #define COIMSG coimsg_
163     #define COISCR coiscr_
164     #define COIEC coiec_
165     #define COIER coier_
166     #define COIENZ coienz_
167     #define COIPRG coiprg_
168     #define COIORC coiorc_
169     #else
170     #define COICSM coicsm
171     #define COICRM coicrm
172     #define COIMEM coimem
173     #define COIRMS coirms
174     #define COIFBL coifbl
175     #define COIFDE coifde
176     #define COISTA coista
177     #define COIRS coirs
178     #define COIUSZ coiusz
179     #define COIOPT coiopt
180     #define COIPSZ coipsz
181     #define COIMSG coimsg
182     #define COISCR coiscr
183     #define COIEC coiec
184     #define COIER coier
185     #define COIENZ coienz
186     #define COIPRG coiprg
187     #define COIORC coiorc
188     #endif /* FORTRAN_UNDERBARS */
189     #endif /* !WIN */
190    
191    
192     /*
193     * Optimization subroutines for CONOPT
194     * ---------------------------------
195     */
196    
197     extern void COIRMS(real64 *, real64 *, real64 *, int32 *, int32 *, real64 *,
198     real64 *, int32 *, int32 *, int32 *, real64 *, int32 *,
199     int32 *, int32 *, int32 *, int32 *, real64 *);
200     /*
201     * COIRMS Based on the information provided in Coispz, CONOPT will
202     * allocate the number of vectors into which the user can define
203     * the details of the model. The details of the model are defined
204     * here.
205     *
206     * COIRMS(lower, curr, upper, vsta, type,rhs, fv, esta, colsta,
207     * rowno, value, nlflag, n, m, n1, nz, usrmem)
208     *
209     * lower - lower bounds on the variables
210     * curr - intial values of the variables
211     * upper - upper bounds on the variables
212     * vsta - initial status of the variable(o nonbasic, 1 basic)
213     * type - types of equations (0 equality,1 greater,2 less)
214     * rhs - values of the right hand sides
215     * fv - sum of the nonlinear terms in the initial point
216     * esta - initial status of the slack in the constraint (nonbasic,basic)
217     * colsta- start of column pointers
218     * rowno - row or equation numbers of the nonzeros
219     * value - values of the jacobian elements
220     * nlflag- nonlinearity flags(0 nonzero constant,1 varying)
221     * n - number of variables
222     * m - number of constraints
223     * n1 - n+1
224     * nz - number of jacobian elements
225     * usrmem- user memory defined by conopt
226     */
227    
228    
229     extern void COIFBL(real64 *, real64 *, int32 *, int32 *, int32 *, int32 *,
230     real64 *, int32 *, int32 *, int32 *, int32 *, int32 *,
231     int32 *, int32 *, int32 *, int32 *, int32 *, int32 *,
232     int32 *, int32 *, int32 *, real64 *);
233     /*
234     * COIFBL Defines the nonlinearities of the model by returning
235     * numerical values. It works on a block of rows during each call.
236     * COIFBL( x, g, otn, nto, from, to, jac, stcl, rnum, cnum, nl, strw,
237     * llen, indx, mode, errcnt, n, m, n1, m1, nz, usrmem)
238     *
239     * x - punt of evaluation provided by conopt
240     * g - vector of function values
241     * otn - old to new permutation vector
242     * nto - new to old permutation vector
243     * from - range in permutation
244     * to - range in permutation
245     * jac - vector of jacobian values.
246     * The following are vectors defining the jacobian structure
247     * stcl - start of column pointers
248     * rnum - row numbers
249     * cnum - column numbers
250     * nl - nonlinearity flags
251     * strw - start row pointers
252     * llen - count of linear jacobian elements
253     * indx - pointers from the row-wise representation
254     * mode - indicator of mode of evaluation
255     * errcnt- number of function evaluation errors
256     * n - umber of variables
257     * m - number of constraints
258     * n1 - n+1
259     * m1 - m+1
260     * nz - number of jacobian elements
261     * usrmem- user memory defined by conopt
262     */
263    
264    
265     extern void COIFDE(real64 *, real64 *, real64 *, int32 *, int32 *, int32 *,
266     int32 *, int32 *, int32 *, int32 *, real64 *);
267     /*
268     * COIFDE Defines the nonlinearities of the model by returning
269     * numerical values. It works on one row or equation at a time
270     * COIFDE(x, g, jac, rowno, jcnm, mode, errcnt, newpt, n, nj, usrmem)
271     *
272     * x - punt of evaluation provided by conopt
273     * g - function value
274     * jac - jacobian values
275     * rowno - number of the row for which nonlinearities will be eval
276     * jcnm - list of column number fon the NL nonzeros
277     * mode - indicator of mode of evaluation
278     * errcnt - sum of number of func evaluation errors thus far
279     * newpt - new point indicator
280     * nj - number of nonlinear nonzero jacobian elements
281     * n - number of variables
282     * usrmem - user memory
283     */
284    
285    
286     extern void COISTA(int32 *, int32 *, int32 *, real64 *, real64 *);
287     /*
288     * COISTA Pass the solution from CONOPT to the modeler. It returns
289     * completion status
290     * COISTA(modsta, solsts, iter, objval, usrmem)
291     *
292     * modsta - model status
293     * solsta - solver status
294     * iter - number of iterations
295     * objval - objective value
296     * usrmem - user memory
297     */
298    
299    
300     extern void COIRS(real64 *, real64 *, int32 *, int32 *, real64 *, real64 *,
301     int32 *, int32 *, int32 *, int32 *, real64 *);
302     /*
303     * COIRS passes the solution from CONOPT to the modeler. It returns
304     * solution values
305     * COIRS(val, xmar, xbas, xsta, yval, ymar, ybas, ysta, n, m, usrmem)
306     *
307     * xval - the solution values of the variables
308     * xmar - corresponding marginal values
309     * xbas - basis indicator for column (at bound, basic, nonbasic)
310     * xsta - status of column (normal, nonoptimal, infeasible,unbounded)
311     * yval - values of the left hand side in all the rows
312     * ymar - corresponding marginal values
313     * ybas - basis indicator for row
314     * ysta - status of row
315     * n - number of variables
316     * m - number of constraints
317     * usrmem - user memory
318     */
319    
320    
321     extern void COIUSZ(int32 *, int32 *, int32 *, real64 *, real64 *);
322     /*
323     * COIUSZ communicates and update of an existing model to CONOPT
324     * COIUSZ(nintg, ipsz, nreal, rpsz, usrmem)
325     *
326     * nintg - number of positions in ipsz
327     * ipsz - array describing problem size and options
328     * nreal - number of positions in rpsz
329     * rpsz - array of reals describing problem size and options
330     * usrmem- user memory
331     */
332    
333    
334     extern void COIOPT(char *, real64 *, int32 *, int32 *, real64 *);
335     /*
336     * COIOPT communicates non-default option values to CONOPT
337     * COIOPT(name, rval, ival, lval, usrmem)
338     * name - the name of a CONOPT CR-cell defined by the modeler
339     * rval - the value to be assigned to name if the cells contains a real
340     * ival - the value to be assigned to name if the cells contains an int
341     * lval - the value to be assigned to name if the cells contains a log value
342     * usrmem - user memory
343     */
344    
345    
346     extern void COIPSZ(int32 *, int32 *, int32 *, real64 *, real64 *);
347     /*
348     * COIPSZ communicates the model size and structure to CONOPT
349     * COIPSZ(nintg, ipsz, nreal, rpsz, usrmem)
350     *
351     * ningt - number of positions in ipsz
352     * ipsz - array describing problem size and options
353     * nreal - number of positions in rpsz
354     * rpsz - array of reals describing problem size and options
355     * usrmem - user memory
356     */
357    
358     extern void COIMSG (int32 *nmsg, int32 *smsg, int32 *llen,
359     char msgv[80*15],real64 *usrmem);
360    
361     extern void COISCR (char msg[80], int32 *len);
362    
363     extern void COIEC (int32 *colno, int32 *msglen, char msg[80],real64 *usrmem);
364    
365     extern void COIER (int32 *rowno, int32 *msglen, char msg[80],real64 *usrmem);
366    
367     extern void COIENZ (int32 *colno, int32 *rowno, int32 *posno,
368     int32 *msglen, char msg[80],real64 *usrmem);
369    
370     extern void COIPRG (int32 *nintgr, int32 *intrep, int32 *nreal,
371     real64 *rl, real64 *x, real64 *usrmem, int32 *finish);
372    
373     extern void COIORC (int32 *colno, int32 *rowno, real64 *value,
374     real64 *resid,real64 *usrmem);
375    
376     /*
377     * IMPORTANT: The use of the following functions is a H A C K to avoid
378     * unresolved externals while linking to the CONOPT library. For some
379     * reason, the linker wants the calls to the provided subroutines
380     * COICSM and COIMEM in the same file as the definition of the user
381     * defined CONOPT subroutines
382     */
383    
384     /*
385     * Passes arguments to COIMEM
386     */
387     extern void conopt_estimate_memory(int32 *, int32 *, int32 *, int32 *);
388    
389     /*
390     * Passes arguments to COICRM
391     */
392     extern void conopt_restart(int32 *, real64 **, int32 *, real64 *, int32 *,
393     int32 *);
394    
395     /*
396     * Passes arguments to COICSM
397     */
398     extern void conopt_start(int32 *, real64 **, int32 *, real64 *, int32 *,
399     int32 *);
400    
401    
402     #if defined(DYNAMIC_CONOPT)
403     /*
404     * conopt_load attempts to dynamically load CONOPT.
405     * Returns 0 for success, 1 for failure.
406     */
407     int32 conopt_load(void);
408     #else
409     /*
410     * CONOPT Provided Subroutines.Only the external definition. The
411     * code for the subroutines is provided by CONOPT.
412     */
413    
414     /*
415     * Memory estimation by using CONOPT subroutine coimem
416     *
417     * COIMEM Estimates the amount of memory needed by CONOPT
418     * COIMEM(nintgr, ipsz, minmem, estmem)
419     *
420     * nintgr - number of elements in the array ipsz. Should be 3.
421     * ipsz - vector of integers to describe the size of the model
422     * minmem - Minimum estimate for the memory needed. Measured in
423     * number of real elements of work
424     * estmem - Estimate of the amount of memory
425     */
426     extern void COIMEM(int32 *, int32 *, int32 *, int32 *);
427    
428     /*
429     * COICRM restarts CONOPT with user memory
430     * COICRM(kept, usrmem, lwork, work, maxusd, curusd)
431     *
432     * kept - Whether CONOPT has kept the model after solving it or not
433     * usrmem - array passed to all subroutines. If not needed is dummy array
434     * lwork - lenght of working array work
435     * work - working array supplied by the user
436     * maxusd - maximum amount of memory in work used during optimization
437     * curusd - current amount of memory in use
438     */
439     extern void COICRM(int32 *, real64 *, int32 *, real64 *, int32 *, int32 *);
440    
441     /*
442     * COICSM starts up CONOPT with user memory
443     * COICSM(kept, usrmem, lwork, work, maxusd, curusd)
444     *
445     * kept - Whether CONOPT has kept the model after solving it or not
446     * usrmem - array passed to all subroutines. If not needed is dummy array
447     * lwork - lenght of working array work
448     * work - working array supplied by the user
449     * maxusd - maximum amount of memory in work used during optimization
450     * curusd - current amount of memory in use
451     */
452     extern void COICSM(int32 *, real64 *, int32 *, real64 *, int32 *, int32 *);
453     #endif /* DYNAMIC_CONOPT */
454     #endif /* if CONOPT_ACTIVE */
455     #endif /* conopt__already_included */
456    
457    

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