/[ascend]/trunk/base/generic/solver/conopt_dl.h
ViewVC logotype

Contents of /trunk/base/generic/solver/conopt_dl.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1751 - (show annotations) (download) (as text)
Mon Feb 11 05:27:18 2008 UTC (12 years, 1 month ago) by jpye
File MIME type: text/x-chdr
File size: 9512 byte(s)
Fixed bug #370 (CONOPT_LINKED behaviour on Windows, problems with 'PREDECOR')
1 /* ASCEND modelling environment
2 Copyright (C) 2006, 2007 Carnegie Mellon University
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA.
18 *//**
19 @file
20 Header file that in turn includes <conopt.h>.
21
22 This file exists in order to pass the correct FNAME_* parameter to
23 <conopt.h> and to permit wrapping of conopt routines for use in
24 a dlopened implementation.
25 *//*
26 By John Pye
27 Based on conopt.h by Vicente Rico Ramirez (created 05/97)
28 */
29
30 #ifndef ASC_CONOPT_H
31 #define ASC_CONOPT_H
32
33 /** @addtogroup solver Solver
34 @{
35 */
36
37 #include <utilities/config.h>
38 #include <utilities/ascConfig.h>
39
40 #include "conoptconfig.h"
41
42 /**
43 * Macros defined because of the different convention of Fortran from C about
44 * the use of an index in arrays (starting from zero or from one).
45 */
46 #define F2C(x) x - 1
47 #define C2F(x) x + 1
48
49 /*
50 Default bound limit for CONOPT
51 */
52 #define CONOPT_BOUNDLIMIT 3.1e9
53
54 /**
55 * Parameter required for CONOPT subroutines
56 */
57 #define NINTGR 3
58 #define MAX_INT 20000
59 #define MAX_REAL 10e300
60
61 /* What is our calling convention? */
62
63 #if !defined(_WIN32)
64 # define FNAME_LCASE_DECOR
65 #endif
66
67 #ifdef ASC_LINKED_CONOPT
68 /*----------------------------------------
69 LINKED CONOPT
70 */
71 # include "conopt.h"
72 #else
73 /*----------------------------------------
74 DLOPENED CONOPT
75 */
76
77 ASC_DLLSPEC int asc_conopt_load();
78
79 # define CONOPT_DISABLE_FN_DECLS
80 # include "conopt.h"
81 /*
82 This is a list of the functions that we're going to be using from CONOPT.
83 Using this list, we can automate the process of reading the function
84 pointers from the DLL
85 */
86
87 # define INTINT (int*cntvect,int*v)
88 # define INTINT1 (cntvect,v)
89 # define INTDOUBLE (int*cntvect,double*v)
90 # define INTDOUBLE1 (cntvect,v)
91
92 /**
93 This is a compressed list describing the function calls in the CONOPT
94 API. The first parameter in each 'D(...)' is the name we will be using to
95 access the function. The second is the parameter declaration. The third is a
96 parameter list that can be used to pass on the parameter to another function.
97 The final one is the text that is appended to the symbol name in the
98 case of the windows DLL, eg "_COIDEF_SIZE@0". That's a kludge because
99 the DLL contains decorated export symbols.
100 */
101 # define CONOPT_FNS(D,X) \
102 D( COIDEF_Size , () , () ,"@0") X \
103 D( COIDEF_Ini , ( int*cntvect), (cntvect) ,"@4") X \
104 D( COIDEF_NumVar , INTINT , INTINT1 ,"@8") X \
105 D( COIDEF_NumCon , INTINT , INTINT1 ,"@8") X \
106 D( COIDEF_NumNZ , INTINT , INTINT1 ,"@8") X \
107 D( COIDEF_NumNlNz , INTINT , INTINT1 ,"@8") X \
108 D( COIDEF_Base , INTINT , INTINT1 ,"@8") X \
109 D( COIDEF_OptDir , INTINT , INTINT1 ,"@8") X \
110 D( COIDEF_ObjCon , INTINT , INTINT1 ,"@8") X \
111 D( COIDEF_ObjVar , INTINT , INTINT1 ,"@8") X \
112 D( COIDEF_ItLim , INTINT , INTINT1 ,"@8") X \
113 D( COIDEF_ErrLim , INTINT , INTINT1 ,"@8") X \
114 D( COIDEF_IniStat , INTINT , INTINT1 ,"@8") X \
115 D( COIDEF_FVincLin , INTINT , INTINT1 ,"@8") X \
116 D( COIDEF_FVforAll , INTINT , INTINT1 ,"@8") X \
117 D( COIDEF_DebugFV , INTINT , INTINT1 ,"@8") X \
118 D( COIDEF_MaxSup , INTINT , INTINT1 ,"@8") X \
119 D( COIDEF_Square , INTINT , INTINT1 ,"@8") X \
120 D( COIDEF_EmptyRow , INTINT , INTINT1 ,"@8") X \
121 D( COIDEF_EmptyCol , INTINT , INTINT1 ,"@8") X \
122 D( COIDEF_Num2D , INTINT , INTINT1 ,"@8") X \
123 D( COIDEF_Debug2D , INTINT , INTINT1 ,"@8") X \
124 D( COIDEF_DisCont , INTINT , INTINT1 ,"@8") X \
125 D( COIDEF_StdOut , INTINT , INTINT1 ,"@8") X \
126 D( COIDEF_ClearM , INTINT , INTINT1 ,"@8") X \
127 D( COIDEF_2DPerturb , INTINT , INTINT1 ,"@8") X \
128 D( COIDEF_NDual , INTINT , INTINT1 ,"@8") X \
129 D( COIDEF_ResLim , INTDOUBLE , INTDOUBLE1 ,"@8") X \
130 D( COIDEF_WorkSpace , INTDOUBLE , INTDOUBLE1 ,"@8") X \
131 D( COIDEF_WorkFactor, INTDOUBLE , INTDOUBLE1 ,"@8") X \
132 D( COIDEF_ReadMatrix, (int*cntvect, COI_READMATRIX f), (cntvect,f) ,"@8") X \
133 D( COIDEF_FDEval , (int*cntvect, COI_FDEVAL f), (cntvect,f) ,"@8") X \
134 D( COIDEF_Status , (int*cntvect, COI_STATUS f), (cntvect,f) ,"@8") X \
135 D( COIDEF_Solution , (int*cntvect, COI_SOLUTION f), (cntvect,f) ,"@8") X \
136 D( COIDEF_Message , (int*cntvect, COI_MESSAGE f), (cntvect,f) ,"@8") X \
137 D( COIDEF_ErrMsg , (int*cntvect, COI_ERRMSG f), (cntvect,f) ,"@8") X \
138 D( COIDEF_Progress , (int*cntvect, COI_PROGRESS f), (cntvect,f) ,"@8") X \
139 D( COIDEF_Optfile , (int*cntvect, COI_OPTFILE f), (cntvect,f) ,"@8") X \
140 D( COIDEF_Option , (int*cntvect, COI_OPTION f), (cntvect,f) ,"@8") X \
141 D( COIDEF_TriOrd , (int*cntvect, COI_TRIORD f), (cntvect,f) ,"@8") X \
142 D( COIDEF_FDInterval, (int*cntvect, COI_FDINTERVAL f), (cntvect,f) ,"@8") X \
143 D( COIDEF_2DDir , (int*cntvect, COI_2DDIR f), (cntvect,f) ,"@8") X \
144 D( COIDEF_2DDirLag , (int*cntvect, COI_2DDIRLAG f), (cntvect,f) ,"@8") X \
145 D( COIDEF_2DLagr , (int*cntvect, COI_2DLAGR f), (cntvect,f) ,"@8") X \
146 D( COIDEF_SRFile , (int*cntvect, COI_SRFILE f), (cntvect,f) ,"@8") X \
147 D( COIDEF_DualBnd , (int*cntvect, COI_DUALBND f), (cntvect,f) ,"@8") X \
148 D( COIDEF_UsrMem , INTDOUBLE , INTDOUBLE1 ,"@8") X \
149 D( COIDEF_WorkMem , (int*cntvect, double*v, int*v2), (cntvect,v,v2),"@12")X \
150 D( COIGET_MaxUsed , (int*cntvect) , (cntvect) ,"@4") X \
151 D( COIGET_CurUsed , (int*cntvect) , (cntvect) ,"@4") X \
152 D( COI_Solve , (int*cntvect) , (cntvect) ,"@4") X \
153 D( COI_MemEst , (int*cntvect,double*v,double*v2),(cntvect,v,v2),"@12")X \
154 D( COI_Version , (float*v, char*c, int i), (v,c,i) ,"@12")
155
156 /*
157 Declare local functions to hook into the DLL
158 */
159 # define FN_PTR_HDR(T,A,V,L) \
160 ASC_DLLSPEC int COI_CALL T A;
161 # define SPACE
162
163 CONOPT_FNS(FN_PTR_HDR,SPACE)
164
165 # undef FN_PTR_HDR
166 # undef SPACE
167
168 # undef INTINT
169 # undef INTINT1
170 # undef INTDOUBLE
171 # undef INTDOUBLE1
172
173 #endif
174
175 /* either static or dlopened, this macro should now be defined */
176 #ifndef COIDEF_Size
177 # error "Where is COIDEF_Size?"
178 #endif
179
180 /**
181 Data structure for dealing with CONOPT
182 Do we still need this?
183 */
184 struct conopt_data {
185 int *cntvect; /* CONOPT's 'control vector' */
186
187 int n; /**< Number of columns. */
188 int m; /**< Number of rows. */
189 int nz; /**< Number of nonzeros. */
190 int nlnz; /**< Number of nonlinear nonzeros */
191 int base; /**< base of arrays, 1=fortran style */
192 int optdir; /**< optimisation direction */
193 int objcon; /**< objective constraint */
194
195 int32 maxrow; /**< Number of elements in densest row. */
196 int32 modsta; /**< Model status. */
197 int32 solsta; /**< Solver status. */
198 int32 iter; /**< Number of conopt iterations. */
199 real64 obj; /**< Objective value. */
200
201 real64 *work; /**< Work space. */
202 int32 minmem; /**< Minimum memory suggested by conopt. */
203 int32 estmem; /**< Estimated memory suggested by conopt. */
204 int32 lwork; /**< Size of allocated workspace. */
205 int32 nintgr; /**< Size of problem size vector. */
206 /* int32 ipsz[NINTGR]; */ /**< Problem size vector. */
207
208 int32 kept; /**< If 1 can call warm conopt restart. */
209
210 int32 optimized; /**< Has conopt been called? */
211 int32 maxusd; /**< Maximum work space used. */
212 int32 curusd; /**< Current work space used. */
213 int32 opt_count; /**< Count of calls to coiopt. */
214 int32 progress_count; /**< Count of calls to coiprg. */
215 };
216
217 /**
218 * Pointer to the previous structure
219 */
220 typedef struct conopt_function_pointers *conopt_pointers;
221
222 /* reporting functions (derived from 'std.c' in CONOPT examples) */
223
224 /* the symbols are exported because they are used in teh solvers, which are dlopened. */
225
226 ASC_DLLSPEC int COI_CALL asc_conopt_message( int* SMSG, int* DMSG, int* NMSG, int* LLEN
227 ,double* USRMEM, char* MSGV, int MSGLEN
228 );
229
230 ASC_DLLSPEC int COI_CALL asc_conopt_errmsg( int* ROWNO, int* COLNO, int* POSNO, int* MSGLEN
231 , double* USRMEM, char* MSG, int LENMSG
232 );
233
234 ASC_DLLSPEC int COI_CALL asc_conopt_status(int* MODSTA, int* SOLSTA
235 , int* ITER, double* OBJVAL, double* USRMEM
236 );
237
238 ASC_DLLSPEC int COI_CALL asc_conopt_solution( double* XVAL, double* XMAR, int* XBAS
239 , int* XSTA, double* YVAL, double* YMAR, int* YBAS, int* YSTA
240 , int* N, int* M, double* USRMEM
241 );
242
243 ASC_DLLSPEC int COI_CALL asc_conopt_progress( int* LEN_INT, int* INT, int* LEN_RL
244 , double* RL, double* X, double* USRMEM
245 );
246
247 /* @} */
248
249 #endif /* ASC_CONOPT_H */
250

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